Class InstanceToInstanceRegistry
- 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
-
- All Implemented Interfaces:
ConfMgrRegistry
,ADEPT2Service
,AuthenticatingService
,LogService
,NameResolution
,ServiceThreadHandling
- Direct Known Subclasses:
LocalServiceRegistry
,ModelFactoryRegistry
@ConfigurationDescription(properties=) public abstract class InstanceToInstanceRegistry extends PluginRegistry
This class extends the plugin registry to support the retrieval of used component instances without needing to know the used instance name at all. This name is set in the corresponding configuration. For instance, it can be configured, that the instance "PM1" of a process manager should use instance "DM1" of a DataManager. This is configured by:PM1.DataManager = DM1
. "PM1" can retrieve the corresponding by callinggetUsedObjectForInstance(session, "/ProcessManager/PM1", "DataManager", DataManager.class)
.
The used component type has to be managed by the registry.The used component can be configured for all instances of the using type by configuring it:
ProcessManager.LogManager = LM1
. This configuration is used, in case no specific one for the using instance is found. If a usage relation is omitted, the default instance (seePluginRegistry
) will be used.This class parses the following properties from the registry configuration - besides the properties parsed by super classes:
- Instances.<ComponentType> (
ConfigurationConstants.PREFIX_PROPERTY_REGISTRY_INSTANCES
) - <InstanceName>.<UsedComponentType> (including anonymous instance: <ComponentType>.<UsedComponentType>)
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.registry.PluginRegistry
PluginRegistry.ConfigurationValidator, 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 Map<String,Map<String,String>>
usedInstances
The usage relations for instances.-
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 Modifier Constructor Description protected
InstanceToInstanceRegistry(UrlConfigurationManager confMgr, org.apache.commons.configuration2.Configuration configuration, Registry registry)
Constructs a new registry supporting instance to instance relations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
getUsedComponentInstanceNameForInstance(String usingInstance, String usedComponentType)
Returns the hierarchical name of the instance of the designated type for usage by the designated instance (specified by its instance name).protected <T> T
getUsedObjectForInstance(String usingInstance, String usedComponentType, Class<T> requestedType)
Gets an object for use by the the designated component instance which conforms to the designated component type (usedComponentType
) and is of the requested type.protected void
renewConfiguration(org.apache.commons.configuration2.Configuration conf)
Renews the configuration of this registry by renewing via the superclass and reading of usage relations.-
Methods inherited from class de.aristaflow.adept2.base.registry.PluginRegistry
createPluginLoader, getConfiguredPlugin, getConfiguredPlugin, getConfiguredPlugin, getConfiguredPlugins, getConfiguredPluginTypes, prepareRuntimePlugin, readMetaConfiguration, shutdown
-
Methods inherited from class de.aristaflow.adept2.base.registry.AbstractRegistry
checkAndStoreProvidedObject, checkConfiguration, checkImplementingClass, checkSupertype, createInstanceForInterface, getAppropriateMethod, getArbitrarilyNamedObject, getComponentType, getFormattedSignature, getHierarchicalInstanceName, getInstanceInformation, getInstantiationMode, getInterfaceForComponentType, getNames, getObjectForInstanceName, getObjectForInstanceName, getObjectForInstanceName, getSimpleInstanceName, init, initialiseInstantiatedObject, readMetaConfiguration
-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractAuthenticatedService
_sessionActive, authenticateService, awaitActiveSessions, createChildSession, createSession, getAgent, getSecurityManager, 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, start, 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, start
-
-
-
-
Constructor Detail
-
InstanceToInstanceRegistry
protected InstanceToInstanceRegistry(UrlConfigurationManager confMgr, org.apache.commons.configuration2.Configuration configuration, Registry registry) throws ConfigurationException
Constructs a new registry supporting instance to instance relations. It calls the constructor ofPluginRegistry
which sets the registry configuration, the configuration manager and the logger.- Parameters:
confMgr
- The initial configuration manager that provides configurations for the loaded component instances.configuration
- The configuration of the registry.registry
- The parent registry of this registry.- Throws:
ConfigurationException
- If the password cannot be parsed from the configuration, aConfigurationException
will be thrown.
-
-
Method Detail
-
renewConfiguration
protected void renewConfiguration(org.apache.commons.configuration2.Configuration conf) throws ConfigurationException
Renews the configuration of this registry by renewing via the superclass and reading of usage relations.- Overrides:
renewConfiguration
in classPluginRegistry
- Parameters:
conf
- The (new) root configuration for this registry.- Throws:
ConfigurationException
- If- mandatory properties are missing (
PropertyNotSetException
), - the class or interface of a type can not be found,
- the instance is not configured properly (implementing class),
ConfigurationException
will be thrown.- mandatory properties are missing (
-
getUsedObjectForInstance
protected <T> T getUsedObjectForInstance(String usingInstance, String usedComponentType, Class<T> requestedType) throws ConfigurationException
Gets an object for use by the the designated component instance which conforms to the designated component type (usedComponentType
) and is of the requested type. The instantiation mode of the used component is obeyed. If the instantiation mode is not set, singleton will be used.
In case of a singleton instance, an existing object will be returned. For instantiating a new object, a constructor with the configuration (Configuration
) will be used.
If the configuration does not contain a reference to an instance of the used component type, the appropriate anonymous instance will be returned.- Type Parameters:
T
- The type which the requested object is expected to be of which is either the registered component type or a super type hereof.- Parameters:
usingInstance
- The hierarchical name of the using component instance. Use the component type if the instance name is not defined. Use the empty string if the instance name is unknown.usedComponentType
- The component type of the instance to be retrieved for usage. This may neither be null nor the empty string.requestedType
- The type of which the requested object is expected to be. This is either the registered component type interface or a super type hereof.- Returns:
- An object of the designated component type which is either the configured named instance or the appropriate anonymous instance.
- Throws:
ConfigurationException
- If- no component interface is registered/configured for the designated component type,
- the usage relation or the used component type is not configured properly
- the configured used instance is not declared or not configured properly,
- the instantiation mode is set to off,
- the configuration of the used instance does not provide required configuration values,
- the creation or the initialisation of the instance fails,
ConfigurationException
will be thrown.- See Also:
AbstractRegistry.getObjectForInstanceName(String, Class, Class[], Object[])
-
getUsedComponentInstanceNameForInstance
protected String getUsedComponentInstanceNameForInstance(String usingInstance, String usedComponentType) throws ConfigurationException
Returns the hierarchical name of the instance of the designated type for usage by the designated instance (specified by its instance name). If no usage relation is found, the anonymous instance is returned for usage.- Parameters:
usingInstance
- The hierarchical name of the component instance for which to retrieve the used component instance. Use the empty string if the instance name is not defined.usedComponentType
- The component type to retrieve an instance name for. This may neither be null nor the empty string.- Returns:
- The hierarchical name of the configured instance or the default instance of the used component type to be used by the designated using component instance.
- Throws:
ConfigurationException
- If there is no used component name found particularly even no default instance, aConfigurationException
will be thrown.
-
-