Interface PersistenceNucleusContext

  • All Superinterfaces:
    NucleusContext
    All Known Implementing Classes:
    PersistenceNucleusContextImpl

    public interface PersistenceNucleusContext
    extends NucleusContext
    Context for use in the persistence process. Adds on many extra services to the basic+store contexts, for transactions, executionContext, identity handling, StateManagers, autostart, L2 cache etc.
    • Method Detail

      • getExecutionContext

        ExecutionContext getExecutionContext​(Object owner,
                                             Map<String,​Object> options)
        Method to return an ExecutionContext for use in persistence.
        Parameters:
        owner - The owner object for the context. PersistenceManager/EntityManager typically.
        options - Any options affecting startup
        Returns:
        The ExecutionContext
      • getIdentityManager

        IdentityManager getIdentityManager()
        Accessor for a manager for identities.
        Returns:
        The identity manager to use
      • statisticsEnabled

        boolean statisticsEnabled()
        Accessor for whether statistics gathering is enabled.
        Returns:
        Whether the user has enabled statistics or JMX management is enabled
      • getJMXManager

        ManagementManager getJMXManager()
        Accessor for the JMX manager (if required). Does nothing if the property "datanucleus.jmxType" is unset.
        Returns:
        The JMX manager
      • getJtaTransactionManager

        javax.transaction.TransactionManager getJtaTransactionManager()
        Accessor for the JTA transaction manager, when using JTA.
        Returns:
        the JTA Transaction Manager
      • getJtaSyncRegistry

        JTASyncRegistry getJtaSyncRegistry()
        Accessor for the JTA Synchronization registry, when using JTA.
        Returns:
        The JTASyncRegistry (or null if not using JTA)
      • getBeanValidationHandler

        BeanValidationHandler getBeanValidationHandler​(ExecutionContext ec)
        Method to return a handler for bean validation (JSR303).
        Parameters:
        ec - The ExecutionContext that the handler is for.
        Returns:
        The bean validation handler (or null if not supported on this PMF/EMF, or no validator present)
      • getCDIHandler

        CDIHandler getCDIHandler()
        Accessor for the handler for CDI (JSR346) if in an environment that provides one.
        Returns:
        The CDI Handler
      • hasLevel2Cache

        boolean hasLevel2Cache()
      • addExecutionContextListener

        void addExecutionContextListener​(ExecutionContext.LifecycleListener listener)
        Register a new Listener for ExecutionContext events.
        Parameters:
        listener - the listener to register
      • removeExecutionContextListener

        void removeExecutionContextListener​(ExecutionContext.LifecycleListener listener)
        Unregister a Listener from ExecutionContext events.
        Parameters:
        listener - the listener to unregister
      • setJcaMode

        void setJcaMode​(boolean jca)
        Mutator for whether we are in JCA mode.
        Parameters:
        jca - true if using JCA connector
      • isJcaMode

        boolean isJcaMode()
        Accessor for the JCA mode.
        Returns:
        true if using JCA connector.
      • getFetchGroupManager

        FetchGroupManager getFetchGroupManager()
        Convenience accessor for the FetchGroupManager. Creates it if not yet existing.
        Returns:
        The FetchGroupManager
      • addInternalFetchGroup

        void addInternalFetchGroup​(FetchGroup grp)
        Method to add a dynamic FetchGroup for use by this OMF.
        Parameters:
        grp - The group
      • removeInternalFetchGroup

        void removeInternalFetchGroup​(FetchGroup grp)
        Method to remove a dynamic FetchGroup from use by this OMF.
        Parameters:
        grp - The group
      • createInternalFetchGroup

        FetchGroup createInternalFetchGroup​(Class cls,
                                            String name)
        Method to create a new internal fetch group for the class+name.
        Parameters:
        cls - Class that it applies to
        name - Name of group
        Returns:
        The group
      • getInternalFetchGroup

        FetchGroup getInternalFetchGroup​(Class cls,
                                         String name,
                                         boolean createIfNotPresent)
        Accessor for an internal fetch group for the specified class.
        Parameters:
        cls - The class
        name - Name of the group
        createIfNotPresent - Whether to create the fetch group if not present
        Returns:
        The FetchGroup
        Throws:
        NucleusUserException - if the class is not persistable
      • getFetchGroupsWithName

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

        boolean isClassWithIdentityCacheable​(Object id)
        Convenience method to return if the supplied id is of an object that is cacheable in the L2 cache.
        Parameters:
        id - The identity
        Returns:
        Whether the object it refers to is considered cacheable
      • isClassCacheable

        boolean isClassCacheable​(AbstractClassMetaData cmd)
        Convenience method to return if objects of this type are cached for this NucleusContext. Uses the "cacheable" flag of the class, and the cache-mode to determine whether to cache
        Parameters:
        cmd - MetaData for the class
        Returns:
        Whether it is cacheable
      • isFederated

        boolean isFederated()
        Return whether we are managing a federated context (i.e a primary StoreManager, with some secondary StoreManager(s)).
        Returns:
        Whether this is federated
      • getTenantId

        String getTenantId​(ExecutionContext ec)
        Accessor for the tenant id for the ExecutionContext. Returns the MultiTenancyProvider id (if specified) or relays to the ExecutionContext "tenantId" property (or global tenantId if that is not defined).
        Parameters:
        ec - ExecutionContext
        Returns:
        The tenant id for this context.
      • getTenantReadIds

        String[] getTenantReadIds​(ExecutionContext ec)
        Accessor for the ids of the tenants that should be included in any read operations. Defaults to just the current tenant id unless specified.
        Parameters:
        ec - ExecutionContext
        Returns:
        The tenant id(s) for use when reading
      • getCurrentUser

        String getCurrentUser​(ExecutionContext ec)
        Accessor for the current user for the supplied ExecutionContext.
        Parameters:
        ec - ExecutionContext
        Returns:
        The current user for this context.