public abstract class BaseServiceBroker extends Object implements ServiceBroker
ServiceBroker
which
provides:
Services
with a configuration based on
system wide configuration mechanism.Modifier and Type | Field and Description |
---|---|
static String |
CLASSNAME_SUFFIX
A
Service property determining its implementing
class name . |
static String |
SERVICE_PREFIX
A prefix for
Service properties in
TurbineResource.properties. |
Modifier | Constructor and Description |
---|---|
protected |
BaseServiceBroker()
Default constructor, protected as to only be usable by subclasses.
|
Modifier and Type | Method and Description |
---|---|
String |
getApplicationRoot()
Get the application root as set by
the parent application.
|
org.apache.commons.configuration2.Configuration |
getConfiguration()
Get the configuration for this service manager.
|
org.apache.commons.configuration2.Configuration |
getConfiguration(String name)
Returns the configuration for the specified service.
|
protected Object |
getNonLocalService(String name)
Get a non-local service managed by a TurbineServiceProvider.
|
Object |
getService(String name)
Returns an instance of requested Service.
|
protected Service |
getServiceInstance(String name)
Retrieves an instance of a Service without triggering late
initialization.
|
Iterator<String> |
getServiceNames()
Returns an Iterator over all known service names.
|
Iterator<String> |
getServiceNames(String prefix)
Returns an Iterator over all known service names beginning with
the provided prefix.
|
Object |
getServiceObject(String name)
Get an application specific service object.
|
void |
init()
Initialize this service manager.
|
protected void |
initMapping()
Creates a mapping between Service names and class names.
|
void |
initService(String name)
Performs early initialization of specified service.
|
void |
initServices()
Performs early initialization of all services.
|
void |
initServices(boolean report)
Performs early initialization of all services.
|
protected boolean |
isLocalService(String name)
Determines if the requested service is managed by this
ServiceBroker.
|
protected boolean |
isNonLocalService(String name)
Determines if the requested service is managed by an initialized
TurbineServiceProvider.
|
boolean |
isRegistered(String serviceName)
Determines whether a service is registered in the configured
TurbineResources.properties . |
void |
setApplicationRoot(String applicationRoot)
Set the application root.
|
void |
setConfiguration(org.apache.commons.configuration2.Configuration configuration)
Set the configuration object for the services broker.
|
void |
setServiceObject(String name,
Object value)
Set an application specific service object
that can be used by application specific
services.
|
void |
shutdownService(String name)
Shuts down a
Service , releasing resources
allocated by an Service , and returns it to its
initial (uninitialized) state. |
void |
shutdownServices()
Shuts down all Turbine services, releasing allocated resources and
returning them to their initial (uninitialized) state.
|
public static final String SERVICE_PREFIX
Service
properties in
TurbineResource.properties.public static final String CLASSNAME_SUFFIX
Service
property determining its implementing
class name .protected BaseServiceBroker()
public void setConfiguration(org.apache.commons.configuration2.Configuration configuration)
configuration
- Broker configuration.public org.apache.commons.configuration2.Configuration getConfiguration()
public void init() throws InitializationException
InitializationException
- if the initialization failspublic void setServiceObject(String name, Object value)
name
- name of service objectvalue
- value of service objectpublic Object getServiceObject(String name)
name
- the name of the service objectprotected void initMapping() throws InitializationException
services.MyService.classname=com.mycompany.MyServiceImpl services.MyOtherService.classname=com.mycompany.MyOtherServiceImpl
InitializationException
- if a service class could not be foundpublic boolean isRegistered(String serviceName)
TurbineResources.properties
.isRegistered
in interface ServiceBroker
serviceName
- The name of the service whose existence to check.public Iterator<String> getServiceNames()
public Iterator<String> getServiceNames(String prefix)
prefix
- The prefix against which to test.public void initService(String name) throws InitializationException
initService
in interface ServiceBroker
name
- The name of the service (generally the
SERVICE_NAME
constant of the service's interface
definition).InitializationException
- Initialization of this
service was not successful.public void initServices()
public void initServices(boolean report) throws InstantiationException, InitializationException
report
- true
if you want exceptions thrown.InstantiationException
- if the service could not be instantiatedInitializationException
- if the service could not be initializedpublic void shutdownService(String name)
Service
, releasing resources
allocated by an Service
, and returns it to its
initial (uninitialized) state.shutdownService
in interface ServiceBroker
name
- The name of the Service
to be
uninitialized.public void shutdownServices()
shutdownServices
in interface ServiceBroker
public Object getService(String name) throws InstantiationException
getService
in interface ServiceBroker
name
- The name of the Service requested.InstantiationException
- if the service is unknown or
can't be initialized.protected Service getServiceInstance(String name) throws InstantiationException
name
- The name of the service requested.InstantiationException
- The service is unknown or
can't be initialized.public org.apache.commons.configuration2.Configuration getConfiguration(String name)
getConfiguration
in interface ServiceBroker
name
- The name of the service.public void setApplicationRoot(String applicationRoot)
applicationRoot
- application rootpublic String getApplicationRoot()
getApplicationRoot
in interface ServiceBroker
protected boolean isLocalService(String name)
name
- The name of the Service requested.protected boolean isNonLocalService(String name)
name
- The name of the Service requested.protected Object getNonLocalService(String name) throws InstantiationException
name
- The name of the Service requested.InstantiationException
- the service couldn't be instantiatedCopyright © 2000–2019 The Apache Software Foundation. All rights reserved.