public class AristaFlowPlatform
extends java.lang.Object
// create and bootstrap
AristaFlowPlatform aristaFlow = new AristaFlow();
try
{
// access the platform, usually via aristaFlow.getClientService();
...
}
finally
{
// terminate the platform
aristaFlow.terminate();
}
With this simple bootstrapping, the configuration is expected as files in
specified configuration directories and all global properties (e. g. the
configuration directories) are expected as system properties. To allow for
more sophisticated provision of the configuration and the properties, there
are several different constructors. The global properties can be set via a
ConfigurationPropertyProvider which in turn can retrieve the
properties arbitrarily, e. g. from a servlet configuration. A configuration
can be provided directly which can either be combined with the configuration
from the configuration directories. Or it can be a complete configuration not
requiring any additional configuration. For the latter just do not provide
any configuration directories via the provider (or system properties).
Bootstrapping can also be a two-step procedure: Create an instance of the
AristaFlowPlatform using one of the constructors accepting a
eager parameter. This will prepare the root configuration of the
platform. You may then access and manipulate
this. Afterwards bootstrap() the platform which will respect your
configuration changes. The eager-flag specifies whether to
provide a complete root configuration by loading and integrating all
externally referenced configuration files. Use it to get the complete
configuration and not just the basic one. But note that eager loading will
take some time.
// create
AristaFlowPlatform aristaFlow = new AristaFlow(true);
try
{
Configuration conf = aristaFlow.getRootConfiguration();
// manipulate the configuration
...
// bootstrap
aristaFlow.bootstrap();
// access the platform, usually via aristaFlow.getClientService();
...
}
finally
{
// terminate the platform
aristaFlow.terminate();
}
The two-step bootstrapping should only be used for highly sophisticated
requirements, e. g. you need to decide on existing configuration values which
other values you need to set. For providing configuration values from outside
the configuration files, just use a constructor with integrated bootstrapping
(without the eager parameter) accepting a configuration.
The configuration even allows for injection of complete service objects. These services need a normal configuration specifying the data for the registry (component type, whether to export, instantiation mode). Instead of providing an implementation class, the corresponding configuration value can also be directly the corresponding instance. With this, for instance, you can inject a servlet context when running in a servlet container, thus allowing the platform to access the servlet container.
Note that only one platform should be running at the same time in one JVM. However, you can terminate the platform and restart it by creating a new instance and bootstrapping it.
| Modifier and Type | Field and Description |
|---|---|
protected UrlConfigurationManager |
confMgr
The configuration manager used for the bootstrapped platform.
|
| Modifier | Constructor and Description |
|---|---|
|
AristaFlowPlatform()
Bootstraps AristaFlow using system properties which also provide the
configuration directories (or the default
. |
|
AristaFlowPlatform(boolean eager)
Partially bootstraps AristaFlow using system properties which also provide
the configuration directories (or the default
. |
|
AristaFlowPlatform(boolean eager,
Configuration conf)
Partially bootstraps AristaFlow using system properties which also provide
the configuration directories (or the default
. |
|
AristaFlowPlatform(boolean eager,
Configuration conf,
ConfigurationPropertyProvider provider)
Partially bootstraps AristaFlow using the designated properties which also
provide the configuration directories or URLs to load the root
configuration from additionally to the designated configuration.
|
|
AristaFlowPlatform(boolean eager,
ConfigurationPropertyProvider provider)
Partially bootstraps AristaFlow using the designated properties which also
provide the configuration directories or URLs to load the root
configuration from.
|
|
AristaFlowPlatform(Configuration conf)
Bootstraps AristaFlow using system properties which also provide the
configuration directories or URLs to load the root configuration from
additionally to the designated configuration.
|
|
AristaFlowPlatform(Configuration conf,
ConfigurationPropertyProvider provider)
Bootstraps AristaFlow using the designated properties which also provide
the configuration directories or URLs to load the root configuration from
additionally to the designated configuration.
|
|
AristaFlowPlatform(ConfigurationPropertyProvider provider)
Bootstraps AristaFlow using the designated properties which also provide
the configuration directories or URLs to load the root configuration from.
|
protected |
AristaFlowPlatform(java.lang.String rootConfFileName,
Configuration providedConfiguration,
boolean eager,
boolean singleton,
ConfigurationPropertyProvider provider)
Initialises the global properties and logging and creates a configuration
manager.
|
| Modifier and Type | Method and Description |
|---|---|
void |
bootstrap()
Bootstraps the AristaFlow platform, that is, the initial services are started
based on the root configuration from the configuration manager.
|
protected void |
bootstrap(boolean dump)
Creates a new bootstrap registry and initialises and starts it.
|
protected BootstrapRegistry |
createBootstrapRegistry(UrlConfigurationManager cMgr)
Creates a new bootstrap registry having the designated configuration
manager.
|
protected UrlConfigurationManager |
createConfigurationManager(java.lang.String rootConfFileName,
Configuration providedConfiguration,
boolean eager,
ConfigurationPropertyProvider provider,
LoggerManager loggerManager)
Gets a configuration manager having the designated file (file name without
path) as root configuration and/or the designated configuration.
|
protected BootstrapRegistry |
getBootstrapRegistry() |
ClientService |
getClientService()
Gets the client service providing convenient access to the services
provided by the platform and needed by client components.
|
Registry |
getRegistry()
Gets the wrapper for access to the platform via the
Registry
-interface. |
Configuration |
getRootConfiguration()
Gets the root configuration used for this AristaFlow platform.
|
void |
terminate()
Terminates the platform by shutting down the bootstrap registry.
|
protected void |
terminateSafely()
Terminates this platform safely, that is, all used services are terminated
but they are not expected to be initialised.
|
protected UrlConfigurationManager confMgr
null after termination.public AristaFlowPlatform()
throws AbortServiceException
./conf) or URLs to
load the root configuration from.ConfigurationException - If
ConfigurationException will be thrown.AbortServiceException - If the platform has already been bootstrapped
or the initialisation or starting of the registry fails, an
AbortServiceException will be thrown.public AristaFlowPlatform(ConfigurationPropertyProvider provider) throws AbortServiceException
provider - The provider for the global properties including the
configuration directories to load the root configuration from.ConfigurationException - If
ConfigurationException will be thrown.AbortServiceException - If the platform has already been bootstrapped
or the initialisation or starting of the registry fails, an
AbortServiceException will be thrown.public AristaFlowPlatform(Configuration conf) throws AbortServiceException
./conf) will be used.conf - The configuration to be integrated with the set configuration
directories or URLs or a complete root configuration.ConfigurationException - If
ConfigurationException will be thrown.AbortServiceException - If the platform has already been bootstrapped
or the initialisation or starting of the registry fails, an
AbortServiceException will be thrown.public AristaFlowPlatform(Configuration conf, ConfigurationPropertyProvider provider) throws AbortServiceException
conf - The configuration to be integrated with the set configuration
directories or URLs or a complete root configuration.provider - The provider for the global properties including the
configuration directories to load additional configurations for
the root configuration from.ConfigurationException - If
ConfigurationException will be thrown.AbortServiceException - If the platform has already been bootstrapped
or the initialisation or starting of the registry fails, an
AbortServiceException will be thrown.public AristaFlowPlatform(boolean eager)
throws ConfigurationException
./conf) or URLs
to load the root configuration from. eager - Whether to (transitively) load all referenced configuration
files for the root configuration.ConfigurationException - If
ConfigurationException will be thrown.public AristaFlowPlatform(boolean eager,
ConfigurationPropertyProvider provider)
throws ConfigurationException
eager - Whether to (transitively) load all referenced configuration
files for the root configuration.provider - The provider for the global properties including the
configuration directories to load the root configuration from.ConfigurationException - If
ConfigurationException will be thrown.public AristaFlowPlatform(boolean eager,
Configuration conf)
throws ConfigurationException
./conf) or URLs
to load the root configuration from additionally to the designated
configuration. eager - Whether to (transitively) load all referenced configuration
files for the root configuration.conf - The configuration to be integrated with the set configuration
directories or URLs or a complete root configuration.ConfigurationException - If
ConfigurationException will be thrown.public AristaFlowPlatform(boolean eager,
Configuration conf,
ConfigurationPropertyProvider provider)
throws ConfigurationException
eager - Whether to (transitively) load all referenced configuration
files for the root configuration.conf - The configuration to be integrated with the set configuration
directories or URLs or a complete root configuration.provider - The provider for the global properties including the
configuration directories to load additional configurations for
the root configuration from.ConfigurationException - If
ConfigurationException will be thrown.protected AristaFlowPlatform(java.lang.String rootConfFileName,
Configuration providedConfiguration,
boolean eager,
boolean singleton,
ConfigurationPropertyProvider provider)
throws ConfigurationException
rootConfFileName - The name of the file (relative to the configuration
directory/directories) containing the root configuration that is
searched for in the configuration directories specified by the
designated provider. This may be null but then the
designated configuration has to be a complete root configuration.providedConfiguration - The configuration provided when bootstrapping.
This may either be a complete root configuration (without
additional configuration directories), a delta configuration
complementing or overriding the configurations from the
configuration directories or even null. If this is
null, only configurations from the configuration
directories will be used but this requires a valid
rootConfFileName.eager - Whether to (transitively) load all referenced configuration
files for the root configuration.singleton - Whether this platform should be singleton or allow
multiple instantiations of the platform. Usually singleton (
true) is the best, with multiple instantiations the
global properties and the configuration may be arbitrary since
they rely on static methods and fields.provider - The provider for the global properties including the
configuration directories to load additional configurations for
the root configuration from. This must not be null.ConfigurationException - If
ConfigurationException will be thrown.protected UrlConfigurationManager createConfigurationManager(java.lang.String rootConfFileName, Configuration providedConfiguration, boolean eager, ConfigurationPropertyProvider provider, LoggerManager loggerManager) throws ConfigurationException
rootConfFileName - The name of the file (relative to the configuration
directory/directories) containing the root configuration that is
searched for in the configuration directories specified by the
designated provider. This may be null but then the
designated configuration has to be a complete root configuration.providedConfiguration - The configuration provided when bootstrapping.
This may either be a complete root configuration (without
additional configuration directories), a delta configuration
complementing or overriding the configurations from the
configuration directories or even null. If this is
null, only configurations from the configuration
directories will be used but this requires a valid
rootConfFileName.eager - Whether to (transitively) load all referenced configuration
files for the root configuration.provider - The provider for the global properties including the
configuration directories to load additional configurations for
the root configuration from. This must not be null.loggerManager - The logger manager providing and configuring the
loggers for the platform. Logging is initialised right after the
root configuration has been initialised.ConfigurationException - If
ConfigurationException will be thrown.protected BootstrapRegistry createBootstrapRegistry(UrlConfigurationManager cMgr) throws AbortServiceException
cMgr - The initial configuration manager that provides the root
configuration and configurations for the loaded component
instances.ConfigurationException - If the registry configuration is invalid, a
ConfigurationExceptionwill be thrown.AbortServiceException - If the initialisation or starting of the
registry fails, an AbortServiceException will be
thrown.public final Configuration getRootConfiguration()
null after
terminating.protected void bootstrap(boolean dump)
throws AbortServiceException
dump - Whether the configuration manager should dump the root
configuration after bootstrapping. This also reflects the changes
that may have been applied between initialising the configuration
manager and bootstrapping.ConfigurationException - If there are problems loading the externally
referenced configuration files for dumping, a
ConfigurationException will be thrown.AbortServiceException - If the platform has already been
bootstrapped, the initialisation or starting of the registry
fails or the platform has already been terminated, an
AbortServiceException will be thrown.public void bootstrap()
throws AbortServiceException
ConfigurationException - If there are problems loading the externally
referenced configuration files for dumping, a
ConfigurationException will be thrown.AbortServiceException - If the platform has already been bootstrapped
or the initialisation or starting of the registry fails, an
AbortServiceException will be thrown.public ClientService getClientService() throws AbortServiceException
ServiceNotKnownException - If there are problems retrieving the
client service, a ServiceNotKnownException will be
thrown.AbortServiceException - If the platform has not been bootstrapped or
terminated, an AbortServiceException will be thrown.public Registry getRegistry() throws AbortServiceException
Registry
-interface. This is used by (server) services to access the registry.
Clients should always use an appropriate client
service. Only use this registry for very special purposes.ServiceNotKnownException - If there are problems loading the model
factory registry, a ServiceNotKnownException will be
thrown.AbortServiceException - If the platform has not been bootstrapped or
terminated, an AbortServiceException will be thrown.protected void terminateSafely()
public void terminate()
protected BootstrapRegistry getBootstrapRegistry() throws AbortServiceException
AbortServiceException