Class AbstractTopiaApplicationContext<K extends TopiaPersistenceContext>
java.lang.Object
org.nuiton.topia.persistence.internal.AbstractTopiaApplicationContext<K>
- All Implemented Interfaces:
Closeable,AutoCloseable,TopiaListenableSupport,TopiaServiceSupport,TopiaApplicationContext<K>
public abstract class AbstractTopiaApplicationContext<K extends TopiaPersistenceContext>
extends Object
implements TopiaApplicationContext<K>
The application context is the main class in ToPIA usage. This class is a kind of equivalent of the RootTopiaContext.
It contains only high level methods and new contexts creation (transaction begin, ...). This class has to be extended
by the user, even if some default one could be automatically generated.
- Since:
- 3.0
- Author:
- Arnaud Thimel (Code Lutin)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected TopiaConfigurationprotected HibernateProviderprotected Set<TopiaPersistenceContext>A set of known initialized opened persistence contexts.protected TopiaHibernateSessionRegistryprotected TopiaFiresSupportprotected TopiaIdFactoryprotected TopiaServiceSupport -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.AbstractTopiaApplicationContext(Properties properties) AbstractTopiaApplicationContext(TopiaConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoidRegister to the context a PropertyChangeListener about some entity's property change.voidRegister to the context a TopiaEntitiesVetoable about any TopiaEntity.voidaddTopiaEntityListener(Class<? extends TopiaEntity> entityClass, TopiaEntityListener listener) Register to the context a TopiaEntityListener about the given entity class.voidaddTopiaEntityListener(TopiaEntityListener listener) Register to the context a TopiaEntityListener about any TopiaEntity.voidaddTopiaEntityVetoable(Class<? extends TopiaEntity> entityClass, TopiaEntityVetoable vetoable) Register to the context a TopiaEntityVetoable about the given entity class.voidaddTopiaEntityVetoable(TopiaEntityVetoable vetoable) Register to the context a TopiaEntityVetoable about any TopiaEntity.voidaddTopiaSchemaListener(TopiaSchemaListener listener) Register to the context a TopiaSchemaListener about any schema modification.voidRegister to the context a TopiaTransactionListener about the transaction.voidRegister to the context a TopiaTransactionVetoable about the transaction.voidclose()Method to call when the application is going for shutdown.voidvoidprotected abstract Set<Class<? extends TopiaEntity>>Get the list of entities (ToPIA or not) that Hibernate has to handle.com.google.common.collect.ImmutableSet<String><T extends TopiaService>
Map<String,T> getServices(Class<T> interfaceService) protected TopiaFiresSupportprotected TopiaIdFactoryprotected voidinit()voidWill make everything possible to ensure the schema is ready to use.protected voidbooleanisClosed()protected booleanIf application context should init schema.booleanisOpened()booleanbooleanisTableExists(Class<?> clazz) protected voidregisterPersistenceContext(TopiaPersistenceContext persistenceContext) voidUnregister the given PropertyChangeListener about some entity's property change from the contextvoidUnregister the given TopiaEntitiesVetoable about any TopiaEntity from the contextvoidremoveTopiaEntityListener(Class<? extends TopiaEntity> entityClass, TopiaEntityListener listener) Unregister the given TopiaEntityListener about the given entity class from the contextvoidremoveTopiaEntityListener(TopiaEntityListener listener) Unregister the given TopiaEntityListener about any TopiaEntity from the contextvoidremoveTopiaEntityVetoable(Class<? extends TopiaEntity> entityClass, TopiaEntityVetoable vetoable) Unregister the given TopiaEntityVetoable about the given entity class from the contextvoidremoveTopiaEntityVetoable(TopiaEntityVetoable vetoable) Unregister the given TopiaEntityVetoable about any TopiaEntity from the contextvoidremoveTopiaSchemaListener(TopiaSchemaListener listener) Unregister the given TopiaSchemaListener about any schema modification from the contextvoidUnregister the given TopiaTransactionListener about the transaction from the contextvoidUnregister the given TopiaTransactionVetoable about the transaction from the contextvoidvoidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuiton.topia.persistence.TopiaApplicationContext
getContractClass, getContractClasses, getImplementationClass, getModelName, getModelVersion, newPersistenceContext
-
Field Details
-
topiaIdFactory
-
configuration
-
topiaFiresSupport
-
topiaServiceSupport
-
hibernateProvider
-
sessionRegistry
-
closed
protected boolean closed -
persistenceContexts
A set of known initialized opened persistence contexts. This set is mainly used to trigger shutdown on these persistence contexts when the application context is closed.
-
-
Constructor Details
-
AbstractTopiaApplicationContext
- Parameters:
properties- FIXME
-
AbstractTopiaApplicationContext
- Parameters:
map- FIXME
-
AbstractTopiaApplicationContext
-
-
Method Details
-
init
protected void init() -
initServices
protected void initServices() -
isInitSchema
protected boolean isInitSchema()If application context should init schema. This simple check is in its own method so it can be overridden.- Returns:
- FIXME
- See Also:
-
initSchema
public void initSchema()Will make everything possible to ensure the schema is ready to use. It will create unless it already exists. If it already exists, we will try to find a migration service and call it.- Specified by:
initSchemain interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
getImplementationClasses
-
registerPersistenceContext
-
getHibernateProvider
-
getTopiaFiresSupport
-
getConfiguration
- Specified by:
getConfigurationin interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
getTopiaIdFactory
-
getSessionRegistry
-
addTopiaEntityListener
Description copied from interface:TopiaListenableSupportRegister to the context a TopiaEntityListener about any TopiaEntity.listenerinstance will be notified AFTER any operation on the entity.- Specified by:
addTopiaEntityListenerin interfaceTopiaListenableSupport- Parameters:
listener- the listener instance to register
-
addTopiaEntityListener
public void addTopiaEntityListener(Class<? extends TopiaEntity> entityClass, TopiaEntityListener listener) Description copied from interface:TopiaListenableSupportRegister to the context a TopiaEntityListener about the given entity class.listenerinstance will be notified AFTER any operation on the entity.- Specified by:
addTopiaEntityListenerin interfaceTopiaListenableSupport- Parameters:
entityClass- the TopiaEntity's class to listenlistener- the listener instance to register
-
removeTopiaEntityListener
Description copied from interface:TopiaListenableSupportUnregister the given TopiaEntityListener about any TopiaEntity from the context- Specified by:
removeTopiaEntityListenerin interfaceTopiaListenableSupport- Parameters:
listener- the listener instance to unregister
-
removeTopiaEntityListener
public void removeTopiaEntityListener(Class<? extends TopiaEntity> entityClass, TopiaEntityListener listener) Description copied from interface:TopiaListenableSupportUnregister the given TopiaEntityListener about the given entity class from the context- Specified by:
removeTopiaEntityListenerin interfaceTopiaListenableSupport- Parameters:
entityClass- the listened TopiaEntity's classlistener- the listener instance to unregister
-
addTopiaEntityVetoable
Description copied from interface:TopiaListenableSupportRegister to the context a TopiaEntityVetoable about any TopiaEntity.vetoableinstance will be notified BEFORE any operation on the entity.- Specified by:
addTopiaEntityVetoablein interfaceTopiaListenableSupport- Parameters:
vetoable- the vetoable instance to register
-
addTopiaEntityVetoable
public void addTopiaEntityVetoable(Class<? extends TopiaEntity> entityClass, TopiaEntityVetoable vetoable) Description copied from interface:TopiaListenableSupportRegister to the context a TopiaEntityVetoable about the given entity class.vetoableinstance will be notified BEFORE any operation on the entity.- Specified by:
addTopiaEntityVetoablein interfaceTopiaListenableSupport- Parameters:
entityClass- the TopiaEntity's class to listenvetoable- the vetoable instance to register
-
removeTopiaEntityVetoable
Description copied from interface:TopiaListenableSupportUnregister the given TopiaEntityVetoable about any TopiaEntity from the context- Specified by:
removeTopiaEntityVetoablein interfaceTopiaListenableSupport- Parameters:
vetoable- the vetoable instance to unregister
-
removeTopiaEntityVetoable
public void removeTopiaEntityVetoable(Class<? extends TopiaEntity> entityClass, TopiaEntityVetoable vetoable) Description copied from interface:TopiaListenableSupportUnregister the given TopiaEntityVetoable about the given entity class from the context- Specified by:
removeTopiaEntityVetoablein interfaceTopiaListenableSupport- Parameters:
entityClass- the listened TopiaEntity's classvetoable- the vetoable instance to unregister
-
addTopiaEntitiesVetoable
Description copied from interface:TopiaListenableSupportRegister to the context a TopiaEntitiesVetoable about any TopiaEntity.vetoableinstance will be notified BEFORE any entity load- Specified by:
addTopiaEntitiesVetoablein interfaceTopiaListenableSupport- Parameters:
vetoable- the vetoable instance to register
-
removeTopiaEntitiesVetoable
Description copied from interface:TopiaListenableSupportUnregister the given TopiaEntitiesVetoable about any TopiaEntity from the context- Specified by:
removeTopiaEntitiesVetoablein interfaceTopiaListenableSupport- Parameters:
vetoable- the vetoable instance to unregister
-
addTopiaTransactionListener
Description copied from interface:TopiaListenableSupportRegister to the context a TopiaTransactionListener about the transaction.listenerinstance will be notified AFTER any operation on the transaction.- Specified by:
addTopiaTransactionListenerin interfaceTopiaListenableSupport- Parameters:
listener- the listener instance to register
-
removeTopiaTransactionListener
Description copied from interface:TopiaListenableSupportUnregister the given TopiaTransactionListener about the transaction from the context- Specified by:
removeTopiaTransactionListenerin interfaceTopiaListenableSupport- Parameters:
listener- the listener instance to unregister
-
addTopiaTransactionVetoable
Description copied from interface:TopiaListenableSupportRegister to the context a TopiaTransactionVetoable about the transaction.vetoableinstance will be notified BEFORE any operation on the transaction.- Specified by:
addTopiaTransactionVetoablein interfaceTopiaListenableSupport- Parameters:
vetoable- the vetoable instance to register
-
removeTopiaTransactionVetoable
Description copied from interface:TopiaListenableSupportUnregister the given TopiaTransactionVetoable about the transaction from the context- Specified by:
removeTopiaTransactionVetoablein interfaceTopiaListenableSupport- Parameters:
vetoable- the vetoable instance to unregister
-
addPropertyChangeListener
Description copied from interface:TopiaListenableSupportRegister to the context a PropertyChangeListener about some entity's property change.listenerinstance will be notified AFTER any change on the entity's property- Specified by:
addPropertyChangeListenerin interfaceTopiaListenableSupport- Parameters:
listener- the listener instance to register
-
removePropertyChangeListener
Description copied from interface:TopiaListenableSupportUnregister the given PropertyChangeListener about some entity's property change from the context- Specified by:
removePropertyChangeListenerin interfaceTopiaListenableSupport- Parameters:
listener- the listener instance to unregister
-
addTopiaSchemaListener
Description copied from interface:TopiaListenableSupportRegister to the context a TopiaSchemaListener about any schema modification.listenerinstance will be notified BEFORE and AFTER any change on the schema- Specified by:
addTopiaSchemaListenerin interfaceTopiaListenableSupport- Parameters:
listener- the listener instance to register
-
removeTopiaSchemaListener
Description copied from interface:TopiaListenableSupportUnregister the given TopiaSchemaListener about any schema modification from the context- Specified by:
removeTopiaSchemaListenerin interfaceTopiaListenableSupport- Parameters:
listener- the listener instance to unregister
-
getServices
- Specified by:
getServicesin interfaceTopiaServiceSupport- Returns:
- The list of registered services. The map key is the service name, and the value is the service instance.
-
getServices
- Specified by:
getServicesin interfaceTopiaServiceSupport- Type Parameters:
T- type of service- Parameters:
interfaceService- FIXME- Returns:
- Same as
TopiaServiceSupport.getServices()but returns only services that implements given contract (or is instance of given class).
-
getPersistenceClasses
Description copied from interface:TopiaApplicationContextGet the list of entities (ToPIA or not) that Hibernate has to handle. By default it only contains ToPIA entities but you may override it to add any other Hibernate entity.- Specified by:
getPersistenceClassesin interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
isSchemaEmpty
public boolean isSchemaEmpty()- Specified by:
isSchemaEmptyin interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
isTableExists
- Specified by:
isTableExistsin interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
getSchemaName
- Specified by:
getSchemaNamein interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>- Returns:
- the default schema name.
-
createSchema
public void createSchema()- Specified by:
createSchemain interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
showCreateSchema
public void showCreateSchema()- Specified by:
showCreateSchemain interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
updateSchema
public void updateSchema()- Specified by:
updateSchemain interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
dropSchema
public void dropSchema()- Specified by:
dropSchemain interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
close
public void close()Description copied from interface:TopiaApplicationContextMethod to call when the application is going for shutdown. It will trigger the shutdown of all the opened childrenTopiaPersistenceContext- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>
-
getSchemaNames
- Specified by:
getSchemaNamesin interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>- Returns:
- all schema names used by persistent entities.
-
isClosed
public boolean isClosed()- Specified by:
isClosedin interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>- Returns:
- true is the application context is already closed, false otherwise
-
isOpened
public boolean isOpened()- Specified by:
isOpenedin interfaceTopiaApplicationContext<K extends TopiaPersistenceContext>- Returns:
- true is the application context is opened (ie not yet
TopiaApplicationContext.isClosed())
-
AbstractTopiaApplicationContext(org.nuiton.topia.persistence.TopiaConfiguration)