public class DefaultServiceContext extends Object implements ServiceContext
| Modifier and Type | Field and Description |
|---|---|
protected AgrosystServiceConfig |
config |
protected AgrosystTopiaPersistenceContext |
persistenceContext |
protected ServiceFactory |
serviceFactory |
protected com.google.common.base.Supplier<AgrosystTopiaPersistenceContext> |
transactionSupplier |
| Constructor and Description |
|---|
DefaultServiceContext(AgrosystServiceConfig config,
com.google.common.base.Supplier<AgrosystTopiaPersistenceContext> transactionSupplier) |
DefaultServiceContext(AgrosystServiceConfig config,
com.google.common.base.Supplier<AgrosystTopiaPersistenceContext> transactionSupplier,
String authenticationToken) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close context and release resources.
|
AgrosystServiceConfig |
getConfig()
Let each service get the current configuration
|
Date |
getCurrentDate()
Méthode à utiliser plutôt que new Date() pour une meilleure testabilité
|
AgrosystTopiaDaoSupplier |
getDaoSupplier()
Permet à chaque service d'obtenir un fournisseur de Dao
|
com.google.gson.Gson |
getGson() |
AgrosystTopiaPersistenceContext |
getPersistenceContext() |
AgrosystTopiaPersistenceContext |
getPersistenceContext(boolean create) |
SecurityContext |
getSecurityContext()
Returns the current security context.
|
SecurityContext |
getSecurityContextAsUser(String userId)
Returns the current security context to operate as specified
userId. |
ServiceFactory |
getServiceFactory() |
org.nuiton.topia.persistence.TopiaTransaction |
getTransaction()
Permet à chaque service d'obtenir la transaction en cours.
|
org.nuiton.topia.persistence.TopiaTransaction |
getTransaction(boolean create)
Permet à chaque service d'obtenir la transaction en cours
|
protected AgrosystTopiaPersistenceContext |
getTransaction0(boolean create) |
<I> I |
newInstance(Class<I> clazz)
Build new
clazz instance with inject objects (Service, Config, DAO...) |
<E extends AgrosystService> |
newService(Class<E> clazz)
Build new service instance depending on factory implementation.
|
ServiceContext |
newServiceContext()
Create new service context from current service context with custom lifecycle.
|
void |
setAuthenticationToken(String authenticationToken) |
protected ServiceFactory serviceFactory
protected com.google.common.base.Supplier<AgrosystTopiaPersistenceContext> transactionSupplier
protected AgrosystTopiaPersistenceContext persistenceContext
protected AgrosystServiceConfig config
public DefaultServiceContext(AgrosystServiceConfig config, com.google.common.base.Supplier<AgrosystTopiaPersistenceContext> transactionSupplier)
public DefaultServiceContext(AgrosystServiceConfig config, com.google.common.base.Supplier<AgrosystTopiaPersistenceContext> transactionSupplier, String authenticationToken)
public ServiceContext newServiceContext()
ServiceContextnewServiceContext in interface ServiceContextpublic Date getCurrentDate()
ServiceContextgetCurrentDate in interface ServiceContextpublic org.nuiton.topia.persistence.TopiaTransaction getTransaction()
ServiceContextServiceContext.getTransaction(boolean))} avec la valeur 'true'getTransaction in interface ServiceContextServiceContext.getTransaction(boolean)public org.nuiton.topia.persistence.TopiaTransaction getTransaction(boolean create)
ServiceContextgetTransaction in interface ServiceContextcreate - indique si il faut créer la transaction si elle n'existe paspublic AgrosystTopiaDaoSupplier getDaoSupplier()
ServiceContextgetDaoSupplier in interface ServiceContextpublic AgrosystTopiaPersistenceContext getPersistenceContext()
getPersistenceContext in interface ServiceContextpublic AgrosystTopiaPersistenceContext getPersistenceContext(boolean create)
getPersistenceContext in interface ServiceContextcreate - indique si il faut créer la transaction si elle n'existe paspublic void close()
ServiceContextclose in interface ServiceContextprotected AgrosystTopiaPersistenceContext getTransaction0(boolean create)
public ServiceFactory getServiceFactory()
public <E extends AgrosystService> E newService(Class<E> clazz)
ServiceContextnewService in interface ServiceContextclazz - service interfaceServiceFactory.newService(Class)public AgrosystServiceConfig getConfig()
ServiceContextgetConfig in interface ServiceContextpublic SecurityContext getSecurityContext()
ServiceContextgetSecurityContext in interface ServiceContextpublic SecurityContext getSecurityContextAsUser(String userId)
ServiceContextuserId. Note : the life cycle of this object is linked to the security context
life cycle (request).getSecurityContextAsUser in interface ServiceContextuserId - userId to operate withpublic <I> I newInstance(Class<I> clazz)
ServiceContextclazz instance with inject objects (Service, Config, DAO...)newInstance in interface ServiceContextclazz - implementation classpublic void setAuthenticationToken(String authenticationToken)
public com.google.gson.Gson getGson()
getGson in interface ServiceContextCopyright © 2013–2015 Inra. All rights reserved.