Interface ExecutionContext

  • All Superinterfaces:
    ExecutionContextReference
    All Known Implementing Classes:
    ExecutionContextImpl, ExecutionContextThreadedImpl

    public interface ExecutionContext
    extends ExecutionContextReference
    Context of execution for persistence operations. This equates to the work of a PersistenceManager/EntityManager. An ExecutionContext is responsible for
    • persist, merge, find and delete of persistable objects from the defined StoreManager
    • have a set of properties defining behaviour over and above the default configuration of the parent NucleusContext
    • provide an interface to querying of the persistable objects in the StoreManager
    • provide a way of managing persistable objects using StateManagers
    • have a cache of currently managed objects (the "Level 1" cache), and make use of the cache of the parent NucleusContext when not available in its cache
    • have a single "current" transaction. This transaction can be local, or JTA

    An ExecutionContext can be started with a series of options that affect its behaviour thereafter. These are defined by the "OPTION_{YYY}" static Strings.

    • Field Detail

      • OPTION_USERNAME

        static final String OPTION_USERNAME
        Startup option overriding the default (PMF/EMF) username for the connectionURL.
        See Also:
        Constant Field Values
      • OPTION_PASSWORD

        static final String OPTION_PASSWORD
        Startup option overriding the default (PMF/EMF) password for the connectionURL.
        See Also:
        Constant Field Values
      • OPTION_JTA_AUTOJOIN

        static final String OPTION_JTA_AUTOJOIN
        Startup option setting whether, when using JTA, to do auto-join of transactions.
        See Also:
        Constant Field Values
    • Method Detail

      • getTransaction

        Transaction getTransaction()
        Accessor for the current transaction for this execution context.
        Returns:
        The current transaction
      • getStoreManager

        default StoreManager getStoreManager()
        Accessor for the Store Manager.
        Returns:
        Store Manager
      • getMetaDataManager

        default MetaDataManager getMetaDataManager()
        Accessor for the MetaData Manager.
        Returns:
        The MetaData Manager
      • getNucleusContext

        PersistenceNucleusContext getNucleusContext()
        Accessor for the context in which this execution context is running.
        Returns:
        Returns the context.
      • getApiAdapter

        default ApiAdapter getApiAdapter()
        Accessor for the API adapter.
        Returns:
        API adapter.
      • getFetchPlan

        FetchPlan getFetchPlan()
        Acessor for the current FetchPlan
        Returns:
        FetchPlan
      • getClassLoaderResolver

        ClassLoaderResolver getClassLoaderResolver()
        Accessor for the ClassLoader resolver to use in class loading issues.
        Returns:
        The ClassLoader resolver
      • getLockManager

        LockManager getLockManager()
        Accessor for the lock manager for this execution context.
        Returns:
        The lock manager
      • getStatistics

        ManagerStatistics getStatistics()
        Accessor for any statistics-gathering object.
        Returns:
        The statistics for this manager
      • setProperties

        void setProperties​(Map props)
        Method to set properties on the execution context.
        Parameters:
        props - The properties
      • setProperty

        void setProperty​(String name,
                         Object value)
        Method to set a property on the execution context
        Parameters:
        name - Name of the property
        value - Value to set
      • getProperty

        Object getProperty​(String name)
        Accessor for a property.
        Parameters:
        name - Name of the property
        Returns:
        The value
      • getBooleanProperty

        Boolean getBooleanProperty​(String name)
        Accessor for a boolean property value.
        Parameters:
        name - Name of the property
        Returns:
        the value
      • getIntProperty

        Integer getIntProperty​(String name)
        Accessor for an int property value.
        Parameters:
        name - Name of the property
        Returns:
        the value
      • getStringProperty

        String getStringProperty​(String name)
        Accessor for a String property value.
        Parameters:
        name - Name of the property
        Returns:
        The value
      • getProperties

        Map<String,​Object> getProperties()
        Accessor for the defined properties.
        Returns:
        Properties for this execution context
      • getSupportedProperties

        Set<String> getSupportedProperties()
        Accessor for the supported property names.
        Returns:
        Set of names
      • getTypeManager

        default TypeManager getTypeManager()
        TODO should we keep this here? this is api/language dependent
        Returns:
        The type manager
      • close

        void close()
        Method to close the execution context.
      • isClosed

        boolean isClosed()
        Accessor for whether this execution context is closed.
        Returns:
        Whether this manager is closed.
      • findStateManager

        DNStateManager findStateManager​(Object pc)
        Method to find StateManager for the passed persistable object when it is managed by this manager.
        Parameters:
        pc - The persistable object
        Returns:
        StateManager
      • findStateManager

        DNStateManager findStateManager​(Object pc,
                                        boolean persist)
        Method to find StateManager for the passed persistable object when it is managed by this manager, and if not yet persistent to persist it and return the assigned StateManager.
        Parameters:
        pc - The persistable object
        persist - Whether to persist if not yet persistent
        Returns:
        StateManager
      • findStateManagerForEmbedded

        DNStateManager findStateManagerForEmbedded​(Object value,
                                                   DNStateManager owner,
                                                   AbstractMemberMetaData mmd)
        Method to find StateManager for the passed embedded persistable object. Will create one if not already registered, and tie it to the specified owner.
        Parameters:
        value - The embedded object
        owner - The owner StateManager (if known).
        mmd - Metadata for the field of the owner
        Returns:
        StateManager for the embedded object
      • findStateManagerOfOwnerForAttachingObject

        DNStateManager findStateManagerOfOwnerForAttachingObject​(Object pc)
      • addStateManagerToCache

        void addStateManagerToCache​(DNStateManager sm)
        Method to add the object managed by the specified StateManager to the cache.
        Parameters:
        sm - StateManager
      • removeStateManagerFromCache

        void removeStateManagerFromCache​(DNStateManager sm)
        Method to remove the object managed by the specified StateManager from the cache.
        Parameters:
        sm - StateManager
      • evictObject

        void evictObject​(Object pc)
        Method to evict the passed object.
        Parameters:
        pc - The object
      • evictObjects

        void evictObjects​(Class cls,
                          boolean subclasses)
        Method to evict all objects of the specified type (and optionaly its subclasses).
        Parameters:
        cls - Type of persistable object
        subclasses - Whether to include subclasses
      • evictAllObjects

        void evictAllObjects()
        Method to evict all L1 cache objects
      • retrieveObjects

        void retrieveObjects​(boolean useFetchPlan,
                             Object... pcs)
        Method to retrieve the (fields of the) passed object(s).
        Parameters:
        useFetchPlan - Whether to retrieve the current fetch plan
        pcs - The objects
      • persistObject

        <T> T persistObject​(T pc,
                            boolean merging)
        Method to persist the passed object.
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        pc - The object
        merging - Whether this object (and dependents) is being merged
        Returns:
        The persisted object
      • persistObjects

        Object[] persistObjects​(Object... pcs)
        Method to persist the passed object(s).
        Parameters:
        pcs - The objects to persist
        Returns:
        The persisted objects
      • persistObjectInternal

        <T> T persistObjectInternal​(T pc,
                                    FieldValues preInsertChanges,
                                    DNStateManager ownerSM,
                                    int ownerFieldNum,
                                    int objectType)
        Method to persist the passed object (internally).
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        pc - The object
        preInsertChanges - Changes to be made before inserting
        ownerSM - StateManager of the owner when embedded
        ownerFieldNum - Field number in the owner where this is embedded (or -1 if not embedded)
        objectType - Type of object (see org.datanucleus.store.DNStateManager, e.g DNStateManager.PC)
        Returns:
        The persisted object
      • persistObjectInternal

        <T> T persistObjectInternal​(T pc,
                                    DNStateManager ownerSM,
                                    int ownerFieldNum,
                                    int objectType)
        Method to persist the passed object (internally).
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        pc - The object
        ownerSM - StateManager of the owner when embedded
        ownerFieldNum - Field number in the owner where this is embedded (or -1 if not embedded)
        objectType - Type of object (see org.datanucleus.state.DNStateManager, e.g DNStateManager.PC)
        Returns:
        The persisted object
      • persistObjectInternal

        default <T> T persistObjectInternal​(T pc,
                                            FieldValues preInsertChanges,
                                            int objectType)
        Method to persist the passed object (internally).
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        pc - The object
        preInsertChanges - Changes to be made before inserting
        objectType - Type of object (see org.datanucleus.state.DNStateManager, e.g DNStateManager.PC)
        Returns:
        The persisted object
      • makeObjectTransient

        void makeObjectTransient​(Object pc,
                                 FetchPlanState state)
        Method to make transient the passed object.
        Parameters:
        pc - The object
        state - Object containing the state of the fetchplan processing
      • makeObjectTransactional

        void makeObjectTransactional​(Object pc)
        Method to make the passed object transactional.
        Parameters:
        pc - The object
      • makeObjectNontransactional

        void makeObjectNontransactional​(Object pc)
        Method to make the passed object nontransactional.
        Parameters:
        pc - The object
      • exists

        boolean exists​(Object obj)
        Method to return if the specified object exists in the datastore.
        Parameters:
        obj - The (persistable) object
        Returns:
        Whether it exists
      • getManagedObjects

        Set getManagedObjects()
        Accessor for the currently managed objects for the current transaction. If the transaction is not active this returns null.
        Returns:
        Collection of managed objects enlisted in the current transaction
      • getManagedObjects

        Set getManagedObjects​(Class[] classes)
        Accessor for the currently managed objects for the current transaction. If the transaction is not active this returns null.
        Parameters:
        classes - Classes that we want the objects for
        Returns:
        Collection of managed objects enlisted in the current transaction
      • getManagedObjects

        Set getManagedObjects​(String[] states)
        Accessor for the currently managed objects for the current transaction. If the transaction is not active this returns null.
        Parameters:
        states - States that we want the objects for
        Returns:
        Collection of managed objects enlisted in the current transaction
      • getManagedObjects

        Set getManagedObjects​(String[] states,
                              Class[] classes)
        Accessor for the currently managed objects for the current transaction. If the transaction is not active this returns null.
        Parameters:
        states - States that we want the objects for
        classes - Classes that we want the objects for
        Returns:
        Collection of managed objects enlisted in the current transaction
      • deleteObject

        void deleteObject​(Object obj)
        Method to delete an object from the datastore.
        Parameters:
        obj - The object
      • deleteObjects

        void deleteObjects​(Object... objs)
        Method to delete an array of objects from the datastore.
        Parameters:
        objs - The objects to delete
      • deleteObjectInternal

        void deleteObjectInternal​(Object pc)
        Method to delete the passed object (internally).
        Parameters:
        pc - The object
      • detachObject

        void detachObject​(FetchPlanState state,
                          Object pc)
        Method to detach the passed object.
        Parameters:
        state - State for the detachment process.
        pc - The object to detach
      • detachObjects

        void detachObjects​(FetchPlanState state,
                           Object... pcs)
        Method to detach the passed object(s).
        Parameters:
        state - State for the detachment process.
        pcs - The object(s) to detach
      • detachObjectCopy

        <T> T detachObjectCopy​(FetchPlanState state,
                               T pc)
        Method to detach a copy of the passed object using the provided state.
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        state - State for the detachment process
        pc - The object
        Returns:
        The detached copy of the object
      • detachAll

        void detachAll()
        Method to detach all managed objects.
      • attachObject

        void attachObject​(DNStateManager sm,
                          Object pc,
                          boolean sco)
        Method to attach the passed object (and related objects). Throws an exception if another (persistent) object with the same id exists in the L1 cache already.
        Parameters:
        sm - StateManager of the owning object that has this in a field causing its attach
        pc - The (detached) object
        sco - Whether the object has no identity (embedded or serialised)
      • attachObjectCopy

        <T> T attachObjectCopy​(DNStateManager sm,
                               T pc,
                               boolean sco)
        Method to attach a copy of the passed object (and related objects).
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        sm - StateManager of the owning object that has this in a field causing its attach
        pc - The object
        sco - Whether it has no identity (second-class object)
        Returns:
        The attached copy of the input object
      • getAttachedObjectForId

        Object getAttachedObjectForId​(Object id)
        Convenience method to return the attached object for the specified id if one exists.
        Parameters:
        id - The id
        Returns:
        The attached object
      • refreshObject

        void refreshObject​(Object pc)
        Method to refresh the passed object.
        Parameters:
        pc - The object
      • refreshAllObjects

        void refreshAllObjects()
        Method to refresh all L1 cache objects
      • enlistInTransaction

        void enlistInTransaction​(DNStateManager sm)
        Method to enlist the specified StateManager in the current transaction.
        Parameters:
        sm - StateManager
      • isEnlistedInTransaction

        boolean isEnlistedInTransaction​(Object id)
        Method to return if an object is enlisted in the current transaction.
        Parameters:
        id - Identity for the object
        Returns:
        Whether it is enlisted in the current transaction
      • evictFromTransaction

        void evictFromTransaction​(DNStateManager sm)
        Method to evict the specified StateManager from the current transaction.
        Parameters:
        sm - StateManager
      • markDirty

        void markDirty​(DNStateManager sm,
                       boolean directUpdate)
        Mark the specified StateManager as dirty
        Parameters:
        sm - StateManager
        directUpdate - Whether the object has had a direct update made on it (if known)
      • clearDirty

        void clearDirty​(DNStateManager sm)
        Mark the specified StateManager as clean.
        Parameters:
        sm - StateManager
      • clearDirty

        void clearDirty()
        Method to mark as clean all StateManagers of dirty objects.
      • processNontransactionalUpdate

        void processNontransactionalUpdate()
        Method to process any outstanding non-transactional updates that are queued. If "datanucleus.nontx.atomic" is false, or currently in a transaction then returns immediately. Otherwise will flush any updates that are outstanding (updates to an object), will perform detachAllOnCommit if enabled (so user always has detached objects), update objects in any L2 cache, and migrates any objects through lifecycle changes. Is similar in content to "flush"+"preCommit"+"postCommit"
      • findObject

        <T> T findObject​(Class<T> cls,
                         Object key)
        Accessor for an object of the specified type with the provided id "key". With datastore id or single-field id the "key" is the key of the id, and with composite ids the "key" is the toString() of the id.
        Type Parameters:
        T - Type of the persistable
        Parameters:
        cls - Class of the persistable
        key - Value of the key field for SingleFieldIdentity, or the string value of the key otherwise
        Returns:
        The object meeting this requirement
      • findObjects

        <T> List<T> findObjects​(Class<T> cls,
                                List keys)
        Accessor for objects of the specified type, with the provided id "key"s. With datastore id or single-field id the "key" is the key of the id, and with composite ids the "key" is the toString() of the id.
        Type Parameters:
        T - Type of the persistable
        Parameters:
        cls - Class of the persistable
        keys - Values of the key field for SingleFieldIdentity, or the string value of the keys otherwise
        Returns:
        The objects meeting this requirement
      • findObjectByUnique

        <T> T findObjectByUnique​(Class<T> cls,
                                 String[] fieldNames,
                                 Object[] fieldValues)
        Accessor for an object of the specified type with the provided values for a unique key. Alternative would be to have an intermediate class and do this
         ec.findObjectByUnique(cls).for("field1", val1).for("field2", val2).find();
         
        Type Parameters:
        T - Type of the persistable
        Parameters:
        cls - Class of the persistable
        fieldNames - Name(s) of the field(s) forming the unique key
        fieldValues - Value(s) of the field(s) forming the unique key
        Returns:
        The object meeting this requirement
      • findObject

        Persistable findObject​(Object id,
                               boolean validate)
        Shortcut to calling "findObject(id, validate, validate, null)". Note: This is used by the bytecode enhancement contract in
        dnCopyKeyFieldsFromObjectId
        Specified by:
        findObject in interface ExecutionContextReference
        Parameters:
        id - The id of the object
        validate - Whether to validate the id
        Returns:
        The object
      • findObjectsById

        Persistable[] findObjectsById​(Object[] ids,
                                      boolean validate)
        Accessor for persistable objects with the specified identities.
        Parameters:
        ids - Ids of the object(s).
        validate - Whether to validate the object state
        Returns:
        The persistable objects with these ids (same order)
        Throws:
        NucleusObjectNotFoundException - if an object doesn't exist in the datastore
      • findObject

        Persistable findObject​(Object id,
                               boolean validate,
                               boolean checkInheritance,
                               String objectClassName)
        Accessor for an object given the object id.
        Parameters:
        id - Id of the object.
        validate - Whether to validate the object state
        checkInheritance - Whether look to the database to determine which class this object is. This parameter is a hint. Set false, if it's already determined the correct pcClass for this pc "object" in a certain level in the hierarchy. Set to true and it will look to the database.
        objectClassName - Class name for the object with this id (if known, optional)
        Returns:
        The Object
      • findObject

        Persistable findObject​(Object id,
                               FieldValues fv,
                               Class pcClass,
                               boolean ignoreCache,
                               boolean checkInheritance)
        Accessor for an object given the object id. Typically used after a query to apply the retrieved values to an object.
        Parameters:
        id - Id of the object.
        fv - FieldValues to apply to the object (optional)
        pcClass - the type which the object is. This type will be used to instantiate the object
        ignoreCache - true if the cache is ignored
        checkInheritance - Whether to check the inheritance of this object
        Returns:
        the Object
      • getExtent

        <T> Extent<T> getExtent​(Class<T> candidateClass,
                                boolean includeSubclasses)
        Accessor for the Extent for a class (and optionally its subclasses).
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        candidateClass - The class
        includeSubclasses - Whether to include subclasses
        Returns:
        The Extent
      • putObjectIntoLevel1Cache

        void putObjectIntoLevel1Cache​(DNStateManager sm)
        Method to put a Persistable object associated to StateManager into the L1 cache.
        Parameters:
        sm - StateManager
      • getObjectFromCache

        Persistable getObjectFromCache​(Object id)
        Convenience method to access an object in the cache. Firstly looks in the L1 cache for this ExecutionContext, and if not found looks in the L2 cache.
        Parameters:
        id - Id of the object
        Returns:
        Persistable object (with connected StateManager).
      • getObjectsFromCache

        Persistable[] getObjectsFromCache​(Object[] ids)
        Convenience method to access objects in the cache. Firstly looks in the L1 cache, and if not found looks in the L2 cache.
        Parameters:
        ids - Ids of the objects
        Returns:
        Persistable objects (with connected StateManager).
      • removeObjectFromLevel1Cache

        void removeObjectFromLevel1Cache​(Object id)
        Method to remove an object from the L1 cache.
        Parameters:
        id - The id of the object
      • removeObjectFromLevel2Cache

        void removeObjectFromLevel2Cache​(Object id)
        Method to remove an object from the L2 cache.
        Parameters:
        id - The id of the object
      • markFieldsForUpdateInLevel2Cache

        void markFieldsForUpdateInLevel2Cache​(Object id,
                                              boolean[] fields)
        Method to mark the object with specifed id to have the supplied fields updated in the L2 cache at commit.
        Parameters:
        id - Id of the object
        fields - The fields to update
      • hasIdentityInCache

        boolean hasIdentityInCache​(Object id)
        Whether an object with the specified identity exists in the cache(s). Used as a check on identity (inheritance-level) validity
        Parameters:
        id - The identity
        Returns:
        Whether it exists
      • newObjectId

        Object newObjectId​(Class pcClass,
                           Object key)
        This method returns an object id instance corresponding to the pcClass and key arguments. Operates in 2 modes :-
        • The class uses SingleFieldIdentity and the key is the value of the key field
        • In all other cases the key is the String form of the object id instance
        Parameters:
        pcClass - Class of the persistable object to create the identity for
        key - Value of the key for SingleFieldIdentity (or the toString value)
        Returns:
        The new object-id instance
      • newObjectId

        Object newObjectId​(String className,
                           Object pc)
        This method returns an object id instance corresponding to the class name, and the passed object (when using app identity).
        Parameters:
        className - Name of the class of the object.
        pc - The persistable object. Used for application-identity
        Returns:
        A new object ID.
      • getSerializeReadForClass

        boolean getSerializeReadForClass​(String className)
        Convenience method to return the setting for serialize read for the current transaction for the specified class name. Returns the setting for the transaction (if set), otherwise falls back to the setting for the class, otherwise returns false.
        Parameters:
        className - Name of the class
        Returns:
        Setting for serialize read
      • assertClassPersistable

        void assertClassPersistable​(Class cls)
        Convenience method to assert if the passed class is not persistable.
        Parameters:
        cls - The class of which we want to persist objects
        Throws:
        ClassNotPersistableException - When the class is not persistable
        NoPersistenceInformationException - When the class has no available persistence information
      • hasPersistenceInformationForClass

        boolean hasPersistenceInformationForClass​(Class cls)
        Utility method to check if the specified class has reachable metadata or annotations.
        Parameters:
        cls - The class to check
        Returns:
        Whether the class has reachable metadata or annotations
      • isInserting

        boolean isInserting​(Object pc)
        Tests whether this persistable object is being inserted.
        Parameters:
        pc - the object to verify the status
        Returns:
        true if this instance is inserting.
      • isFlushing

        boolean isFlushing()
        Accessor for whether the ExecutionContext is flushing changes to the datastore.
        Returns:
        Whether it is currently flushing
      • getFlushMode

        FlushMode getFlushMode()
        Accessor for the flush mode. Whether to auto-commit, or whether to delay flushing.
        Returns:
        The flush mode.
      • isDelayDatastoreOperationsEnabled

        boolean isDelayDatastoreOperationsEnabled()
        Whether the datastore operations are delayed until commit. In optimistic transactions this is automatically enabled.
        Returns:
        true if datastore operations are delayed until commit
      • isRunningDetachAllOnCommit

        boolean isRunningDetachAllOnCommit()
        Accessor for whether this ExecutionContext is currently running detachAllOnCommit.
        Returns:
        Whether running detachAllOnCommit
      • flush

        void flush()
        Method callable from external APIs for user-management of flushing. Called by JDO PM.flush, or JPA EM.flush(). Performs management of relations, prior to performing internal flush of all dirty/new/deleted instances to the datastore.
      • flushInternal

        void flushInternal​(boolean flushToDatastore)
        Method to flushes all dirty, new, and deleted instances to the datastore. It has no effect if a transaction is not active. If a datastore transaction is active, this method synchronizes the cache with the datastore and reports any exceptions. If an optimistic transaction is active, this method obtains a datastore connection and synchronizes the cache with the datastore using this connection. The connection obtained by this method is held until the end of the transaction.
        Parameters:
        flushToDatastore - Whether to ensure any changes reach the datastore Otherwise they will be flushed to the datastore manager and leave it to decide the opportune moment to actually flush them to teh datastore
        Throws:
        NucleusOptimisticException - when optimistic locking error(s) occur
      • getOperationQueue

        OperationQueue getOperationQueue()
        Accessor for the operation queue. The queue can be null if there are no operations queued (txn not active, not optimistic, no ops arrived yet).
        Returns:
        The operation queue (typically for collections/maps)
      • operationQueueIsActive

        boolean operationQueueIsActive()
        Accessor for whether the operation queue is currently active. Will return false if not delaying flush, or not in a transaction, or flushing.
        Returns:
        Whether the operation queue is active for adding operations
      • addOperationToQueue

        void addOperationToQueue​(Operation oper)
        Method to add an operation to the queue.
        Parameters:
        oper - The operation to add
      • flushOperationsForBackingStore

        void flushOperationsForBackingStore​(Store backingStore,
                                            DNStateManager sm)
        Method to flush all queued operations for the specified backing store (if any).
        Parameters:
        backingStore - The backing store
        sm - StateManager
      • getObjectsToBeFlushed

        List<DNStateManager> getObjectsToBeFlushed()
        Convenience method to inspect the list of objects with outstanding changes to flush.
        Returns:
        StateManagers for the objects to be flushed.
      • getMultithreaded

        boolean getMultithreaded()
        Accessor for whether this context is multithreaded.
        Returns:
        Whether multithreaded (and hence needing locking)
      • getManageRelations

        boolean getManageRelations()
        Whether managed relations are supported by this execution context.
        Returns:
        Supporting managed relations
      • getRelationshipManager

        RelationshipManager getRelationshipManager​(DNStateManager sm)
        Accessor for the RelationshipManager for the provided StateManager.
        Parameters:
        sm - StateManager
        Returns:
        The RelationshipManager
      • isManagingRelations

        boolean isManagingRelations()
        Returns whether this ExecutionContext is currently performing the manage relationships task.
        Returns:
        Whether in the process of managing relations
      • getCallbackHandler

        CallbackHandler getCallbackHandler()
        Retrieve the callback handler for this ExecutionContext.
        Returns:
        the callback handler
      • getInternalFetchGroup

        FetchGroup getInternalFetchGroup​(Class cls,
                                         String name)
        Accessor for an internal fetch group for the specified class.
        Parameters:
        cls - The class
        name - Name of the group
        Returns:
        The FetchGroup
      • addInternalFetchGroup

        void addInternalFetchGroup​(FetchGroup grp)
        Method to add an internal fetch group to this ExecutionContext.
        Parameters:
        grp - The internal fetch group
      • getFetchGroupsWithName

        Set<FetchGroup> getFetchGroupsWithName​(String name)
        Accessor for the fetch groups for the specified name.
        Parameters:
        name - Name of the group
        Returns:
        The FetchGroup
      • getTenantId

        String getTenantId()
        Accessor for the tenant id, for this ExecutionContext.
        Returns:
        The tenant id for this context.
      • getCurrentUser

        String getCurrentUser()
        Accessor for the current user, for this ExecutionContext.
        Returns:
        The current user for this context
      • getLock

        default Lock getLock()
        Accessor for the lock object for this ExecutionContext.
        Returns:
        The lock object
      • newInstance

        <T> T newInstance​(Class<T> cls)
        Method to generate an instance of an interface, abstract class, or concrete PC class.
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        cls - The class of the interface or abstract class, or concrete class defined in MetaData
        Returns:
        The instance of this type
      • isObjectModifiedInTransaction

        boolean isObjectModifiedInTransaction​(Object id)
        Accessor for whether the object with this identity is modified in the current transaction.
        Parameters:
        id - The identity.
        Returns:
        Whether it is modified/new/deleted in this transaction
      • replaceObjectId

        void replaceObjectId​(Persistable pc,
                             Object oldID,
                             Object newID)
        Replace the previous object id for a PC object to a new
        Parameters:
        pc - The Persistable object
        oldID - the old id
        newID - the new id
      • getAttachDetachReferencedObject

        Object getAttachDetachReferencedObject​(DNStateManager sm)
        Access a referenced object for this StateManager during the attach/detach process. When attaching and this is the detached object this returns the newly attached object. When attaching and this is the newly attached object this returns the detached object. When detaching and this is the newly detached object this returns the attached object. When detaching and this is the attached object this returns the newly detached object.
        Parameters:
        sm - StateManager
        Returns:
        The referenced object (if any)
      • setAttachDetachReferencedObject

        void setAttachDetachReferencedObject​(DNStateManager sm,
                                             Object obj)
        Register a referenced object against this StateManager for the attach/detach process.
        Parameters:
        sm - StateManager
        obj - The referenced object (or null to clear out any reference)
      • registerEmbeddedRelation

        ExecutionContext.EmbeddedOwnerRelation registerEmbeddedRelation​(DNStateManager ownerSM,
                                                                        int ownerFieldNum,
                                                                        DNStateManager embSM)
        Method to register an embedded relation for the specified memberf of the owner StateManager where the embedded StateManager is stored.
        Parameters:
        ownerSM - Owner StateManager
        ownerFieldNum - Member number that is embedded
        embSM - StateManager of the embedded object
        Returns:
        The EmbeddedOwnerRelation
      • deregisterEmbeddedRelation

        void deregisterEmbeddedRelation​(ExecutionContext.EmbeddedOwnerRelation rel)
        Method to deregister the specified embedded relation (e.g when the embedded object is disconnected).
        Parameters:
        rel - The embedded relation
      • getEmbeddedInformationForOwner

        List<ExecutionContext.EmbeddedOwnerRelation> getEmbeddedInformationForOwner​(DNStateManager ownerOP)
        Accessor for the relations for the specified embedded StateManager where it is embedded.
        Parameters:
        ownerOP - StateManager that owns the embedded
        Returns:
        The List of embedded relations involving this StateManager as owner
      • getOwnerInformationForEmbedded

        List<ExecutionContext.EmbeddedOwnerRelation> getOwnerInformationForEmbedded​(DNStateManager embOP)
        Accessor for the relations for the specified embedded StateManager where it is embedded.
        Parameters:
        embOP - StateManager that is embedded
        Returns:
        The List of embedded relations involving this StateManager as embedded
      • getOwnersForEmbeddedStateManager

        DNStateManager[] getOwnersForEmbeddedStateManager​(DNStateManager embOP)
        Accessor for the owner objects for the provided embedded StateManager.
        Parameters:
        embOP - StateManager that is embedded
        Returns:
        The owner object(s) that have this object embedded.
      • removeEmbeddedOwnerRelation

        void removeEmbeddedOwnerRelation​(DNStateManager ownerSM,
                                         int ownerFieldNum,
                                         DNStateManager embOP)
        Convenience method to remove the EmbeddedOwnerRelation between the specified StateManagers.
        Parameters:
        ownerSM - Owner StateManager
        ownerFieldNum - Field in owner
        embOP - Embedded StateManager
      • removeStateManagerAssociatedValue

        void removeStateManagerAssociatedValue​(DNStateManager sm,
                                               Object key)
      • containsStateManagerAssociatedValue

        boolean containsStateManagerAssociatedValue​(DNStateManager sm,
                                                    Object key)
      • registerExecutionContextListener

        void registerExecutionContextListener​(ExecutionContextListener listener)
        Register a listener to be called when this ExecutionContext is closing.
        Parameters:
        listener - The listener
      • deregisterExecutionContextListener

        void deregisterExecutionContextListener​(ExecutionContextListener listener)
        Deregister a listener from calling when this ExecutionContext is closing.
        Parameters:
        listener - The listener
      • closeCallbackHandler

        void closeCallbackHandler()
        Close the callback handler, and disconnect any registered instance listeners. Used by JCA.