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 objects in 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<String,​Object> 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()
        Convenience accessor for the type manager for this persistence context (from NucleusContext).
        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,
                                                   PersistableObjectType objectType)
        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
        objectType - Type of persistable object being stored
        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 make an object persistent. Should be called by EXTERNAL APIs (JDO/JPA) only. All INTERNAL (DataNucleus) calls should go via persistObjectInternal(...).
        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
        Throws:
        NucleusUserException - if the object is managed by a different manager
      • persistObjects

        Object[] persistObjects​(Object... pcs)
        Method to persist an array of objects to the datastore. Should be called by EXTERNAL APIs (JDO/JPA) only.
        Parameters:
        pcs - The objects to persist
        Returns:
        The persisted objects
        Throws:
        NucleusUserException - Thrown if an error occurs during the persist process. Any exception could have several nested exceptions for each failed object persist
      • persistObjectInternal

        default <T> T persistObjectInternal​(T pc,
                                            FieldValues preInsertChanges,
                                            PersistableObjectType objectType)
        Method to make an object persistent which should be called from INTERNAL (DataNucleus) calls only. All EXTERNAL (PM/EM) calls should go via persistObject(Object pc). To be used when not providing the owner object details that this is part of (embedded).
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        pc - The object
        preInsertChanges - Changes to be made before inserting
        objectType - Type of object
        Returns:
        The persisted object
        Throws:
        NucleusUserException - if the object is managed by a different context
      • persistObjectInternal

        <T> T persistObjectInternal​(T pc,
                                    FieldValues preInsertChanges,
                                    PersistableObjectType objectType,
                                    DNStateManager ownerSM,
                                    int ownerFieldNum)
        Method to make an object persistent which should be called from INTERNAL (DataNucleus) calls only. All EXTERNAL (PM/EM) calls should go via persistObject(Object pc). To be used when providing the owner object details that this is part of (embedded).
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        pc - The object
        preInsertChanges - Any changes to make before inserting
        objectType - Type of object
        ownerSM - StateManager of the owner when embedded (or attached?) (null if not embedded)
        ownerFieldNum - Field number in the owner where this is embedded (or attached?) (-1 if not embedded)
        Returns:
        The persisted object
        Throws:
        NucleusUserException - if the object is managed by a different context
      • makeObjectTransient

        void makeObjectTransient​(Object pc,
                                 FetchPlanState state)
        Method to migrate an object to transient state.
        Parameters:
        pc - The object
        state - Object containing the state of the fetch plan process (if any)
        Throws:
        NucleusException - When an error occurs in making the object transient
      • makeObjectTransactional

        void makeObjectTransactional​(Object pc)
        Method to make an object transactional.
        Parameters:
        pc - The object
        Throws:
        NucleusException - Thrown when an error occurs
      • makeObjectNontransactional

        void makeObjectNontransactional​(Object pc)
        Method to make the passed object nontransactional.
        Parameters:
        pc - The object
        Throws:
        NucleusException - Thrown when an error occurs
      • 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. NOT to be called by internal methods. Only callable by external APIs (JDO/JPA).
        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
        Throws:
        NucleusUserException - Thrown if an error occurs during the deletion process. Any exception could have several nested exceptions for each failed object deletion
      • deleteObjectInternal

        void deleteObjectInternal​(Object pc)
        Method to delete an object from persistence which should be called from internal calls only. All PM/EM calls should go via deleteObject(Object obj).
        Parameters:
        pc - Object to delete
      • detachObject

        void detachObject​(FetchPlanState state,
                          Object pc)
        Method to detach a persistent object without making a copy. Note that also all the objects which are refered to from this object are detached. If the object is of class that is not detachable a ClassNotDetachableException will be thrown. If the object is not persistent a NucleusUserException is thrown.
        Parameters:
        state - State for the detachment process
        pc - The object
      • 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)
        Detach a copy of the passed persistent object using the provided detach state. If the object is of class that is not detachable it will be detached as transient. If it is not yet persistent it will be first persisted.
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        state - State for the detachment process
        pc - The object
        Returns:
        The detached object
      • detachAll

        void detachAll()
        Method to detach all objects in the context. Detaches all objects enlisted as well as all objects in the L1 cache. Of particular use with JPA when doing a clear of the persistence context.
      • attachObject

        void attachObject​(DNStateManager ownerSM,
                          Object pc,
                          boolean sco)
        Method to attach a persistent detached object. If a different object with the same identity as this object exists in the L1 cache then an exception will be thrown.
        Parameters:
        ownerSM - StateManager of the owner object that has this in a field that causes this attach
        pc - The persistable object
        sco - Whether the PC object is stored without an identity (embedded/serialised)
      • attachObjectCopy

        <T> T attachObjectCopy​(DNStateManager ownerSM,
                               T pc,
                               boolean sco)
        Method to attach a persistent detached object returning an attached copy of the object. If the object is of class that is not detachable, a ClassNotDetachableException will be thrown.
        Type Parameters:
        T - Type of the persistable object
        Parameters:
        ownerSM - StateManager of the owner object that has this in a field that causes this attach
        pc - The object
        sco - Whether it has no identity (second-class object)
        Returns:
        The attached object
      • getAttachedObjectForId

        Object getAttachedObjectForId​(Object id)
        Convenience method to return the attached object for the specified id if one exists. Returns null if there is no currently enlisted/cached object with the specified id.
        Parameters:
        id - The id
        Returns:
        The attached object
      • refreshObject

        void refreshObject​(Object pc)
        Method to do a refresh of an object, updating it from its datastore representation. Also updates the object in the L1/L2 caches.
        Parameters:
        pc - The object
      • refreshAllObjects

        void refreshAllObjects()
        Method to do a refresh of all objects.
        Throws:
        NucleusUserException - thrown if instances could not be refreshed.
      • enlistInTransaction

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

        void evictFromTransaction​(DNStateManager sm)
        Method to evict the specified StateManager from 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
      • 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 for this id.
      • 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 objects with the specified identities.
        Parameters:
        ids - Identities of the object(s).
        validate - Whether to validate the object state
        Returns:
        The 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 and a set of field values to apply to it. This is intended for use where we have done a query and have the id from the results, and we want to create the object, preferably using the cache, and then apply any field values to it.
        Parameters:
        id - Id of the object.
        fv - Field values for the object (to copy in)
        pcClass - the type which the object is (optional). Used to instantiate the object
        ignoreCache - true if it must ignore the cache
        checkInheritance - Whether to check the inheritance on the id of the 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
      • putObjectIntoLevel2Cache

        void putObjectIntoLevel2Cache​(DNStateManager sm,
                                      boolean updateIfPresent)
        Method to add/update the managed object into the L2 cache as long as it isn't modified in the current transaction.
        Parameters:
        sm - StateManager for the object
        updateIfPresent - Whether to update it in the L2 cache if already present
      • 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/flush. In optimistic transactions this is automatically enabled. In datastore transactions there is a persistence property to enable it. If we are committing/flushing then will return false since the delay is no longer required.
        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
      • threadLock

        default void threadLock()
        Method to lock this ExecutionContext for threading
      • threadUnlock

        default void threadUnlock()
        Method to unlock this ExecutionContext for threading
      • 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 ownerMemberNum,
                                                                        PersistableObjectType objectType,
                                                                        DNStateManager embSM)
        Method to register an embedded relation for the specified member of the owner StateManager where the embedded StateManager is stored.
        Parameters:
        ownerSM - Owner StateManager
        ownerMemberNum - Member number that is embedded
        objectType - Type of object being persisted
        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 ownerSM)
        Accessor for the relations for the specified embedded StateManager where it is embedded.
        Parameters:
        ownerSM - StateManager that owns the embedded
        Returns:
        The List of embedded relations involving this StateManager as owner
      • getOwnerInformationForEmbedded

        ExecutionContext.EmbeddedOwnerRelation getOwnerInformationForEmbedded​(DNStateManager embSM)
        Accessor for the owner relation for the specified embedded StateManager where it is embedded.
        Parameters:
        embSM - StateManager that is embedded
        Returns:
        The embedded relation info involving this (embedded) StateManager
      • getOwnerForEmbeddedStateManager

        DNStateManager getOwnerForEmbeddedStateManager​(DNStateManager embSM)
        Accessor for the owner StateManager for the provided embedded StateManager.
        Parameters:
        embSM - StateManager that is embedded
        Returns:
        The owner StateManager that have this object embedded.
      • removeEmbeddedOwnerRelation

        void removeEmbeddedOwnerRelation​(DNStateManager ownerSM,
                                         int ownerFieldNum,
                                         DNStateManager embSM)
        Convenience method to remove the EmbeddedOwnerRelation between the specified StateManagers.
        Parameters:
        ownerSM - Owner StateManager
        ownerFieldNum - Field in owner
        embSM - 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.