Package org.datanucleus
Interface PersistenceNucleusContext
-
- All Superinterfaces:
NucleusContext,StoreNucleusContext
- All Known Implementing Classes:
PersistenceNucleusContextImpl
public interface PersistenceNucleusContext extends StoreNucleusContext
Context for use in the persistence process. Adds on many extra services to the basic+store contexts, for transactions, executionContext, identity handling, object providers, autostart, L2 cache etc.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddExecutionContextListener(ExecutionContext.LifecycleListener listener)Register a new Listener for ExecutionContext events.voidaddInternalFetchGroup(FetchGroup grp)Method to add a dynamic FetchGroup for use by this OMF.FetchGroupcreateInternalFetchGroup(Class cls, String name)Method to create a new internal fetch group for the class+name.AutoStartMechanismgetAutoStartMechanism()BeanValidationHandlergetBeanValidationHandler(ExecutionContext ec)Method to return a handler for bean validation (JSR303).CDIHandlergetCDIHandler()Accessor for the handler for CDI (JSR346) if in an environment that provides one.StringgetCurrentUser(ExecutionContext ec)Accessor for the current user for the supplied ExecutionContext.ExecutionContextgetExecutionContext(Object owner, Map<String,Object> options)Method to return an ExecutionContext for use in persistence.ExecutionContext.LifecycleListener[]getExecutionContextListeners()Object the array of registered ExecutionContext listeners.ExecutionContextPoolgetExecutionContextPool()FetchGroupManagergetFetchGroupManager()Convenience accessor for the FetchGroupManager.Set<FetchGroup>getFetchGroupsWithName(String name)Accessor for the fetch groups for the specified name.IdentityManagergetIdentityManager()Accessor for a manager for identities.ImplementationCreatorgetImplementationCreator()FetchGroupgetInternalFetchGroup(Class cls, String name, boolean createIfNotPresent)Accessor for an internal fetch group for the specified class.ManagementManagergetJMXManager()Accessor for the JMX manager (if required).JTASyncRegistrygetJtaSyncRegistry()Accessor for the JTA Synchronization registry, when using JTA.TransactionManagergetJtaTransactionManager()Accessor for the JTA transaction manager, when using JTA.Level2CachegetLevel2Cache()StringgetMultiTenancyId(ExecutionContext ec)Accessor for the tenant id for the ExecutionContext.String[]getMultiTenancyReadIds(ExecutionContext ec)Accessor for the ids of the tenants that should be included in any read operations.ObjectProviderFactorygetObjectProviderFactory()ResourcedTransactionManagergetResourcedTransactionManager()FactoryStatisticsgetStatistics()booleanhasLevel2Cache()booleanisClassCacheable(AbstractClassMetaData cmd)Convenience method to return if objects of this type are cached for this NucleusContext.booleanisClassMultiTenant(AbstractClassMetaData cmd)Accessor for whether the supplied class is multi-tenant (i.e with a tenancy id column).booleanisClassWithIdentityCacheable(Object id)Convenience method to return if the supplied id is of an object that is cacheable in the L2 cache.booleanisFederated()Return whether we are managing a federated context (i.e a primary StoreManager, with some secondary StoreManager(s)).booleanisJcaMode()Accessor for the JCA mode.voidremoveExecutionContextListener(ExecutionContext.LifecycleListener listener)Unregister a Listener from ExecutionContext events.voidremoveInternalFetchGroup(FetchGroup grp)Method to remove a dynamic FetchGroup from use by this OMF.voidsetJcaMode(boolean jca)Mutator for whether we are in JCA mode.booleanstatisticsEnabled()Accessor for whether statistics gathering is enabled.-
Methods inherited from interface org.datanucleus.NucleusContext
applyDefaultProperties, close, getApiAdapter, getApiName, getClassLoaderResolver, getConfiguration, getMetaDataManager, getPluginManager, getTypeManager, initialise, supportsORMMetaData
-
Methods inherited from interface org.datanucleus.StoreNucleusContext
getStoreManager
-
-
-
-
Method Detail
-
getAutoStartMechanism
AutoStartMechanism getAutoStartMechanism()
-
getObjectProviderFactory
ObjectProviderFactory getObjectProviderFactory()
-
getExecutionContextPool
ExecutionContextPool getExecutionContextPool()
-
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
-
getStatistics
FactoryStatistics getStatistics()
-
getImplementationCreator
ImplementationCreator getImplementationCreator()
-
getResourcedTransactionManager
ResourcedTransactionManager getResourcedTransactionManager()
-
getJtaTransactionManager
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()
-
getLevel2Cache
Level2Cache getLevel2Cache()
-
getExecutionContextListeners
ExecutionContext.LifecycleListener[] getExecutionContextListeners()
Object the array of registered ExecutionContext listeners.- Returns:
- array of
ExecutionContext.LifecycleListener
-
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 toname- 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 classname- Name of the groupcreateIfNotPresent- 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
-
isClassMultiTenant
boolean isClassMultiTenant(AbstractClassMetaData cmd)
Accessor for whether the supplied class is multi-tenant (i.e with a tenancy id column).- Parameters:
cmd- The class- Returns:
- Whether it is multi-tenant
-
getMultiTenancyId
String getMultiTenancyId(ExecutionContext ec)
Accessor for the tenant id for the ExecutionContext.- Parameters:
ec- ExecutionContext- Returns:
- The tenant id for this context.
-
getMultiTenancyReadIds
String[] getMultiTenancyReadIds(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.
-
-