com.ibm.itim.script.wrappers

Class ObjectWrapperManager

  • java.lang.Object
    • com.ibm.itim.script.wrappers.ObjectWrapperManager


  • public class ObjectWrapperManager
    extends java.lang.Object
    Main entry point to wrap an Object to place in the scripting environment. Each script evaluating thread has its own ObjectWrapperManager instance. An instance is created for the first time for a script evaluating thread and stored in OWMInstances Map. This instance is used during the evaluation of the entire script. Once the script evaluation completes, the instance of ObjectWrapperManager is removed from OWMInstances map.
    Since:
    ITIM 5.0
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String NO_WRAP
      Factory name to use for classes that should not be wrapped.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static void dispose()
      Remove the ObjectWrapperManager instance from the Map once the script evaluation has completed.
      static ObjectWrapperManager getInstance()
      Get a reference to the ObjectWrapperManager which is created by the current script evaluating thread.
      java.lang.Object lookupItem(java.lang.String name)
      Gets the origional Object with the given name.
      void remove(java.lang.String key)
      Remove the Object associated with key from the lookup map.
      void storeItem(java.lang.Object obj, ObjectWrapper wrapper)
      This method generates a unique key for the wrapper and sets the name via the ObjectWrapper.setKey(String key) method, then inserts obj into the lookup map maintained by ObjectWrapperManager so we can get at the origional object later.
      java.lang.Object wrap(java.lang.String name, java.lang.Object obj, java.lang.String lang, java.lang.Object param)
      Wraps obj with the correct type of Wrapper based on the configuration.
      java.lang.Object wrapInternalObject(java.lang.String name, java.lang.Object obj, java.lang.String lang, java.lang.Object param)
      Wraps obj with the correct type of Wrapper based on the configuration.
      If the wrapper to use for obj is com.ibm.itim.script.wrappers.NO_WRAP then obj will be returned and not wrapped or inserted into the lookup map.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NO_WRAP

        public static final java.lang.String NO_WRAP
        Factory name to use for classes that should not be wrapped. ObjectWrapperManager will deal with these objects in a consistant manner.
        See Also:
        Constant Field Values
    • Method Detail

      • getInstance

        public static ObjectWrapperManager getInstance()
        Get a reference to the ObjectWrapperManager which is created by the current script evaluating thread. If the getInstance() is called for the first time by this thread, then a new instance is created, put in the map and returned. If the instance already exist in the map, then it is returned.
        Returns:
        an instance of ObjectWrapperManager
      • wrap

        public java.lang.Object wrap(java.lang.String name,
                                     java.lang.Object obj,
                                     java.lang.String lang,
                                     java.lang.Object param)
        Wraps obj with the correct type of Wrapper based on the configuration. If the wrapper to use for obj is com.ibm.itim.script.wrappers.NO_WRAP then obj will be returned and not wrapped or inserted into the lookup map.
        Parameters:
        name - Name that can be used to look this bean up using the ScriptEvaluator. This is typically the bean name, and can be null. If name is null, then a unique id will be automatically assigned.
        obj - The Object to wrap.
        lang - The scripting language we are using.
        param - Some wrapper classes need parameters to correctly wrap objects. param is how this information is passed.
        Returns:
        null - if (obj == null)
        null - if param is not sufficient to wrap the object for the given language.
        obj - if the wrapper for obj is com.ibm.itim.script.wrappers.NO_WRAP.
        obj - if (obj instanceof ObjectWrapper)
        obj - if (obj instanceof ExtensionBean)
        Wrapped object - else.
      • remove

        public void remove(java.lang.String key)
        Remove the Object associated with key from the lookup map. This method should only be called by the dispose() method of ObjectWrapper classes. Though the references to this method still exist, this method is not used anymore by internal script engine implementation of ITIM.
        Parameters:
        key - The key (or name) used to lookup objects in ObjectWrapperManager. Since this method is only supposed to be called by ObjectWrapper classes, key can be gotten from the getKey() method.
      • dispose

        public static void dispose()
        Remove the ObjectWrapperManager instance from the Map once the script evaluation has completed.
      • lookupItem

        public java.lang.Object lookupItem(java.lang.String name)
        Gets the origional Object with the given name.
        Parameters:
        name - The name of the Object used when wrapping the Object.
        Returns:
        The Object associated with name.
      • storeItem

        public void storeItem(java.lang.Object obj,
                              ObjectWrapper wrapper)
        This method generates a unique key for the wrapper and sets the name via the ObjectWrapper.setKey(String key) method, then inserts obj into the lookup map maintained by ObjectWrapperManager so we can get at the origional object later. This method exists so that items constructed from the script environment, in their wrappers, can still be accessed outside of the scripting environment.
        Parameters:
        obj - The object that is wrapped.
        wrapper - The wrapped version of obj.
      • wrapInternalObject

        public java.lang.Object wrapInternalObject(java.lang.String name,
                                                   java.lang.Object obj,
                                                   java.lang.String lang,
                                                   java.lang.Object param)
        Wraps obj with the correct type of Wrapper based on the configuration.
        If the wrapper to use for obj is com.ibm.itim.script.wrappers.NO_WRAP then obj will be returned and not wrapped or inserted into the lookup map.
        Parameters:
        name - Name that can be used to look this bean up using the ScriptEvaluator. This is typically the bean name, and can be null. If name is null, then a unique id will be automatically assigned.
        obj - The Object to wrap.
        lang - The scripting language we are using.
        param - Some wrapper classes need parameters to correctly wrap objects. param is how this information is passed.
        Returns:
        null - if (obj == null)
        null - if param is not sufficient to wrap the object for the given language.
        obj - if the wrapper for obj is com.ibm.itim.script.wrappers.NO_WRAP.
        obj - if (obj instanceof ObjectWrapper)
        obj - if (obj instanceof ExtensionBean)
        Wrapped object - else.