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 * @author Devin Rosenbauer
016 * @author Instrumental Identity
017 */
018@SuppressWarnings("unused")
019public abstract class AbstractBaseUtility {
020        
021        /**
022         * The SailPointContext
023         */
024        protected final SailPointContext context;
025
026        protected final AtomicBoolean debug;
027
028        /**
029         * The logger for this class
030         */
031        protected final SLogger log;
032        
033        /**
034         * Constructor, builds some common functions
035         */
036        public AbstractBaseUtility(SailPointContext context) {
037                this.log = new SLogger(LogFactory.getLog(this.getClass()));
038                this.context = context;
039                this.debug = new AtomicBoolean();
040        }
041
042        /**
043         * Injects this object into the given Beanshell context, making all of this
044         * object's methods available as 'static' methods in Beanshell.
045         * @param beanshell The beanshell context to inject into
046         */
047        public void inject(bsh.This beanshell) {
048                beanshell.getNameSpace().importObject(this);
049        }
050
051        /**
052         * Returns true if the debug flag has been set on this utility
053         * @return The debug flag state
054         */
055        public boolean isDebug() {
056                return this.debug.get();
057        }
058
059        /**
060         * Sets or unsets the debug flag
061         * @param debug The new debug flag state
062         */
063        public final void setDebug(boolean debug) {
064                this.debug.set(debug);
065        }
066        
067}