001package com.identityworksllc.iiq.common; 002 003import org.apache.commons.logging.LogFactory; 004 005import com.identityworksllc.iiq.common.logging.SLogger; 006 007import sailpoint.api.SailPointContext; 008 009import java.util.Objects; 010import java.util.concurrent.atomic.AtomicBoolean; 011 012/** 013 * The base class for each Utilities class that contains common functions to all 014 */ 015@SuppressWarnings("unused") 016public abstract class AbstractBaseUtility { 017 018 /** 019 * The SailPointContext 020 */ 021 protected final SailPointContext context; 022 023 protected final AtomicBoolean debug; 024 025 /** 026 * The logger for this class 027 */ 028 protected final SLogger log; 029 030 /** 031 * Constructor, builds some common functions 032 */ 033 public AbstractBaseUtility(SailPointContext context) { 034 this.log = new SLogger(LogFactory.getLog(this.getClass())); 035 this.context = context; 036 this.debug = new AtomicBoolean(); 037 } 038 039 /** 040 * Injects this object into the given Beanshell context, making all of this 041 * object's methods available as 'static' methods in Beanshell. 042 * @param beanshell The beanshell context to inject into 043 */ 044 public void inject(bsh.This beanshell) { 045 beanshell.getNameSpace().importObject(this); 046 } 047 048 /** 049 * Returns true if the debug flag has been set on this utility 050 * @return The debug flag state 051 */ 052 public boolean isDebug() { 053 return this.debug.get(); 054 } 055 056 /** 057 * Sets or unsets the debug flag 058 * @param debug The new debug flag state 059 */ 060 public final void setDebug(boolean debug) { 061 this.debug.set(debug); 062 } 063 064}