Class TwoPhaseBootstrap<T extends ADEPT2Service>
- java.lang.Object
-
- de.aristaflow.adept2.base.service.AbstractADEPT2Service
-
- de.aristaflow.adept2.base.service.AbstractAuthenticatedService
-
- de.aristaflow.adept2.base.registry.AbstractRegistry
-
- de.aristaflow.adept2.base.registry.PluginRegistry
-
- de.aristaflow.adept2.base.registry.InstanceToInstanceRegistry
-
- de.aristaflow.adept2.base.registry.LocalServiceRegistry
-
- de.aristaflow.adept2.base.registry.ServiceRegistry
-
- de.aristaflow.adept2.core.registry.BootstrapRegistry
-
- de.aristaflow.adept2.core.registry.twophase.TwoPhaseBootstrap<T>
-
- Type Parameters:
T
- The type of the initial service which is provided after the first phase of bootstrapping.
- All Implemented Interfaces:
GlobalInvocationResolver
,GlobalRegistryServiceProvider
,ConfMgrRegistry
,ADEPT2Service
,AuthenticatingService
,LogService
,NameResolution
,ServiceThreadHandling
public class TwoPhaseBootstrap<T extends ADEPT2Service> extends BootstrapRegistry
A bootstrap registry that bootstraps and shuts down in two phases. First the registry is only bootstrapped to retrieve the initial service provided in the constructor. Afterwards the second phase of bootstrapping may continue at any time. Note that the second phase is required before accessing the registry.
The first phase just starts the initial service as well as its required services. Note that the registry cannot be accessed in the first phase since it is not (completely) started. So only basic services may be started in the first phase.
Shutting down may also consist of two inverse phases by usingshutdownToInitialService()
andBootstrapRegistry.shutdown(boolean)
. Shutting down may also be done in one step by just callingBootstrapRegistry.shutdown(boolean)
. Be sure to callBootstrapRegistry.shutdown(boolean)
in afinally
-clause so that it will be done under all circumstances.If no initial service is provided, this registry will just act like the
BootstrapRegistry
, that is first and second phase will be one phase.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.registry.ServiceRegistry
ServiceRegistry.ConfigurationValidator
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.registry.LocalServiceRegistry
LocalServiceRegistry.ServiceExportInformation, LocalServiceRegistry.ServiceNameResolution, LocalServiceRegistry.ServiceStarter
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.registry.PluginRegistry
PluginRegistry.URLClassloaderPrivilegedAction
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.registry.AbstractRegistry
AbstractRegistry.DefaultNameResolution, AbstractRegistry.InstanceInformation, AbstractRegistry.InstantiationMode
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
AbstractADEPT2Service.ActiveSessions
-
-
Field Summary
Fields Modifier and Type Field Description protected Class<T>
initialServiceCls
The class of the initial service.protected String
initialServiceType
The type name of the initial service.-
Fields inherited from class de.aristaflow.adept2.core.registry.BootstrapRegistry
instanceName
-
Fields inherited from class de.aristaflow.adept2.base.registry.ServiceRegistry
clusterName, GLOB_STUB_CACHING_REM_IT_ALIVE_TIME_EXTENSION, GLOB_STUB_CACHING_REM_IT_INIT_ALIVE_TIME, GLOB_STUB_PROXY_ANNOT_CACHE_SIZE, GLOB_STUB_PROXY_LAZY_METHOD_VALID_TIME, globalRegCache, hierInstName, protocolPriority, reexportedServices
-
Fields inherited from class de.aristaflow.adept2.base.registry.LocalServiceRegistry
autoStartServices, failedServices, gsmAvailable, nodeName, release, serviceStarterPool, serviceStartLocker, shuttingDown, startedServices, startingLock, startingRequiredServices, startingService
-
Fields inherited from class de.aristaflow.adept2.base.registry.InstanceToInstanceRegistry
usedInstances
-
Fields inherited from class de.aristaflow.adept2.base.registry.PluginRegistry
declaredPluginTypes, defaultInstances, dynamicPlugins, pluginInstances, runtimePlugins, runtimePluginTypeCLs, singletonPlugins
-
Fields inherited from class de.aristaflow.adept2.base.registry.AbstractRegistry
componentInterfaces, configurationManager, declaredInstances, INIT_INSTANTIATED_OBJECT_METHOD, nameResolution, singletonInstances
-
Fields inherited from class de.aristaflow.adept2.base.service.AbstractAuthenticatedService
CFG_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_USERNAME
-
Fields inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
CONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServices
-
-
Constructor Summary
Constructors Constructor Description TwoPhaseBootstrap(Class<T> initialServiceCls, String initialServiceType, UrlConfigurationManager confMgr, Class<? extends BootstrapRegistry> bootstrapClass)
Creates a new bootstrap registry having the designated configuration manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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
bootstrap()
Bootstraps this registry and therefore the platform.protected GlobalRegistry
continueBootstrap()
Continues the bootstrap.protected T
getInitialService()
Gets the initial service that is provided in the first phase of bootstrapping.void
shutdownToInitialService()
Shuts down all services until the initial service.-
Methods inherited from class de.aristaflow.adept2.core.registry.BootstrapRegistry
getClientService, getRegistry, prepareGlobalSecurityManager, resolveInstanceName, shutdown, terminate
-
Methods inherited from class de.aristaflow.adept2.base.registry.ServiceRegistry
beforeLocalTermination, checkServiceURI, chooseAppropriateURI, createMBeanName, createRegistryWrapper, exportService, getCommunicationService, getGlobalRegistry, getInstanceNameFromServiceURI, getInvocationTarget, getLocallyExportedService, getLocalServiceObject, getService, getService, getServiceInformation, globalRegistryChanged, init, initExportServices, invalidateGlobalRegistry, prepareExport, prioritiseProtocols, readMetaConfiguration, start, unpublishService
-
Methods inherited from class de.aristaflow.adept2.base.registry.LocalServiceRegistry
checkServiceInterface, checkServiceUriSyntax, checkStartupRequiredService, createLocalServiceURI, determineNodeName, getAndCheckRequiredService, getConfiguredPlugin, getGlobalSequence, getInstantiationMode, getRegistry, getSecurityManager, getServiceForInstance, notifyDataSourceToConfMgr, registryActive, renewConfiguration, startLocalService, syncExecute, terminateService
-
Methods inherited from class de.aristaflow.adept2.base.registry.InstanceToInstanceRegistry
getUsedComponentInstanceNameForInstance, getUsedObjectForInstance
-
Methods inherited from class de.aristaflow.adept2.base.registry.PluginRegistry
createPluginLoader, getConfiguredPlugin, getConfiguredPlugin, getConfiguredPlugins, getConfiguredPluginTypes, prepareRuntimePlugin, readMetaConfiguration
-
Methods inherited from class de.aristaflow.adept2.base.registry.AbstractRegistry
checkAndStoreProvidedObject, checkConfiguration, checkImplementingClass, checkSupertype, createInstanceForInterface, getAppropriateMethod, getArbitrarilyNamedObject, getComponentType, getFormattedSignature, getHierarchicalInstanceName, getInstanceInformation, getInterfaceForComponentType, getNames, getObjectForInstanceName, getObjectForInstanceName, getObjectForInstanceName, getSimpleInstanceName, initialiseInstantiatedObject
-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractAuthenticatedService
_sessionActive, authenticateService, awaitActiveSessions, createChildSession, createSession, getAgent, getSessionFactory, getStartupRequired, getTopLevelAgent, getUserCredentials, globalSecurityManagerAvailable, isEarlyService, sessionHasAllCapabilities, sessionHasAllTopLevelCapabilities, sessionHasCapability, sessionHasOneCapability, sessionHasOneTopLevelCapability
-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
_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, unprivilegeThread
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.aristaflow.adept2.base.service.ADEPT2Service
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, ping, preShutdown
-
-
-
-
Field Detail
-
initialServiceCls
protected final Class<T extends ADEPT2Service> initialServiceCls
The class of the initial service.
-
initialServiceType
protected final String initialServiceType
The type name of the initial service.
-
-
Constructor Detail
-
TwoPhaseBootstrap
public TwoPhaseBootstrap(Class<T> initialServiceCls, String initialServiceType, UrlConfigurationManager confMgr, Class<? extends BootstrapRegistry> bootstrapClass) throws AbortServiceException
Creates a new bootstrap registry having the designated configuration manager. Before creating the registry, the root configuration will be validated against the designated class. If an initial service is provided (via its class and component type name), this registry bootstraps in two phases. In the first phase only the initial service will be retrieved. This will start all services required by the initial service but not the registry itself.- Parameters:
initialServiceCls
- The class of the initial service. If this isnull
, this registry will act like the normalBootstrapRegistry
.initialServiceType
- The type name of the initial service. If this isnull
or the empty string, this registry will act like the normalBootstrapRegistry
.confMgr
- The initial configuration manager that provides the root configuration and configurations for the loaded component instances.bootstrapClass
- The class the root configuration is validated against the configuration description. Use this class unless you have a subclass that has its own configuration description.- Throws:
AbortServiceException
- If the initialisation or starting of the registry fails, anAbortServiceException
will be thrown. If the registry configuration is invalid, aConfigurationException
will be thrown.
-
-
Method Detail
-
autoStartServices
protected void autoStartServices() throws AbortServiceException
Description copied from class:LocalServiceRegistry
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.- Overrides:
autoStartServices
in classServiceRegistry
- Throws:
AbortServiceException
- If there are problems preparing the security manager or starting one of the services to be automatically started, anAbortServiceException
will be thrown.
-
getInitialService
protected T getInitialService()
Gets the initial service that is provided in the first phase of bootstrapping.- Returns:
- The initial service that is provided in the first phase of
bootstrapping or
null
if no initial service is specified.
-
bootstrap
protected void bootstrap() throws AbortServiceException
Description copied from class:BootstrapRegistry
Bootstraps this registry and therefore the platform. The registry is initialised with either the configured URI or a local URI with the instance name. Afterwards the registry is started.- Overrides:
bootstrap
in classBootstrapRegistry
- Throws:
AbortServiceException
- If the initialisation or starting of the registry fails, anAbortServiceException
will be thrown.
-
continueBootstrap
protected GlobalRegistry continueBootstrap() throws AbortServiceException
Continues the bootstrap. This will autostart the services of the superclass.- Returns:
- The global registry which provides access to public services.
- Throws:
AbortServiceException
- If there are problems preparing the security manager or starting one of the services to be automatically started, anAbortServiceException
will be thrown.- See Also:
ServiceRegistry.autoStartServices()
-
shutdownToInitialService
public void shutdownToInitialService()
Shuts down all services until the initial service. This can then be used before shutting down completely.
-
-