|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.topia.framework.TopiaContextImpl
public class TopiaContextImpl
Le TopiaContextImpl est le point d'entre pour acceder aux donnees. Il est configurer par un fichier de propriete
List des proprietes disponible
| Field Summary | |
|---|---|
protected java.util.Set<TopiaContextImplementor> |
childContext
Set des sous context creer avec un beginTransaction et donc sur lequel nous sommes listener |
protected boolean |
closed
Indique si le contexte a ete ferme |
protected java.util.Properties |
config
Propriete de configuration |
protected java.util.Map<java.lang.Class<? extends TopiaEntity>,TopiaDAO<? extends TopiaEntity>> |
daoCache
cache des DAO deja chargé pour ce context |
protected TopiaFiresSupport |
firesSupport
|
protected org.hibernate.Session |
hibernate
La session utilisé par le TopiaContextImpl |
protected org.hibernate.cfg.Configuration |
hibernateConfiguration
L'objet configuration utilisé pour la creation de la factory hibernate |
protected org.hibernate.SessionFactory |
hibernateFactory
la factory permettant de recuperer la session hibernate. |
protected TopiaContextImplementor |
parentContext
Le pere de ce context, les contexts initaux n'ont pas de context pere |
protected java.util.List<java.lang.Class<?>> |
persistenceClasses
Liste des classes perssitance |
protected java.util.Map<java.lang.String,TopiaService> |
services
key: service name; value: service instance |
static java.lang.String |
TOPIA_PERSISTENCE_CLASSES
|
static java.lang.String |
TOPIA_PERSISTENCE_DIRECTORIES
|
static java.lang.String |
TOPIA_PERSISTENCE_PROPERTIES_FILE
|
| Constructor Summary | |
|---|---|
|
TopiaContextImpl(java.util.Properties config)
constructeur utilisé par la factory pour creer les contexts initiaux |
protected |
TopiaContextImpl(TopiaContextImplementor parentContext)
Constructeur utilisé par le beginTransaction pour créer le context fils. |
| Method Summary | ||
|---|---|---|
void |
add(TopiaEntity e)
Permet d'ajouter dans le TopiaContext une TopiaEntity créé par un autre context. |
|
protected void |
addChildContext(TopiaContextImplementor child)
|
|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
|
|
void |
addTopiaContextListener(TopiaContextListener listener)
|
|
void |
addTopiaEntitiesVetoable(TopiaEntitiesVetoable vetoable)
|
|
void |
addTopiaEntityListener(java.lang.Class<? extends TopiaEntity> entityClass,
TopiaEntityListener listener)
|
|
void |
addTopiaEntityListener(TopiaEntityListener listener)
|
|
void |
addTopiaEntityVetoable(java.lang.Class<? extends TopiaEntity> entityClass,
TopiaEntityVetoable vetoable)
|
|
void |
addTopiaEntityVetoable(TopiaEntityVetoable vetoable)
|
|
void |
addTopiaTransactionListener(TopiaTransactionListener listener)
|
|
void |
addTopiaTransactionVetoable(TopiaTransactionVetoable vetoable)
|
|
void |
backup(java.io.File file,
boolean compress)
Backup database in gzip compressed file Only work for h2 database |
|
TopiaContext |
beginTransaction()
|
|
protected java.lang.String[] |
buildQueries(java.lang.Object... entityAndCondition)
Build the list of queries from the given parameter entityAndCondition>/code>. |
|
protected void |
checkClosed(java.lang.String message)
|
|
void |
clear(boolean dropDatabase)
Only h2 supported for now |
|
void |
closeContext()
Ferme le contexte |
|
void |
commitTransaction()
applique les modifications apporté a ce context sur la base de données. |
|
void |
createSchema()
Permet de créer le schema de la base de données |
|
int |
execute(java.lang.String hql,
java.lang.Object... args)
Execute HQL operation on data (Update, Delete) |
|
void |
exportXML(java.io.Writer xml,
java.lang.Object... entityAndcondition)
Permet d'exporter certaines données en XML Note: Si le parametre entityAndCondition est vide, alors on duplique
toutes les entités de la base. |
|
protected void |
finalize()
Pour le context root on ferme tous les fils, et la factory hibernate |
|
java.util.List<?> |
find(java.lang.String hql,
int startIndex,
int endIndex,
java.lang.Object... args)
Permet de faire une requete HQL hibernate directement sur la base en precisant la fenetre des elements a remonter avec les parametres startIndex
et endIndex. |
|
java.util.List |
find(java.lang.String hql,
java.lang.Object... args)
Permet de faire une requete HQL hibernate directement sur la base |
|
TopiaEntity |
findByTopiaId(java.lang.String topiaId)
Permet de rechercher un entite directement par son TopiaId |
|
java.util.Collection<TopiaService> |
getAllServices()
|
|
java.util.Set<TopiaContextImplementor> |
getChildContext()
|
|
java.util.Properties |
getConfig()
|
|
|
getDAO(java.lang.Class<E> entityClass)
Get DAO for specified class. |
|
TopiaFiresSupport |
getFiresSupport()
|
|
org.hibernate.Session |
getHibernate()
|
|
org.hibernate.cfg.Configuration |
getHibernateConfiguration()
|
|
org.hibernate.SessionFactory |
getHibernateFactory()
|
|
TopiaContextImplementor |
getParentContext()
|
|
java.util.List<java.lang.Class<?>> |
getPersistenceClasses()
|
|
TopiaContextImplementor |
getRootContext()
|
|
|
getService(java.lang.Class<E> interfaceService)
Take one service, this service must be valid service interface with public static final SERVICE_NAME declaration. |
|
protected TopiaService |
getService(java.lang.String name)
|
|
java.util.Map<java.lang.String,TopiaService> |
getServices()
|
|
void |
importXML(java.io.Reader xml)
Permet d'importer des données en XML |
|
boolean |
isClosed()
Indique si le contexte a ete ferme |
|
boolean |
isSchemaExist(java.lang.Class<? extends TopiaEntity> clazz)
Detect if the table is created on storage for a given persistant class. |
|
protected java.util.Map<java.lang.String,TopiaService> |
loadServices(java.util.Properties config)
|
|
protected void |
postInitServices(java.util.Map<java.lang.String,TopiaService> services)
|
|
protected void |
preInitServices(java.util.Map<java.lang.String,TopiaService> services)
|
|
void |
removeChildContext(TopiaContextImplementor child)
|
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
|
|
void |
removeTopiaContextListener(TopiaContextListener listener)
|
|
void |
removeTopiaEntitiesVetoable(TopiaEntitiesVetoable vetoable)
|
|
void |
removeTopiaEntityListener(java.lang.Class<? extends TopiaEntity> entityClass,
TopiaEntityListener listener)
|
|
void |
removeTopiaEntityListener(TopiaEntityListener listener)
|
|
void |
removeTopiaEntityVetoable(java.lang.Class<? extends TopiaEntity> entityClass,
TopiaEntityVetoable vetoable)
|
|
void |
removeTopiaEntityVetoable(TopiaEntityVetoable vetoable)
|
|
void |
removeTopiaTransactionListener(TopiaTransactionListener listener)
|
|
void |
removeTopiaTransactionVetoable(TopiaTransactionVetoable vetoable)
|
|
void |
replicate(TopiaContext dstCtxt,
java.lang.Object... entityAndCondition)
Permet de dupliquer de ce context vers un context d'une autre base des données sans modification des entites. |
|
protected void |
replicate0(TopiaContextImpl dstContextImpl,
java.lang.Object... entities)
|
|
|
replicateEntities(TopiaContext dstCtxt,
java.util.List<T> entities)
Permet de dupliquer les entités du type donné vers un autre context. |
|
|
replicateEntity(TopiaContext dstCtxt,
T entity)
Permet de dupliquer une entité du type donné vers un autre context. |
|
void |
restore(java.io.File file)
Read database from gzip compressed file Only work for h2 database |
|
void |
rollbackTransaction()
annule les modifications apporté a ce context |
|
|
serviceEnabled(java.lang.Class<E> interfaceService)
Return true if specific service is available |
|
protected boolean |
serviceEnabled(java.lang.String name)
|
|
void |
showCreateSchema()
Permet d'afficher les requetes SQL de creation de base |
|
void |
updateSchema()
Permet de mettre à jour le schema de la base de données |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String TOPIA_PERSISTENCE_DIRECTORIES
public static final java.lang.String TOPIA_PERSISTENCE_CLASSES
public static final java.lang.String TOPIA_PERSISTENCE_PROPERTIES_FILE
protected TopiaContextImplementor parentContext
protected org.hibernate.cfg.Configuration hibernateConfiguration
protected org.hibernate.SessionFactory hibernateFactory
protected org.hibernate.Session hibernate
protected boolean closed
protected java.util.Properties config
protected java.util.Map<java.lang.Class<? extends TopiaEntity>,TopiaDAO<? extends TopiaEntity>> daoCache
protected java.util.Set<TopiaContextImplementor> childContext
protected java.util.Map<java.lang.String,TopiaService> services
protected TopiaFiresSupport firesSupport
protected java.util.List<java.lang.Class<?>> persistenceClasses
| Constructor Detail |
|---|
public TopiaContextImpl(java.util.Properties config)
throws TopiaNotFoundException
config -
TopiaNotFoundException
protected TopiaContextImpl(TopiaContextImplementor parentContext)
throws org.hibernate.HibernateException,
TopiaNotFoundException
parentContext -
org.hibernate.HibernateException
TopiaNotFoundException| Method Detail |
|---|
protected java.util.Map<java.lang.String,TopiaService> loadServices(java.util.Properties config)
protected void preInitServices(java.util.Map<java.lang.String,TopiaService> services)
protected void postInitServices(java.util.Map<java.lang.String,TopiaService> services)
public java.util.Map<java.lang.String,TopiaService> getServices()
getServices in interface TopiaContextImplementorprotected boolean serviceEnabled(java.lang.String name)
protected TopiaService getService(java.lang.String name)
public <E extends TopiaService> boolean serviceEnabled(java.lang.Class<E> interfaceService)
TopiaContext
serviceEnabled in interface TopiaContextE - type of serviceinterfaceService - fqn of the service
public <E extends TopiaService> E getService(java.lang.Class<E> interfaceService)
throws TopiaNotFoundException
getService in interface TopiaContextE - interfaceService - fqn of the service
TopiaNotFoundExceptionpublic java.util.Collection<TopiaService> getAllServices()
getAllServices in interface TopiaContextImplementorpublic java.util.Set<TopiaContextImplementor> getChildContext()
getChildContext in interface TopiaContextImplementorprotected void addChildContext(TopiaContextImplementor child)
public void removeChildContext(TopiaContextImplementor child)
removeChildContext in interface TopiaContextImplementorpublic TopiaContextImplementor getParentContext()
getParentContext in interface TopiaContextImplementorpublic TopiaContextImplementor getRootContext()
getRootContext in interface TopiaContextImplementorpublic java.util.Properties getConfig()
getConfig in interface TopiaContextImplementor
public void createSchema()
throws TopiaException
TopiaContext
createSchema in interface TopiaContextTopiaException - if any exception
public void showCreateSchema()
throws TopiaException
TopiaContext
showCreateSchema in interface TopiaContextTopiaException - if any exception
public void updateSchema()
throws TopiaException
TopiaContext
updateSchema in interface TopiaContextTopiaException - if any exception
public org.hibernate.Session getHibernate()
throws TopiaException
getHibernate in interface TopiaContextImplementorTopiaException - si aucune transaction n'est ouverte
public org.hibernate.SessionFactory getHibernateFactory()
throws TopiaNotFoundException
getHibernateFactory in interface TopiaContextImplementorTopiaNotFoundException
public org.hibernate.cfg.Configuration getHibernateConfiguration()
throws TopiaNotFoundException
getHibernateConfiguration in interface TopiaContextImplementorTopiaNotFoundException
public <E extends TopiaEntity> TopiaDAO<E> getDAO(java.lang.Class<E> entityClass)
throws TopiaException
TopiaContextImplementor
getDAO in interface TopiaContextImplementorTopiaException
public TopiaContext beginTransaction()
throws TopiaException
beginTransaction in interface TopiaContextTopiaException
public void commitTransaction()
throws TopiaException
TopiaContext
commitTransaction in interface TopiaContextTopiaException - if any exception
public void rollbackTransaction()
throws TopiaException
TopiaContext
rollbackTransaction in interface TopiaContextTopiaException - if any exception
public void closeContext()
throws TopiaException
TopiaContext
closeContext in interface TopiaContextTopiaException - if any exception
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.ThrowableObject.finalize()public boolean isClosed()
TopiaContext
isClosed in interface TopiaContexttrue si le context est ferme, false autrement
protected void checkClosed(java.lang.String message)
throws TopiaException
TopiaException
public TopiaEntity findByTopiaId(java.lang.String topiaId)
throws TopiaException
TopiaContext
findByTopiaId in interface TopiaContexttopiaId - l'id de l'entite recherche
TopiaException - if any exception
public java.util.List find(java.lang.String hql,
java.lang.Object... args)
throws TopiaException
TopiaContext
find in interface TopiaContexthql - la requete a faireargs - les arguments de la requete
TopiaException - si une erreur survient durant la requete
public java.util.List<?> find(java.lang.String hql,
int startIndex,
int endIndex,
java.lang.Object... args)
throws TopiaException
TopiaContextstartIndex
et endIndex.
find in interface TopiaContexthql - la requete a fairestartIndex - la position du premier element a remonterendIndex - la position du dernier element a remonterargs - les arguments de la requete
TopiaException - si une erreur survient durant la requete
public int execute(java.lang.String hql,
java.lang.Object... args)
throws TopiaException
execute in interface TopiaContexthql - args -
TopiaException
public void add(TopiaEntity e)
throws TopiaException
TopiaContext
add in interface TopiaContexte - l'entity a ajouter
TopiaException - if any exception
public void importXML(java.io.Reader xml)
throws TopiaException
TopiaContext
importXML in interface TopiaContextxml - le flux XML
TopiaException - si une erreur survient durant l'import
public void exportXML(java.io.Writer xml,
java.lang.Object... entityAndcondition)
throws TopiaException
TopiaContextentityAndCondition est vide, alors on duplique
toutes les entités de la base.
exportXML in interface TopiaContextxml - le flux XML dans lequel il faut ecrireentityAndcondition - paramètre qui vont par deux, qui represente
la classe de l'entity a exporter et la condition where que doit
respecter l'objet pour etre exporter
(entityClass, condition)
TopiaException - si une erreur survient durant l'export
public void replicate(TopiaContext dstCtxt,
java.lang.Object... entityAndCondition)
throws TopiaException,
java.lang.IllegalArgumentException
TopiaContextentityAndCondition est vide, alors on duplique
toutes les entités de la base.
Note 2: Il se peut que la replication simple ne soit pas suffisante (par example
si l'on veut repliquer q'une partie d'une entité), on utilisera donc la seconde méthode
TopiaContext.replicateEntities(TopiaContext, List).
replicate in interface TopiaContextdstCtxt - le context de la base destinationentityAndCondition - paramètre qui vont par deux, qui represente
la classe de l'entity a exporter et la condition where que doit
respecter l'objet pour etre exporter
(entityClass, condition)
TopiaException - si une erreur pendant la duplication
java.lang.IllegalArgumentException - si l'un des context n'est pas ouvert, ou si on essaye de
dupliquer dans la même base.
public <T extends TopiaEntity> void replicateEntity(TopiaContext dstCtxt,
T entity)
throws TopiaException,
java.lang.IllegalArgumentException
TopiaContext
replicateEntity in interface TopiaContextT - le type des entités à répliquerdstCtxt - le context de la base destinationentity - l'entité à répliquer
TopiaException - si une erreur pendant la duplication
java.lang.IllegalArgumentException - si l'un des context n'est pas ouvert, ou si on essaye de
dupliquer dans la même base.
public <T extends TopiaEntity> void replicateEntities(TopiaContext dstCtxt,
java.util.List<T> entities)
throws TopiaException,
java.lang.IllegalArgumentException
TopiaContext
replicateEntities in interface TopiaContextT - le type des entités à répliquerdstCtxt - le context de la base destinationentities - les entités à répliquer
TopiaException - si une erreur pendant la duplication
java.lang.IllegalArgumentException - si l'un des context n'est pas ouvert, ou si on essaye de
dupliquer dans la même base.public TopiaFiresSupport getFiresSupport()
getFiresSupport in interface TopiaContextImplementor
public void backup(java.io.File file,
boolean compress)
throws TopiaException
backup in interface TopiaContextfile - file to write backupcompress - if true then use gzip to compress file
TopiaException - if any exceptionTopiaContext.backup(java.io.File,boolean)
public void restore(java.io.File file)
throws TopiaException
restore in interface TopiaContextfile - le fichier ou prendre les informations, il peut-etre
compressé avec gzip ou non.
TopiaException - if any exceptionTopiaContext.restore(java.io.File)
public void clear(boolean dropDatabase)
throws TopiaException
clear in interface TopiaContextdropDatabase - si vrai alors supprime aussi la base de données
si la base utilise des fichiers les fichiers seront supprimé (ex: h2)
ou sera fait sur la base (pastgresql)
TopiaException - if any exceptionTopiaContext.clear(boolean)public java.util.List<java.lang.Class<?>> getPersistenceClasses()
getPersistenceClasses in interface TopiaContextImplementor
public boolean isSchemaExist(java.lang.Class<? extends TopiaEntity> clazz)
throws TopiaException
TopiaContextImplementor
isSchemaExist in interface TopiaContextImplementorclazz - the researched class
TopiaException - si aucune transaction n'est ouvertepublic void addTopiaEntityListener(TopiaEntityListener listener)
addTopiaEntityListener in interface TopiaContext
public void addTopiaEntityListener(java.lang.Class<? extends TopiaEntity> entityClass,
TopiaEntityListener listener)
addTopiaEntityListener in interface TopiaContextpublic void addTopiaEntityVetoable(TopiaEntityVetoable vetoable)
addTopiaEntityVetoable in interface TopiaContext
public void addTopiaEntityVetoable(java.lang.Class<? extends TopiaEntity> entityClass,
TopiaEntityVetoable vetoable)
addTopiaEntityVetoable in interface TopiaContextpublic void addTopiaTransactionListener(TopiaTransactionListener listener)
addTopiaTransactionListener in interface TopiaContextpublic void addTopiaTransactionVetoable(TopiaTransactionVetoable vetoable)
addTopiaTransactionVetoable in interface TopiaContextpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener in interface TopiaContextpublic void addTopiaContextListener(TopiaContextListener listener)
addTopiaContextListener in interface TopiaContextpublic void removeTopiaEntityListener(TopiaEntityListener listener)
removeTopiaEntityListener in interface TopiaContext
public void removeTopiaEntityListener(java.lang.Class<? extends TopiaEntity> entityClass,
TopiaEntityListener listener)
removeTopiaEntityListener in interface TopiaContextpublic void removeTopiaEntityVetoable(TopiaEntityVetoable vetoable)
removeTopiaEntityVetoable in interface TopiaContext
public void removeTopiaEntityVetoable(java.lang.Class<? extends TopiaEntity> entityClass,
TopiaEntityVetoable vetoable)
removeTopiaEntityVetoable in interface TopiaContextpublic void removeTopiaTransactionListener(TopiaTransactionListener listener)
removeTopiaTransactionListener in interface TopiaContextpublic void removeTopiaTransactionVetoable(TopiaTransactionVetoable vetoable)
removeTopiaTransactionVetoable in interface TopiaContextpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener in interface TopiaContextpublic void removeTopiaContextListener(TopiaContextListener listener)
removeTopiaContextListener in interface TopiaContextpublic void addTopiaEntitiesVetoable(TopiaEntitiesVetoable vetoable)
addTopiaEntitiesVetoable in interface TopiaContextpublic void removeTopiaEntitiesVetoable(TopiaEntitiesVetoable vetoable)
removeTopiaEntitiesVetoable in interface TopiaContext
protected java.lang.String[] buildQueries(java.lang.Object... entityAndCondition)
throws TopiaException,
java.lang.IllegalArgumentException
entityAndCondition>/code>.
If no parameter is given, then build the queries for all entities is db, with no condition.
- Parameters:
entityAndCondition - the list of tuples (Class,String)
- Returns:
- the list of queries.
- Throws:
TopiaException - if any pb of db while getting entities classes.
java.lang.IllegalArgumentException - if any pb with the given parameter (mainly ClassCastException).
protected void replicate0(TopiaContextImpl dstContextImpl,
java.lang.Object... entities)
throws TopiaException
TopiaException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||