public abstract class BaseService extends Object implements Service, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanNameAware
ApplicationContext that is a child of the
context provided in setApplicationContext(ApplicationContext).
Services derived from this base class may not be re-initialized after they have been destroyed.| Modifier and Type | Field and Description |
|---|---|
private boolean |
isDestroyed
Indicates if the service has been destroyed.
|
private boolean |
isInitialized
Indicates if the service has been initialized already.
|
private org.slf4j.Logger |
log
Class logger.
|
private org.springframework.context.ApplicationContext |
owningContext
Application context owning this engine.
|
private ArrayList<Resource> |
serviceConfigurations
List of configuration resources for this service.
|
private org.springframework.context.support.GenericApplicationContext |
serviceContext
Context containing loaded with service content.
|
private ReentrantReadWriteLock |
serviceContextRWLock
Read/Write lock for the context.
|
private String |
serviceName
Unique name of this service.
|
| Constructor and Description |
|---|
BaseService()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy()
Destroys a service, freeing any resources it may currently be using.
|
org.springframework.context.ApplicationContext |
getApplicationContext()
Gets the application context that is the parent to this service's context.
|
String |
getId()
Gets the ID of this service.
|
protected ReadWriteLock |
getReadWriteLock()
Gets the read-write lock guarding the service context.
|
List<Resource> |
getServiceConfigurations()
Gets an unmodifiable list of configurations for this service.
|
org.springframework.context.ApplicationContext |
getServiceContext()
Gets this service's context.
|
void |
initialize()
Initializes this service.
|
boolean |
isDestroyed()
Gets whether the service has been destroyed.
|
boolean |
isInitialized()
Gets whether the service is initialized and ready for use.
|
protected void |
loadContext()
Loads the service context.
|
protected abstract void |
onNewContextCreated(org.springframework.context.ApplicationContext newServiceContext)
Called after a new context has been created but before it set as the service's context.
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Sets the application context that is the parent to this service's context.
|
void |
setBeanName(String name) |
protected void |
setInitialized(boolean initialized)
Sets whether this service has been initialized.
|
void |
setServiceConfigurations(List<Resource> configurations)
Sets the service's configuration resources.
|
protected void |
setServiceContext(org.springframework.context.support.GenericApplicationContext context)
Sets this service's context.
|
private final org.slf4j.Logger log
private String serviceName
private ReentrantReadWriteLock serviceContextRWLock
private org.springframework.context.ApplicationContext owningContext
private org.springframework.context.support.GenericApplicationContext serviceContext
private ArrayList<Resource> serviceConfigurations
private boolean isInitialized
private boolean isDestroyed
public void destroy()
throws ServiceException
destroy in interface ServiceServiceException - thrown if there is a problem destroying the servicepublic org.springframework.context.ApplicationContext getApplicationContext()
public String getId()
protected ReadWriteLock getReadWriteLock()
public List<Resource> getServiceConfigurations()
public org.springframework.context.ApplicationContext getServiceContext()
public void initialize()
throws ServiceException
initialize in interface ServiceServiceException - thrown if there is a problem initializing the servicepublic boolean isInitialized()
isInitialized in interface Servicepublic boolean isDestroyed()
isDestroyed in interface Serviceprotected void loadContext()
throws ServiceException
ServiceException - thrown if the configuration for this service could not be loadedprotected abstract void onNewContextCreated(org.springframework.context.ApplicationContext newServiceContext)
throws ServiceException
newServiceContext - the newly created context for the serviceServiceException - thrown if there is a problem with the given service contextpublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext in interface org.springframework.context.ApplicationContextAwarepublic void setBeanName(String name)
setBeanName in interface org.springframework.beans.factory.BeanNameAwareprotected void setInitialized(boolean initialized)
initialized - whether this service has been initializedpublic void setServiceConfigurations(List<Resource> configurations)
configurations - configuration resources for the serviceprotected void setServiceContext(org.springframework.context.support.GenericApplicationContext context)
context - this service's contextCopyright © 1999-2015. All Rights Reserved.