@ConfigurationDescription(properties={@Property(name="MultiThreadedServiceStartPoolSize",type=INT,defaultValue="0",description="The amount of threads that will be used for theconcurrent service start. The value \'0\' means, that the services are started sequentially. For a server at least 20 threads are needed, for a client at least 10 threads are needed."),,,},validator=LocalServiceRegistry.ConfigurationValidator.class) public abstract class LocalServiceRegistry extends InstanceToInstanceRegistry
InstanceToInstanceRegistry to support service components.
Service components fulfil a service interface that
supports a whole lifecycle (initialisation, starting, shutting down).
Additionally services may be exported, that is, they may be available to
other services outside of their own JVM. However, the local service registry
only handles local services which are not exported and only have local
addresses (URI).
The components managed by this registry must implement
ADEPT2Service. This is checked when creating a local service
registry. Additionally they need to have a public constructor accepting their
configuration (org.apache.commons.configuration2.Configuration)
as well as a wrapper for this registry (Registry). The
constructor should not do much; the initialisation should take place in the
corresponding method. It is
guaranteed that every service is initialised, started and shutdown exactly
once. Additionally, the constructor, ADEPT2Service.init(URI[], URI[])
and ADEPT2Service.start() are called by the same thread.
Services are singletons. This is checked and enforced. Besides these, there
are no further issues for services; they behave like normal components as
described in the super classes of this LocalServiceRegistry.
This also includes the configuration of the services.
Services may require other services for their initialisation and/or execution. Therefore when starting a service, its startup-required services are also started. This applies recursively until a service does not rely on other services. The starting may happen concurrently or sequentially depending on the configuration of this registry. Please note that initialisation, starting and export of a service (including the same with the startup-required services) is performed with a lock based on the session to meet the exactly once-semantic. Since there are no cyclic dependencies there may not be deadlocks.
When shutting down, the services are shut down in the reverse order of their start. This registry will shutdown immediately when starting if one of the auto start services fails to start.
If a critical exception occurs (AbortServiceException when creating,
initialising or starting a service while starting this registry, the starting
will be aborted and already started services will be shut down. This applies
for instance to services required by the registry or autostart services.
This class parses the following (boolean) property from its configuration (in the constructor) - besides the properties parsed by super classes:
ConfigurationConstants.SERVICE_MULTI_THREAD_SERVICE_START_POOL_SIZE )ConfigurationConstants.SERVICE_AUTOSTART_SERVICES )| Modifier and Type | Class and Description |
|---|---|
static class |
LocalServiceRegistry.ConfigurationValidator
Checks the configuration of the
ServiceRegistry. |
protected static class |
LocalServiceRegistry.ServiceExportInformation
ServiceExportInformation encapsulates the data which is
needed for exporting a service, which is:
the services for exporting a service (ADEPT2ServiceExport),
the URIs under which the service is exported and which correspond
based on the position in the array to the export service,
whether the service is to be published at the global registry. |
protected class |
LocalServiceRegistry.ServiceNameResolution
The class used to provide a service load graph with the necessary service
data (names of used services and specific service objects.
|
protected static interface |
LocalServiceRegistry.ServiceStarter
This interface is used for starting services which requires a start routine
(
Callable.call()) and the service name (LocalServiceRegistry.ServiceStarter.getServiceName()) for
logging purpose. |
PluginRegistry.URLClassloaderPrivilegedActionAbstractRegistry.DefaultNameResolution, AbstractRegistry.InstanceInformation, AbstractRegistry.InstantiationModeAbstractADEPT2Service.ActiveSessions| Modifier and Type | Field and Description |
|---|---|
protected java.util.Set<java.lang.String> |
autoStartServices
The names of the services to start when starting this registry.
|
protected java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Throwable> |
failedServices
All services that failed to start, mapping from name to the exception that occurred when
starting.
|
protected boolean |
gsmAvailable
Whether the global security manager is available now.
|
protected java.lang.String |
nodeName
The unique name of the node this registry and the using service belong to.
|
protected SerialisablePair<java.lang.String,java.lang.String> |
release
The release of the bootstrap registry.
|
protected java.util.concurrent.ExecutorService |
serviceStarterPool
A thread-pool service for starting services concurrently.
|
protected boolean |
shuttingDown
Signals when this registry is shutting down and must not start any further
service.
|
protected java.util.Stack<Pair<java.lang.String,ADEPT2Service>> |
startedServices
All started services (hierarchical service name and service), pushed on the
stack in order of their start.
|
protected java.util.Map<java.lang.String,java.util.concurrent.locks.Lock> |
startingLock
While starting and while checking for started, a service a write lock is
needed.
|
protected java.lang.ThreadLocal<java.util.Stack<java.lang.String[]>> |
startingRequiredServices
The names of the startup required services declared by the service which is
currently started by the corresponding thread.
|
protected java.lang.ThreadLocal<java.util.Stack<java.lang.String>> |
startingService
The hierarchical name of the service which is currently started by the
corresponding thread.
|
usedInstancesdeclaredPluginTypes, defaultInstances, dynamicPlugins, pluginInstances, runtimePlugins, runtimePluginTypeCLs, singletonPluginscomponentInterfaces, configurationManager, declaredInstances, INIT_INSTANTIATED_OBJECT_METHOD, nameResolution, singletonInstancesCFG_EARLY_SERVICEAUTH_ORGPOSID, CFG_EARLY_SERVICEAUTH_ORGPOSNAME, CFG_EARLY_SERVICEAUTH_PASSWORD, CFG_EARLY_SERVICEAUTH_USERNAME, CFG_SERVICEAUTH_ORGPOSID, CFG_SERVICEAUTH_ORGPOSNAME, CFG_SERVICEAUTH_PASSWORD, CFG_SERVICEAUTH_USERNAMECONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServices| Modifier | Constructor and Description |
|---|---|
protected |
LocalServiceRegistry(UrlConfigurationManager confMgr,
Configuration configuration,
Registry registry)
Constructs a new local service registry by calling the super constructor.
|
protected |
LocalServiceRegistry(UrlConfigurationManager confMgr,
Configuration configuration,
Registry registry,
SerialisablePair<java.lang.String,java.lang.String> release)
Constructs a new service registry by calling the super constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
autoStartServices()
Prepares the global security manager, authenticates this registry, provides
the data sources for the runtime configurations to the configuration
manager if appropriate, and starts all services to be automatically started
at startup of this registry.
|
protected void |
checkServiceInterface(java.lang.String serviceName,
ADEPT2Service service)
Checks whether the designated service object does fulfill the
ADEPT2Service-interface appropriately. |
protected void |
checkServiceURI(SessionToken session,
java.net.URI serviceURI)
Validates whether the designated URI is local, well-formed and may identify
a service instance.
|
protected void |
checkServiceUriSyntax(java.net.URI serviceUri)
Validates whether the designated URI is well-formed and may identify a
service instance.
|
protected void |
checkStartupRequiredService(java.lang.String serviceName)
Checks whether the current thread is starting a service right now and
whether this service has declared the designated service as a
startup-required service type.
|
protected java.net.URI |
chooseAppropriateURI(java.net.URI[] serviceURIs)
Chooses an appropriate URI, that is a local URI or null in case no local
URI is found.
|
protected java.net.URI |
createLocalServiceURI(java.lang.String instanceName)
Creates a local (i.e. not for remote usage) service URI for a given service
instance name.
|
protected javax.management.ObjectName |
createMBeanName(java.lang.String serviceName)
Creates the name for the designated service to be available as MBean.
|
protected Registry |
createRegistryWrapper(java.lang.String serviceName,
boolean earlyService,
InstanceToInstanceRegistry mfRegistry,
ModelViewerProvider mvProvider)
Creates a
Registry which is a wrapper for this registry including the service
name. |
static java.lang.String |
determineNodeName(java.util.logging.Logger logger)
Determines and returns a unique name for the current platform/cluster node.
|
protected void |
exportService(SessionToken session,
java.lang.String serviceName,
ADEPT2Service service,
LocalServiceRegistry.ServiceExportInformation serviceExportInformation)
Exports and publishes the designated service (in case of an exported
service) using the designated service export objects and the designated
URIs if appropriate.
|
protected java.lang.String |
getAndCheckRequiredService(SessionToken session,
java.lang.String usingService,
java.lang.String usedServiceTypeName)
Gets the name of the used service of the designated type and for the
designated using service.
|
protected <T> T |
getConfiguredPlugin(SessionToken session,
java.lang.String usingInstanceName,
java.lang.Object usingInstance,
java.lang.String pluginTypeName,
java.lang.Class<T> componentType,
java.lang.String pluginInstanceName,
java.lang.Class<?>[] additionalParameterTypes,
java.lang.Object[] additionalParameterValues)
Retrieves the plugin with the designated name of the designated type if it
is declared by the using instance or if it is declared and found as runtime
plugin.
|
protected java.util.concurrent.atomic.AtomicLong |
getGlobalSequence(java.lang.String seqName)
Gets the sequence with the designated name.
|
protected java.lang.String |
getInstanceNameFromServiceURI(java.net.URI serviceURI)
Returns the hierarchical instance name from the service URI.
|
protected AbstractRegistry.InstantiationMode |
getInstantiationMode(java.lang.String serviceType,
java.lang.String simpleName,
Configuration registryConfiguration)
Overridden to log non-singleton services.
|
protected <T extends ADEPT2Service> |
getLocalServiceObject(SessionToken session,
java.lang.String serviceName,
java.lang.Class<T> requestedType)
Returns an instance of the designated service and of the requested type.
|
protected <T extends AbstractRegistry> |
getRegistry(SessionToken session,
java.lang.String registryTypeName,
java.lang.Class<T> registryType)
Gets a registry (as service and therefore singleton) for the specified type
name of the specified type, for instance
RuntimeRegistry. |
protected SecurityManager |
getSecurityManager()
Returns a security manager for this registry.
|
<T extends ADEPT2Service> |
getService(SessionToken session,
java.lang.String serviceName,
java.lang.Class<T> serviceType)
Initialises, starts and exports (not relevant in this registry but in
subclasses) the designated local service as well as the services that are
startup-required by the designated service.
|
<T extends ADEPT2Service> |
getService(SessionToken session,
java.net.URI[] serviceURIs,
java.lang.Class<T> serviceType)
Retrieves the service described by the URIs of which one has to be a local
one.
|
protected <T extends ADEPT2Service> |
getServiceForInstance(SessionToken session,
java.lang.String usingService,
java.lang.String usedServiceTypeName,
java.lang.Class<T> usedServiceType)
Returns a completely initialised and started service which has been
configured to be used by the
usingService for the service
type usedServiceTypeName and is of (object) type
usedServiceType. |
protected ServiceInformation |
getServiceInformation(java.lang.String instanceName)
Returns the information (component type, instantiation mode, implementation
class, service URI, export service instances and whether to publish the
service) for the designated service instance.
|
void |
init(java.net.URI[] localExportedUris,
java.net.URI[] globalExportedUris)
Checking all component interfaces to implement ADEPT2Service and reads the
own configuration.
|
protected void |
notifyDataSourceToConfMgr(boolean gsmAvailable)
Sets the registry in the configuration manager allowing it to access the data source for
runtime configurations.
|
protected LocalServiceRegistry.ServiceExportInformation |
prepareExport(SessionToken session,
java.lang.String serviceName,
ADEPT2Service service)
Prepares the export by creating a local URI for initialisation of the
service.
|
protected abstract GlobalSecurityManager |
prepareGlobalSecurityManager()
Prepares the security manager that is, the global security manager will be
retrieved (and started) if necessary.
|
protected void |
readMetaConfiguration(Configuration registryConfiguration,
java.lang.String serviceType,
java.lang.String simpleInstanceName)
Reads the meta information from the registry for the designated service
instance, which is:
the implementing class or the implementing object for a local service
The instantiation mode of a service is always
AbstractRegistry.InstantiationMode.SINGLETON
If something else is set in the configuration (please note that this
property may also - and in this case should - be omitted), a warning
message is logged and SINGLETON used instead. |
boolean |
registryActive()
Gets whether this registry is active, that is, it has signalled its start
and is not being shut down.
|
protected void |
renewConfiguration(Configuration conf)
Renews the configuration of this registry by renewing via the superclass
and reading of usage relations.
|
void |
shutdown(boolean emergency)
Shut down all started services.
|
void |
start()
Starts the services (and the corresponding required services that this
registry should start when it is itself started.
|
protected void |
startLocalService(SessionToken session,
java.lang.String serviceName,
ADEPT2Service service,
de.aristaflow.adept2.base.registry.ServiceLoadGraph loadGraph)
Initialises, starts and exports (not relevant in this registry but in
subclasses) the designated local service as well as the services that are
startup-required by the designated service.
|
protected void |
syncExecute(LocalServiceRegistry.ServiceStarter[] startServices)
Submits the designated
ServiceStarters to an executor service
and waits for them to complete. |
protected void |
terminate(boolean emergency,
java.lang.String hierServName)
Terminates all started services or until the designated service and signals
the shutdown of this registry.
|
protected void |
terminateService(boolean emergency,
java.lang.String serviceName,
ADEPT2Service service)
Terminates the designated service.
|
protected void |
unpublishService(SessionToken session,
java.lang.String serviceName,
ADEPT2Service service)
Removes the designated service from the global registry and from the
service exports.
|
getUsedComponentInstanceNameForInstance, getUsedObjectForInstancecreatePluginLoader, getConfiguredPlugin, getConfiguredPlugin, getConfiguredPlugins, prepareRuntimePlugin, readMetaConfigurationcheckAndStoreProvidedObject, checkConfiguration, checkImplementingClass, checkSupertype, createInstanceForInterface, getAppropriateMethod, getArbitrarilyNamedObject, getComponentType, getFormattedSignature, getHierarchicalInstanceName, getInstanceInformation, getInterfaceForComponentType, getObjectForInstanceName, getObjectForInstanceName, getObjectForInstanceName, getSimpleInstanceName, initialiseInstantiatedObject_sessionActive, authenticateService, awaitActiveSessions, createChildSession, createSession, getAgent, getSessionFactory, getStartupRequired, getTopLevelAgent, getUserCredentials, globalSecurityManagerAvailable, isEarlyService, sessionHasCapability_sessionFinished, activeOrInvalidServiceStateException, changeLogContext, changeLogContext, changeLogContext, consoleLog, csvLoggingEnabled, getClassSpecificJulLogger, getDependencyRegistry, getLocalUris, getLogger, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, isActive, isSessionActive, isShutdown, logMethodEntry, logMethodEntry, logMethodEntry, logMethodExit, logMethodExit, ping, preShutdown, privilegeSession, privilegeThread, revertLogContextChanges, sessionActive, sessionActive, sessionActive, sessionActive, sessionFinished, sessionFinished, signalShutdown, signalStart, unprivilegeThreadclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, ping, preShutdownprotected final java.lang.String nodeName
protected final java.util.Set<java.lang.String> autoStartServices
protected final java.util.Stack<Pair<java.lang.String,ADEPT2Service>> startedServices
protected final java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Throwable> failedServices
protected volatile boolean shuttingDown
protected final transient java.util.Map<java.lang.String,java.util.concurrent.locks.Lock> startingLock
protected java.util.concurrent.ExecutorService serviceStarterPool
protected final java.lang.ThreadLocal<java.util.Stack<java.lang.String>> startingService
protected final java.lang.ThreadLocal<java.util.Stack<java.lang.String[]>> startingRequiredServices
protected final SerialisablePair<java.lang.String,java.lang.String> release
protected transient boolean gsmAvailable
protected LocalServiceRegistry(UrlConfigurationManager confMgr, Configuration configuration, Registry registry) throws ConfigurationException
configuration - The configuration of the created local service registry instance.confMgr - The initial configuration manager that provides configurations for the loaded
component instances.registry - The parent registry of this registry.ConfigurationException - If the password cannot be parsed from the configuration, a
ConfigurationException will be thrown.protected LocalServiceRegistry(UrlConfigurationManager confMgr, Configuration configuration, Registry registry, SerialisablePair<java.lang.String,java.lang.String> release) throws ConfigurationException
configuration - The configuration of the created service registry instance.confMgr - The initial configuration manager that provides configurations for the loaded
component instances.registry - The parent registry of this registry. This can be null when
invoked by subclasses. But then a release has to be provided.release - The release of the bootstrap registry.ConfigurationException - If the password cannot be parsed from the configuration, a
ConfigurationException will be thrown.protected <T> T getConfiguredPlugin(SessionToken session, java.lang.String usingInstanceName, java.lang.Object usingInstance, java.lang.String pluginTypeName, java.lang.Class<T> componentType, java.lang.String pluginInstanceName, java.lang.Class<?>[] additionalParameterTypes, java.lang.Object[] additionalParameterValues) throws ConfigurationException
PluginRegistryConfiguration and the class/interface of the
using instance) will be called providing the designated additional
parameter values (besides its configuration and the using instance).getConfiguredPlugin in class PluginRegistryT - The type which the used object is expected to be of.session - The session which is used to check for access rights on this
method.usingInstanceName - The hierarchical name of the using component
instance. This may neither be null nor the empty.usingInstance - The using component instance which is provided in the
constructor of the requested plugin to allow for data exchange.pluginTypeName - The component type of the plugin instance to be
retrieved for usage. This may neither be null nor the empty
string.componentType - The type which the used object is expected to be of.pluginInstanceName - The simple (!) name of the plugin instance to
retrieve.additionalParameterTypes - Additional parameter types (besides
Configuration and the class/interface of the using
instance) of the constructor to be used for instantiation. If no
additional parameter is to be used, an empty array will need to be
provided. This has to correspond to
additionalParameterValues.additionalParameterValues - Additional parameter (besides the
configuration and the using instance) of the constructor to be
used for instantiation. If no additional parameter is to be used,
an empty array will need to be provided. This has to correspond to
additionalParameterTypes.ConfigurationException - If
AbstractRegistry.getInstanceInformation(String))AbstractRegistry.getInstanceInformation(String)),AbstractRegistry.componentInterfaces),AbstractRegistry.getInstanceInformation(String)),ConfigurationException will be thrown.protected void renewConfiguration(Configuration conf) throws ConfigurationException
InstanceToInstanceRegistryrenewConfiguration in class InstanceToInstanceRegistryconf - The (new) root configuration for this registry.ConfigurationException - If
PropertyNotSetException),ConfigurationException will be thrown.protected void readMetaConfiguration(Configuration registryConfiguration, java.lang.String serviceType, java.lang.String simpleInstanceName) throws ConfigurationException
AbstractRegistry.InstantiationMode.SINGLETON
If something else is set in the configuration (please note that this
property may also - and in this case should - be omitted), a warning
message is logged and SINGLETON used instead.readMetaConfiguration in class AbstractRegistryregistryConfiguration - The configuration which contains the
(registry) information for the designated instance.serviceType - The type of the component to retrieve the
meta-configuration.simpleInstanceName - The simple name of the component instance as
declared in the configuration.ConfigurationException - If
ADEPT2Service,ConfigurationException will be thrown.protected AbstractRegistry.InstantiationMode getInstantiationMode(java.lang.String serviceType, java.lang.String simpleName, Configuration registryConfiguration)
getInstantiationMode in class AbstractRegistryserviceType - The type of the component to retrieve the
meta-configuration.simpleName - The simple name of the component instance as
declared in the configuration.registryConfiguration - The configuration which contains the declaration of
the instantiation mode.InstantiationMode.SINGLETON.protected LocalServiceRegistry.ServiceExportInformation prepareExport(SessionToken session, java.lang.String serviceName, ADEPT2Service service) throws AbortServiceException
session - The session which is used to check for access rights on this
method.serviceName - The name of the service to prepare the export of.service - The service object to prepare the export of.ServiceExportInformation-instance containing an
empty service export array and a local URI.ConfigurationException - If the service type of the designated
service (retrieved from the service name) is not known by this
registry, a ConfigurationException will be thrown.
This exception will never be thrown by this implementation.AbortServiceException - If the preparation of the service export
fails, an AbortServiceException will be thrown. This
exception will never be thrown by this implementation.InvalidServiceStateException - If
this registry failed to start or is shut down, an
InvalidServiceStateException will be thrown.protected void exportService(SessionToken session, java.lang.String serviceName, ADEPT2Service service, LocalServiceRegistry.ServiceExportInformation serviceExportInformation) throws AbortServiceException
This implementation does nothing and is only for extension in subclasses.
session - The session which is used to check for access rights on this
method.serviceName - The hierarchical instance name of the service.service - The service object to export.serviceExportInformation - The information on the export services and
the URIs to use.ConfigurationException - If the service type of the designated
service (retrieved from the service name) is not known by this
registry, a ConfigurationException will be thrown.
This exception will never thrown by this implementation.AbortServiceException - If exporting the service fails, an
AbortServiceException will be thrown. This exception
will never thrown by this implementation.protected void unpublishService(SessionToken session, java.lang.String serviceName, ADEPT2Service service)
This implementation does nothing and is only for extension in subclasses.
session - The session which is used to check for access rights on this
method.serviceName - The hierarchical instance name of the service to remove
from the global registry.service - The service object to remove from the global registry and
the service exports.protected void syncExecute(LocalServiceRegistry.ServiceStarter[] startServices) throws java.util.concurrent.ExecutionException, AbortServiceException
ServiceStarters to an executor service
and waits for them to complete. If an exception or an interrupt occurs, all
starters will be cancelled (if not already finished) and the exception will
be forwarded.startServices - Callables to start services.java.util.concurrent.ExecutionException - If there is an exception (not an
AbortServiceException) while executing a
Callable, an ExecutionException will be
thrown.AbortServiceException - If the waiting thread is interrupted, an
AbortServiceException will be thrown. If one of the
awaited services fails to start with an
AbortServiceException (encapsulated in an
ExecutionException), this will be forwarded.protected void startLocalService(SessionToken session, java.lang.String serviceName, ADEPT2Service service, de.aristaflow.adept2.base.registry.ServiceLoadGraph loadGraph) throws AbortServiceException
ADEPT2Service.getStartupRequiredServices() does not. This is only
for better performance. session - The session which is used to check for access rights on this
method.serviceName - The hierarchical instance name of the service.service - The service which is to be started.loadGraph - A graph containing the transitive dependencies of the
services. It is used for determining the startup-required services
since it does already ignore started services (unlike
ADEPT2Service.getStartupRequiredServices()).AbortServiceException - If
AbortServiceException
while initialised or started,ADEPT2Service-interface appropriately,AbortServiceException will be thrown.InvalidServiceStateException - If
this registry failed to start or is shut down, an
InvalidServiceStateException will be thrown.protected void autoStartServices()
throws AbortServiceException
AbortServiceException - If there are problems preparing the security
manager or starting one of the services to be automatically
started, an AbortServiceException will be thrown.public <T extends ADEPT2Service> T getService(SessionToken session, java.lang.String serviceName, java.lang.Class<T> serviceType) throws ServiceNotKnownException
checkStartupRequiredService(String)).
T - The type which the requested service is expected to be of which
is a subtype of ADEPT2Service and either the
registered service type or a super type hereof.session - The session which is used to check for access rights on this
method.serviceName - The hierarchical instance name of the service.serviceType - The type of which the requested service is expected to
be. This is a subtype of ADEPT2Service and either
the registered service type interface or a super type hereof.ServiceNotKnownException - If
ADEPT2Service-interface appropriately, ServiceNotKnownException will be thrown. This may
encapsulate a ConfigurationException or an
AbortServiceException.InvalidServiceStateException - If
this registry failed to start or is shut down, an
InvalidServiceStateException will be thrown.public <T extends ADEPT2Service> T getService(SessionToken session, java.net.URI[] serviceURIs, java.lang.Class<T> serviceType) throws ServiceNotKnownException
checkStartupRequiredService(String)). T - The type which the requested service is expected to be of. This
is a subtype of ADEPT2Service and either the
registered service type or a super type hereof.session - The session which is used to check for access rights on this
method.serviceURIs - The URIs of the service to be retrieved, the array has
to contain at least one valid service URI.serviceType - The type of which the requested service is expected to
be.NullArgumentException - If one of the parameters is null, a
NullArgumentException will be thrown.ServiceNotKnownException - If
ADEPT2Service-interface appropriately, ServiceNotKnownException will be thrown. This may
encapsulate a ConfigurationException or an
AbortServiceException.InvalidServiceStateException - If
this registry failed to start or is shut down, an
InvalidServiceStateException will be thrown.java.lang.IllegalArgumentException - If the service URI is invalid, an
IllegalArgumentException will be thrown.protected <T extends ADEPT2Service> T getServiceForInstance(SessionToken session, java.lang.String usingService, java.lang.String usedServiceTypeName, java.lang.Class<T> usedServiceType) throws ServiceNotKnownException
usingService for the service
type usedServiceTypeName and is of (object) type
usedServiceType. T - The type which the requested service is expected to be of. This
is a subtype of ADEPT2Service and either the
registered service type or a super type hereof.session - The session which is used to check for access rights on this
method.usingService - The hierarchical instance name of the using service.usedServiceTypeName - The name of the type the used component is of.
This is the name of the registered service type.usedServiceType - The (object) type of which the requested service is
expected to be.InvalidServiceStateException - If
this registry failed to start or is shut down, an
InvalidServiceStateException will be thrown.ServiceNotKnownException - If
ADEPT2Service-interface appropriately, ServiceNotKnownException will be thrown. This may
encapsulate a ConfigurationException or an
AbortServiceException.InvalidServiceStateException - If
this registry failed to start or is shut down, an
InvalidServiceStateException will be thrown.java.lang.IllegalArgumentException - If a local service is requested and the
designated service type interface is not the registered service
type interface or a super type hereof, an
IllegalArgumentException will be thrown.getAndCheckRequiredService(SessionToken, String, String)protected <T extends AbstractRegistry> T getRegistry(SessionToken session, java.lang.String registryTypeName, java.lang.Class<T> registryType) throws ServiceNotKnownException
RuntimeRegistry.
The registry will be loaded by the class loader of the/this
bootstrap-registry. T - The type which the requested registry is expected to be of which
is either the registered registry type or a super type hereof.session - The session which is used to check for access rights on this
method.registryTypeName - The (simple) type name of the registry to be
retrieved.registryType - The type of which the requested registry is expected to
be. This is either the registered registry type interface or a
super type hereof.ServiceNotKnownException - If
ServiceNotKnownException will be thrown. This may
encapsulate a ConfigurationException or an
AbortServiceException.InvalidServiceStateException - If
this registry failed to start or is shut down, an
InvalidServiceStateException will be thrown.protected void terminateService(boolean emergency,
java.lang.String serviceName,
ADEPT2Service service)
emergency - Whether it is an emergency shutdown.serviceName - The hierarchical name of the service which to terminate.service - The service instance which to terminate.public void init(java.net.URI[] localExportedUris,
java.net.URI[] globalExportedUris)
throws AbortServiceException
AbstractRegistry.init(URI[], URI[])) before initialising and starting
services. These services are allowed to access the registry and expect it
be started!init in interface ADEPT2Serviceinit in class AbstractRegistrylocalExportedUris - The URIs with which this service is exported
locally or a local URI or an empty array for internal services.globalExportedUris - The URIs with which this service is published
globally or null in case the service is not
published.AbortServiceException - If
ADEPT2Service (
AbstractRegistry.checkSupertype(String, Class, Class)),AbstractRegistry.checkConfiguration(Configuration, String, Class)),ConfigurationException will be thrown.public void start()
throws AbortServiceException
start in interface ADEPT2Servicestart in class AbstractADEPT2ServiceAbortServiceException - If preparing the security manager or starting
an auto start service fails, the registry will be shut down and
an AbortServiceException will be thrown, whereas in
case of a wrapped ConfigurationException or
AbortServiceException the exceptions will be
unwrapped.public void shutdown(boolean emergency)
shutdown in interface ADEPT2Serviceshutdown in class AbstractRegistryemergency - Whether the shutdown will be an emergency shutdown.protected void terminate(boolean emergency,
java.lang.String hierServName)
null as service
name.emergency - Whether it is an emergency shutdown.hierServName - The hierarchical name of the service until which to
shutdown all services started later. If this is null,
all services and the registry will be shut down.protected ServiceInformation getServiceInformation(java.lang.String instanceName) throws ConfigurationException
AbstractRegistry.getInstanceInformation(String) but with the more specific return
type ServiceInformation.instanceName - The hierarchical name of the service instance for which
to retrieve its information.ConfigurationException - If the designated instance is not configured
properly, that is, it is not declared, a
ConfigurationException will be thrown.protected abstract GlobalSecurityManager prepareGlobalSecurityManager() throws ServiceNotKnownException
ServiceNotKnownException - If the security manager could not be
retrieved, a ServiceNotKnownException will be
thrown. The registry must not continue starting in this case!!protected SecurityManager getSecurityManager()
getSecurityManager in class AbstractAuthenticatedServiceprotected java.util.concurrent.atomic.AtomicLong getGlobalSequence(java.lang.String seqName)
seqName - The name of the sequence. This name is arbitrary but should be shared among the
services that share the sequence.protected Registry createRegistryWrapper(java.lang.String serviceName, boolean earlyService, InstanceToInstanceRegistry mfRegistry, ModelViewerProvider mvProvider)
Registry which is a wrapper for this registry including the service
name. It provides convenient access to a registry without the need for the service name and/or
session tokens. The created Registry is afterwards provided in the constructor of
a service which is currently created.serviceName - The hierarchical name of the service for which to create a registry wrapper.earlyService - Whether the service is an early service for which initially only the local
security manager is available.mfRegistry - The model factory registry to be used by the designated registry wrapper.mvProvider - The provider for model view, that are classes providing type-safe access to
plugin data. This is usually the model factory registry.Registry
-interface.protected java.net.URI createLocalServiceURI(java.lang.String instanceName)
instanceName - The hierarchical name of the service instance.protected javax.management.ObjectName createMBeanName(java.lang.String serviceName)
throws javax.management.MalformedObjectNameException
serviceName - The name of the service which to register as MBean.javax.management.MalformedObjectNameException - If the designated service name cannot be formatted as a
valid MBean name, a MalformedObjectNameException will be thrown.protected <T extends ADEPT2Service> T getLocalServiceObject(SessionToken session, java.lang.String serviceName, java.lang.Class<T> requestedType) throws ConfigurationException
ConfigurationException will be thrown. AbstractRegistry.getObjectForInstanceName(String, Class, Class[], Object[]).T - The type which the requested service is expected to be of which
is a subtype of ADEPT2Service and either the
registered service type or a super type hereof.session - The session which is used to check for access rights on this
method.serviceName - The hierarchical instance name of the service.requestedType - The type of which the requested object is expected to
be. This is a subtype of ADEPT2Service and either
the registered service type interface or a super type hereof.ConfigurationException - If
ConfigurationException will be thrown
(encapsulating an AbortServiceException in case the
registry could not be loaded).InvalidServiceStateException - If
this registry failed to start or is shut down, an
InvalidServiceStateException will be thrown.protected void checkStartupRequiredService(java.lang.String serviceName)
ThreadLocals set when starting a service.serviceName - The hierarchical instance name of requested required
service.protected java.lang.String getAndCheckRequiredService(SessionToken session, java.lang.String usingService, java.lang.String usedServiceTypeName) throws ConfigurationException
ADEPT2Service, it will be checked whether the used service
is declared as required (startup- as well as runtime-required). If it is
not required, a QA-notice will be logged.session - The session which is used to check for access rights on this
method.usingService - The hierarchical instance name of the using service.usedServiceTypeName - The name of the type the used service is of.
This is the name of the registered service type.ConfigurationException - If
ConfigurationException will be thrown.InvalidServiceStateException - If
this registry failed to start or is shut down, an
InvalidServiceStateException will be thrown.protected void checkServiceInterface(java.lang.String serviceName,
ADEPT2Service service)
throws ConfigurationException
ADEPT2Service-interface appropriately. This includes returning
arrays that are not null for required services and URIs.serviceName - The name of the service of which to check the interface.service - The service object of which to check the interface.ConfigurationException - If the designated service does not fulfill
the ADEPT2Service-interface appropriately, a
ConfigurationException will be thrown.protected void checkServiceURI(SessionToken session, java.net.URI serviceURI) throws ServiceNotKnownException
session - The session which is used to check for access rights on this
method.serviceURI - The local URI to check for validity.ServiceNotKnownException - If the schema of the designated URI does
not specify a known communication service, a
ServiceNotKnownException will be thrown. This
exception will never thrown by this implementation.java.lang.IllegalArgumentException - If the service URI is invalid, an
IllegalArgumentException will be thrown.protected void checkServiceUriSyntax(java.net.URI serviceUri)
serviceUri - The URI to check for validity.java.lang.IllegalArgumentException - If the service URI is invalid, an
IllegalArgumentException will be thrown.protected java.net.URI chooseAppropriateURI(java.net.URI[] serviceURIs)
serviceURIs - A list of service URIs with which a service is exported.protected java.lang.String getInstanceNameFromServiceURI(java.net.URI serviceURI)
throws ServiceNotKnownException
Whenever the instance name needs to be derived from a services URI, this method should be called. This keeps the way, how the instance name is stored in the URI more exchangeable.
serviceURI - The service URI.ServiceNotKnownException - If the schema of the designated URI does
not specify a known communication service, a
ServiceNotKnownException will be thrown. This
exception will never thrown by this implementation.protected void notifyDataSourceToConfMgr(boolean gsmAvailable)
gsmAvailable - Whether the global security manager has become available. This makes the
check for the availability of the data source unnecessary.public boolean registryActive()
public static java.lang.String determineNodeName(java.util.logging.Logger logger)
logger - The logger where to log information messages on creating the node name.