Class ObjectStore

  • Direct Known Subclasses:
    DispatchingObjectStore, ReflectedObjectStore

    public abstract class ObjectStore
    extends java.lang.Object
    This is a wrapper for the data layer in an application. Any code that accesses a database or some other form of data should be in a subclass of ObjectStore
    Version:
    $Revision: 1.4 $
    • Constructor Detail

      • ObjectStore

        protected ObjectStore()
        Create an instance
    • Method Detail

      • setResourceFactoryMap

        public final void setResourceFactoryMap​(java.util.Map inputMap)

        Set the resource map. This defines what class is used when a specific resource factory is requested.

        It is recommended to use setResourceManager(ResourceManager) instead

        Parameters:
        inputMap - A map containing string/class pairs.
      • setResourceManager

        public final void setResourceManager​(ResourceManager resourceManager)
        Set the resource manager
        Parameters:
        resourceManager - The new resource manager
      • getResourceManager

        public final ResourceManager getResourceManager()
        Gets the resource manager
        Returns:
        The resource manager or null if a resource manager has not been set.
      • handleException

        protected java.lang.Object handleException​(java.lang.Exception exception)
                                            throws ObjectStoreException,
                                                   ObjectStoreCommandNotSupportedException
        Handle an exception that occured during the processing of executeImpl(). Usually these exceptions will be rethrown after logging them to some error log

        The default behaviour is to rethrow any ObjectStoreExceptions or ObjectStoreCommandNotSupportedExceptions. All other exceptions are wrapped in a new ObjectStoreException and then that wrapper is thown

        Parameters:
        exception - the exception that had been thrown
        Returns:
        The object to return from execute in those cases where an exception is not thrown out of this method
        Throws:
        ObjectStoreException - The exception to be thrown back out of execute()
        ObjectStoreCommandNotSupportedException - the exception to be thrown back out of execute()
      • handleError

        protected java.lang.Object handleError​(java.lang.Error error)
        Handle an exception that occured during the processing of executeImpl(). Usually these exceptions will be rethrown after logging them to some error log

        The default behaviour is to rethrow the error

        Parameters:
        error - The error that had been thrown
        Returns:
        The object to return from execute in those cases where an exception is not thrown out of this method
      • getResource

        protected final java.lang.Object getResource​(java.lang.String name)
        Return a resource from the specified factory
        Parameters:
        name - The name of the factory
        Returns:
        The specified resource
        See Also:
        setResourceFactoryMap(Map)
      • releaseResource

        protected final void releaseResource​(ManagedResource object)
        Release the specified resource
        Parameters:
        object - The resource to release
      • getResourceManagerOrDie

        private ResourceManager getResourceManagerOrDie()
        Return the resource manager. If a resource manager has not been specified then throw an exception.
        Returns:
        The resource manager
      • assertNotNull

        protected final void assertNotNull​(java.lang.String fieldName,
                                           java.lang.Object object)
        Throw an exception if the specified object is null
        Parameters:
        fieldName - The name of the paremeter we are checking
        object - The value of the parameter we are checking