public class GenericReplicatingServiceBean extends GenericServiceBean
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
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
collectReplications |
protected boolean |
connected |
protected IGenericBaseService |
replication |
protected List<IGenericBaseService> |
replicationServices |
entityManagerNAMEDQUERY_ALL, NAMEDQUERY_BETWEEN, NAMEDQUERY_DELETE, NAMEDQUERY_ID, NAMEDQUERY_INSERT, NAMEDQUERY_UPDATE| Constructor and Description |
|---|
GenericReplicatingServiceBean(javax.persistence.EntityManager entityManager,
boolean createReplication)
constructor
|
GenericReplicatingServiceBean(javax.persistence.EntityManager entityManager,
List<IGenericBaseService> replicationServices)
constructor
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected void |
addReplicationEntities(IGenericBaseService repService,
List<Object> reps,
de.tsl2.nano.persistence.replication.Tree<Object,de.tsl2.nano.bean.def.BeanValue> container,
Class... excludes) |
boolean |
checkConnection(boolean throwException) |
protected boolean |
checkConnection(IGenericBaseService service,
boolean throwException)
checkConnection
|
javax.persistence.EntityManager |
connection() |
protected static List<IGenericBaseService> |
createStandardReplication()
createStandardReplication
|
protected void |
doForReplication(Runnable replicationJob) |
Collection<?> |
findByQuery(String queryString,
boolean nativeQuery,
int startIndex,
int maxResult,
Object[] args,
Map<String,?> hints,
Class... lazyRelations) |
protected IGenericBaseService |
getAvailableReplication() |
<T> T |
persistNoTransaction(T bean,
boolean refreshBean,
boolean flush,
Class... lazyRelations) |
void |
remove(Object bean) |
void |
switchToConnection(int index)
setting default entitymanager.
|
createQuery, executeQuery, fillTree, find, findAll, findAll, findBatch, findBetween, findBetween, findByExample, findByExample, findByExample, findByExampleLike, findById, findByQuery, findByQuery, findHolders, findItemByQuery, findMembers, findValueByQuery, getUser, instantiateLazyRelationship, instantiateLazyRelationship, instantiateLazyRelationship, instantiateLazyRelationship, instantiateLazyRelationship, persist, persist, persistAll, persistCollection, refresh, removeCollectionfindByNamedQuery, getNamedQueryByArguments, getNamedQueryPrefix, isNamedQuery, isVirtualEntity, persistByNamedQuery, removeByNamedQuerycheckContextSecurity, formatQuery, getEntityTypes, getLazyRelationType, getMaxRecursionLevel, getMaxResult, getServerInfo, initServerSideFactories, isLazyLoadingOnlyOnOneToMany, logTrace, setParameterclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitServerSideFactoriesinitServerSideFactoriesgetServerInfofindByNamedQueryprotected List<IGenericBaseService> replicationServices
protected IGenericBaseService replication
protected boolean connected
protected boolean collectReplications
public GenericReplicatingServiceBean(javax.persistence.EntityManager entityManager,
boolean createReplication)
public GenericReplicatingServiceBean(javax.persistence.EntityManager entityManager,
List<IGenericBaseService> replicationServices)
enitityManager - replications - protected static List<IGenericBaseService> createStandardReplication()
protected IGenericBaseService getAvailableReplication()
public void switchToConnection(int index)
index - index of replication (TODO: how to evaluate a name of an entity manager?)public javax.persistence.EntityManager connection()
connection in class AbstractStatelessServiceBeanpublic boolean checkConnection(boolean throwException)
protected boolean checkConnection(IGenericBaseService service, boolean throwException)
service - connectionthrowException - if true, the exception will be forwardedprotected void doForReplication(Runnable replicationJob)
public Collection<?> findByQuery(String queryString, boolean nativeQuery, int startIndex, int maxResult, Object[] args, Map<String,?> hints, Class... lazyRelations)
findByQuery in interface IGenericBaseServicefindByQuery in class GenericServiceBeanprotected void addReplicationEntities(IGenericBaseService repService, List<Object> reps, de.tsl2.nano.persistence.replication.Tree<Object,de.tsl2.nano.bean.def.BeanValue> container, Class... excludes)
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)
repService - service to check the new replication objectsreps - objects to be checked if already persistedpublic <T> T persistNoTransaction(T bean,
boolean refreshBean,
boolean flush,
Class... lazyRelations)
persistNoTransaction in interface IGenericBaseServicepersistNoTransaction in class GenericServiceBeanpublic void remove(Object bean)
remove in interface IGenericBaseServiceremove in class GenericServiceBeanCopyright © 2012–2018. All rights reserved.