Class GenericReplicatingServiceBean
java.lang.Object
de.tsl2.nano.service.util.AbstractStatelessServiceBean
de.tsl2.nano.service.util.NamedQueryServiceBean
de.tsl2.nano.service.util.GenericServiceBean
de.tsl2.nano.persistence.replication.GenericReplicatingServiceBean
- All Implemented Interfaces:
IBatchService,IGenericBaseService,IGenericLocalService,IGenericService,INamedQueryService,IQueryService,IStatelessService
- Direct Known Subclasses:
GenericLocalServiceBean
NOT FINISHED YET!
Overrides the base service methods of
GenericServiceBean to do actions on a list of jpa EntitiyManagers. The
first entity manager is the root/main to do the service on. all other entity managers will be used for replications.
Technical Mechanism: - on getting data by queries, the root/main entity manager will be used to evaluate the data. the others will persist this new data. - on storing new or changed data, all entity managers will do the same on their connection. - works only if auto-commit = true
- Version:
- $Revision$
- Author:
- Tom, Thomas Schneider
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected IGenericBaseServiceprotected List<IGenericBaseService>Fields inherited from class de.tsl2.nano.service.util.AbstractStatelessServiceBean
entityManagerFields inherited from interface de.tsl2.nano.service.util.INamedQueryService
NAMEDQUERY_ALL, NAMEDQUERY_BETWEEN, NAMEDQUERY_DELETE, NAMEDQUERY_ID, NAMEDQUERY_INSERT, NAMEDQUERY_UPDATE -
Constructor Summary
ConstructorsConstructorDescriptionGenericReplicatingServiceBean(javax.persistence.EntityManager entityManager, boolean createReplication) constructorGenericReplicatingServiceBean(javax.persistence.EntityManager entityManager, List<IGenericBaseService> replicationServices) constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddReplicationEntities(IGenericBaseService repService, List<Object> reps, de.tsl2.nano.persistence.replication.Tree<Object, de.tsl2.nano.bean.def.BeanValue> container, boolean addRepsToContainer, Class... excludes) checks recursive the given list of objects to be replicated to the given service.protected voidaddReplicationEntities(IGenericBaseService repService, List<Object> reps, de.tsl2.nano.persistence.replication.Tree<Object, de.tsl2.nano.bean.def.BeanValue> container, Class... excludes) booleancheckConnection(boolean throwException) protected booleancheckConnection(IGenericBaseService service, boolean throwException) checkConnectionjavax.persistence.EntityManagerprotected static List<IGenericBaseService>createStandardReplicationprotected voiddoForReplication(Runnable replicationJob) Collection<?>findByQuery(String queryString, boolean nativeQuery, int startIndex, int maxResult, Object[] args, Map<String, ?> hints, Class... lazyRelations) protected IGenericBaseService<T> TpersistNoTransaction(T bean, boolean refreshBean, boolean flush, Class... lazyRelations) voidvoidswitchToConnection(int index) setting default entitymanager.Methods inherited from class de.tsl2.nano.service.util.GenericServiceBean
createQuery, executeQuery, fillTree, find, findAll, findAll, findAll, findBatch, findBetween, findBetween, findBetween, findByExample, findByExample, findByExample, findByExampleLike, findByExampleLike, findById, findByQuery, findByQuery, findHolders, findItemByQuery, findMembers, findValueByQuery, getUser, instantiateLazyRelationship, instantiateLazyRelationship, instantiateLazyRelationship, instantiateLazyRelationship, instantiateLazyRelationship, persist, persist, persistAll, persistCollection, refresh, removeCollectionMethods inherited from class de.tsl2.nano.service.util.NamedQueryServiceBean
findByNamedQuery, getNamedQueryByArguments, getNamedQueryPrefix, isNamedQuery, isVirtualEntity, persistByNamedQuery, removeByNamedQueryMethods inherited from class de.tsl2.nano.service.util.AbstractStatelessServiceBean
checkContextSecurity, finalize, formatQuery, getEntityTypes, getLazyRelationType, getMaxRecursionLevel, getMaxResult, getServerInfo, initServerSideFactories, isLazyLoadingOnlyOnOneToMany, logTrace, setParameterMethods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.tsl2.nano.service.util.IGenericLocalService
initServerSideFactoriesMethods inherited from interface de.tsl2.nano.service.util.IGenericService
initServerSideFactoriesMethods inherited from interface de.tsl2.nano.service.util.INamedQueryService
findByNamedQueryMethods inherited from interface de.tsl2.nano.service.util.IStatelessService
getServerInfo
-
Field Details
-
replicationServices
-
replication
-
connected
protected boolean connected -
collectReplications
protected boolean collectReplications
-
-
Constructor Details
-
GenericReplicatingServiceBean
public GenericReplicatingServiceBean(javax.persistence.EntityManager entityManager, boolean createReplication) constructor -
GenericReplicatingServiceBean
public GenericReplicatingServiceBean(javax.persistence.EntityManager entityManager, List<IGenericBaseService> replicationServices) constructor- Parameters:
enitityManager-replications-
-
-
Method Details
-
createStandardReplication
createStandardReplication- Returns:
- list filled with service on persistence-unit 'replication'
-
getAvailableReplication
-
switchToConnection
public void switchToConnection(int index) setting default entitymanager.- Parameters:
index- index of replication (TODO: how to evaluate a name of an entity manager?)
-
connection
public javax.persistence.EntityManager connection()- Overrides:
connectionin classAbstractStatelessServiceBean
-
checkConnection
public boolean checkConnection(boolean throwException) -
checkConnection
checkConnection- Parameters:
service- connectionthrowException- if true, the exception will be forwarded- Returns:
- true, if connection could be established
-
doForReplication
-
findByQuery
public Collection<?> findByQuery(String queryString, boolean nativeQuery, int startIndex, int maxResult, Object[] args, Map<String, ?> hints, Class... lazyRelations) - Specified by:
findByQueryin interfaceIGenericBaseService- Overrides:
findByQueryin classGenericServiceBean
-
addReplicationEntities
protected void addReplicationEntities(IGenericBaseService repService, List<Object> reps, de.tsl2.nano.persistence.replication.Tree<Object, de.tsl2.nano.bean.def.BeanValue> container, Class... excludes) -
addReplicationEntities
protected void addReplicationEntities(IGenericBaseService repService, List<Object> reps, de.tsl2.nano.persistence.replication.Tree<Object, de.tsl2.nano.bean.def.BeanValue> container, boolean addRepsToContainer, Class... excludes) checks recursive the given list of objects to be replicated to the given service.- Parameters:
repService- service to check the new replication objectsreps- objects to be checked if already persisted
-
persistNoTransaction
public <T> T persistNoTransaction(T bean, boolean refreshBean, boolean flush, Class... lazyRelations) - Specified by:
persistNoTransactionin interfaceIGenericBaseService- Overrides:
persistNoTransactionin classGenericServiceBean
-
remove
- Specified by:
removein interfaceIGenericBaseService- Overrides:
removein classGenericServiceBean
-