Class AdapterRegistry
- All Implemented Interfaces:
AdapterRegistryMBean
,BaseComponentMBean
-
Field Summary
Fields inherited from interface com.adaptris.core.runtime.AdapterRegistryMBean
JMX_REGISTRY_TYPE, REGISTRY_PREFIX, STANDARD_REGISTRY_JMX_NAME
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAdapter
(AdapterManagerMBean adapterManager) Add anAdapterManagerMBean
instance to the registry.void
void
addManagementComponentInfo
(ManagementComponentInfo componentInfo) Set<com.adaptris.core.runtime.AdapterBuilder>
builders()
Get All the builders.static void
close
(Set<ObjectName> adapterManagers) Convenience method to close a set of adapter managers that usesAdapterComponentMBean.requestClose()
createAdapter
(URLString url) Create an adapter from the given URL.createAdapter
(String xml) Create an adapter from the given string representation.Create an adapter from the given URL.Create the object name representation of the mbean.void
destroyAdapter
(AdapterManagerMBean adapter) Close the underlying adapter and unregister from JMX.void
destroyAdapter
(ObjectName adapterName) Close the underlying adapter and unregister from JMX.static AdapterRegistryMBean
findInstance
(Properties cfg) Get all the adapters that have been registered.Get theAdapterBuilderMBean
associated with givenProperties
object.Get a reference to theAdapterBuilderMBean
instance that built the correspondingAdapterManagerMBean
instance.Get a reference to theAdapterBuilderMBean
instance that built the correspondingAdapterManagerMBean
instance.Get All the builders object names.getClassDefinition
(String className) In JSON format return the full class description, including subclasses and annotation detail.Return theBootstrapProperties
instance that was used to create this registry.getConfigurationURL
(ObjectName adapterName) Get the URL that was used to create the adapter associated with that ObjectName.getConfigurationURLString
(ObjectName adapterName) Get the URL that was used to create the adapter associated with that ObjectName.Will return a Map ofManagementComponentInfo
's.Return the version control system that is currently in use based on RuntimeVersionControl.getImplementationName()void
Persist some data the given URL.void
persistAdapter
(AdapterManagerMBean adapter, URLString url) Persist the adapter to the given URL.void
persistAdapter
(AdapterManagerMBean adapter, String url) Persist the adapter to the given URL.void
persistAdapter
(ObjectName adapter, URLString url) Persist the adapter to the given URL.void
persistAdapter
(ObjectName adapter, String url) Persist the adapter to the given URL.void
putConfigurationURL
(ObjectName adapterName, URLString configUrl) Register a URL against a given ObjectName.void
putConfigurationURL
(ObjectName adapterName, String configUrl) Register a URL against a given ObjectName.void
Register this component (and all children) against the default Platform MBeanServer.Recreate all adapters associated with this AdapterRegistry from their associated bootstrap file.Recreate the adapters associated with the specified objectname from their associated bootstrap file.void
Recreate all adapters associated with this AdapterRegistry from version control.Recreate the adapter associated with the specified objectname from their associated bootstrap file.boolean
removeConfigurationURL
(ObjectName adapterName) Remove the URL that was used to create the adapter associated with the ObjectName.static void
sendShutdownEvent
(Set<ObjectName> adapterManagers) Convenience method for sending a shutdown event for every adapter.void
setManagementComponentInfo
(List<ManagementComponentInfo> managementComponentInfo) Set the list of configured management components.static void
start
(Set<ObjectName> adapterManagers) Convenience method to start a set of adapter managers that usesAdapterComponentMBean.requestStart()
static void
stop
(Set<ObjectName> adapterManagers) Convenience method to close a set of adapter managers that usesAdapterComponentMBean.requestStop()
static void
unregister
(Set<ObjectName> adapterManagers) Convenience method to close a set of adapter managers that usesBaseComponentMBean.unregisterMBean()
void
Unregister this component (and all children) from the default Platform MBeanServer.void
validateConfig
(String config) Attempts to unmarshal the component within this target runtime unit.
-
Method Details
-
findInstance
public static AdapterRegistryMBean findInstance(Properties cfg) throws MalformedObjectNameException, CoreException -
createObjectName
Description copied from interface:BaseComponentMBean
Create the object name representation of the mbean.- Specified by:
createObjectName
in interfaceBaseComponentMBean
- Returns:
- the object name.
-
registerMBean
Description copied from interface:BaseComponentMBean
Register this component (and all children) against the default Platform MBeanServer.- Specified by:
registerMBean
in interfaceBaseComponentMBean
- Throws:
CoreException
- wrapping any exception- See Also:
-
unregisterMBean
Description copied from interface:BaseComponentMBean
Unregister this component (and all children) from the default Platform MBeanServer.- Specified by:
unregisterMBean
in interfaceBaseComponentMBean
- Throws:
CoreException
- wrapping any exception- See Also:
-
getAdapters
Description copied from interface:AdapterRegistryMBean
Get all the adapters that have been registered.- Specified by:
getAdapters
in interfaceAdapterRegistryMBean
- Returns:
- set of ObjectNames that can be looked up in JMX.
-
getConfigurationURL
Description copied from interface:AdapterRegistryMBean
Get the URL that was used to create the adapter associated with that ObjectName.When attempting to persist an adapter instance, you can use this method to query for the URL that was used to create the associated adapter. This will be the URL used to create the adapter initially (i.e. the
adapterConfigURL
that was resolved frombootstrap.properties
) unless the adapter was created with AdapterRegistryMBean.createAdapter(String xml) in the first instance (in which case, you need to figure out where you want to persist the adapter in a different way).Internally, the URLs are keyed against the ObjectName, which means that if create adapters that have the same logical object name, then a URLString will be returned regardless of "how" you created the adapter. So the code below will return
http://my/url
if the two ObjectName instances are considered the same.{ @code ObjectName on = createAdapter(new URLString("http://my/url")); ObjectName on2 = createAdapter("<adapter>...</adapter>"); URLString url = getConfigurationURL(on2); }
- Specified by:
getConfigurationURL
in interfaceAdapterRegistryMBean
- Parameters:
adapterName
- object name representation for the associatedAdapterManagerMBean
- Returns:
- the URL that was used to create the object, or null, if AdapterRegistryMBean.createAdapter(String xml) was used to create a new adapter.
-
getConfigurationURLString
Description copied from interface:AdapterRegistryMBean
Get the URL that was used to create the adapter associated with that ObjectName.When attempting to persist an adapter instance, you can use this method to query for the URL that was used to create the associated adapter. This will be the URL used to create the adapter initially (i.e. the
adapterConfigURL
that was resolved frombootstrap.properties
) unless the adapter was created with AdapterRegistryMBean.createAdapter(String xml) in the first instance (in which case, you need to figure out where you want to persist the adapter in a different way).Internally, the URLs are keyed against the ObjectName, which means that if create adapters that have the same logical object name, then a URL will be returned regardless of "how" you created the adapter. So the code below will return
http://my/url
if the two ObjectName instances are considered the same.ObjectName on = createAdapter(new URL("http://my/url")); ObjectName on2 = createAdapter("<adapter>...</adapter>"); URL url = getConfigurationURL(on2);
- Specified by:
getConfigurationURLString
in interfaceAdapterRegistryMBean
- Parameters:
adapterName
- object name representation for the associatedAdapterManagerMBean
- Returns:
- the URL that was used to create the object, or null, if AdapterRegistryMBean.createAdapter(String xml) was used to create a new adapter.
-
removeConfigurationURL
Description copied from interface:AdapterRegistryMBean
Remove the URL that was used to create the adapter associated with the ObjectName.Note that calling either AdapterRegistryMBean.destroyAdapter(AdapterManagerMBean) or AdapterRegistryMBean.destroyAdapter(ObjectName) will NOT remove the URL from the internal map (as you are likely to invoke those methods to stop/close the adapter prior to creating a new one), so this method is available for you to manually clean up if desired.
- Specified by:
removeConfigurationURL
in interfaceAdapterRegistryMBean
- Parameters:
adapterName
- object name representation for the associatedAdapterManagerMBean
- Returns:
- true if the URL was removed.
-
putConfigurationURL
Description copied from interface:AdapterRegistryMBean
Register a URL against a given ObjectName.Where you have used
AdapterRegistryMBean.createAdapter(String)
; there will not be an URL associated with the newly created adapter. Use this to register a URL against the given ObjectName, which means that AdapterRegistryMBean.getConfigurationURL(ObjectName) will not return a null object.- Specified by:
putConfigurationURL
in interfaceAdapterRegistryMBean
- Parameters:
adapterName
- object name representation for the associatedAdapterManagerMBean
configUrl
- the URL to be stored against the objectname
-
putConfigurationURL
Description copied from interface:AdapterRegistryMBean
Register a URL against a given ObjectName.Where you have used
AdapterRegistryMBean.createAdapter(String)
; there will not be an URL associated with the newly created adapter. Use this to register a URL against the given ObjectName, which means that AdapterRegistryMBean.getConfigurationURL(ObjectName) will not return a null object.- Specified by:
putConfigurationURL
in interfaceAdapterRegistryMBean
- Parameters:
adapterName
- object name representation for the associatedAdapterManagerMBean
configUrl
- the URL to be stored against the objectname- Throws:
IOException
-
persistAdapter
public void persistAdapter(AdapterManagerMBean adapter, URLString url) throws CoreException, IOException Description copied from interface:AdapterRegistryMBean
Persist the adapter to the given URL.- Specified by:
persistAdapter
in interfaceAdapterRegistryMBean
- Parameters:
adapter
- the adapter Manager.url
- the url.- Throws:
CoreException
IOException
-
persistAdapter
public void persistAdapter(AdapterManagerMBean adapter, String url) throws CoreException, IOException Description copied from interface:AdapterRegistryMBean
Persist the adapter to the given URL.- Specified by:
persistAdapter
in interfaceAdapterRegistryMBean
- Parameters:
adapter
- the adapter Manager.url
- the url.- Throws:
CoreException
IOException
-
persistAdapter
Description copied from interface:AdapterRegistryMBean
Persist the adapter to the given URL.- Specified by:
persistAdapter
in interfaceAdapterRegistryMBean
- Parameters:
adapter
- theAdapterManagerMBean
ObjectName.url
- the url.- Throws:
CoreException
IOException
-
persistAdapter
Description copied from interface:AdapterRegistryMBean
Persist the adapter to the given URL.- Specified by:
persistAdapter
in interfaceAdapterRegistryMBean
- Parameters:
adapter
- theAdapterManagerMBean
ObjectName.url
- the url.- Throws:
CoreException
IOException
-
persist
Description copied from interface:AdapterRegistryMBean
Persist some data the given URL.- Specified by:
persist
in interfaceAdapterRegistryMBean
- Parameters:
data
- the data.configUrl
- the url.- Throws:
CoreException
IOException
-
createAdapter
public ObjectName createAdapter(URLString url) throws IOException, MalformedObjectNameException, CoreException Description copied from interface:AdapterRegistryMBean
Create an adapter from the given URL.Create an adapter from the given URL; the license associated with this adapter is one that was derived from
bootstrap.properties
.- Specified by:
createAdapter
in interfaceAdapterRegistryMBean
- Parameters:
url
- the url- Returns:
- the object name representing for the associated
AdapterManagerMBean
- Throws:
IOException
- an error accessing the URL.MalformedObjectNameException
- if there was a problemCoreException
- an error creating the underlying adapter.
-
createAdapterFromUrl
public ObjectName createAdapterFromUrl(String url) throws IOException, MalformedObjectNameException, CoreException Description copied from interface:AdapterRegistryMBean
Create an adapter from the given URL.Create an adapter from the given URL; the license associated with this adapter is one that was derived from
bootstrap.properties
.- Specified by:
createAdapterFromUrl
in interfaceAdapterRegistryMBean
- Parameters:
url
- the url- Returns:
- the object name representing for the associated
AdapterManagerMBean
- Throws:
IOException
- an error accessing the URL.MalformedObjectNameException
- if there was a problemCoreException
- an error creating the underlying adapter.
-
createAdapter
public ObjectName createAdapter(String xml) throws IOException, MalformedObjectNameException, CoreException Description copied from interface:AdapterRegistryMBean
Create an adapter from the given string representation.Create an adapter from the given string; the license associated with this adapter is one that was derived from
bootstrap.properties
.- Specified by:
createAdapter
in interfaceAdapterRegistryMBean
- Parameters:
xml
- the string representation (generally XML).- Returns:
- the object name representing for the associated
AdapterManagerMBean
- Throws:
IOException
- an error accessing the URL.MalformedObjectNameException
- if there was a problem with the objectname.CoreException
- an error creating the underlying adapter.
-
addAdapter
public void addAdapter(AdapterManagerMBean adapterManager) throws MalformedObjectNameException, CoreException Description copied from interface:AdapterRegistryMBean
Add anAdapterManagerMBean
instance to the registry.- Specified by:
addAdapter
in interfaceAdapterRegistryMBean
- Parameters:
adapterManager
- theAdapterManagerMBean
instance.- Throws:
MalformedObjectNameException
- if there was a problem with the objectnameCoreException
- if the objectname already exists in the registry.
-
destroyAdapter
public void destroyAdapter(AdapterManagerMBean adapter) throws CoreException, MalformedObjectNameException Description copied from interface:AdapterRegistryMBean
Close the underlying adapter and unregister from JMX.Note that this uses
AdapterComponentMBean.requestClose()
which will block until the adapter is closed; if a timeout is required, then make sure to useAdapterComponentMBean.requestClose(long)
and possiblyAdapterManagerMBean.forceClose()
before invoking this method.- Specified by:
destroyAdapter
in interfaceAdapterRegistryMBean
- Parameters:
adapter
- theAdapterManagerMBean
.- Throws:
CoreException
- an error accessing the underlying adapter.MalformedObjectNameException
- if there was a problem with the objectname.
-
destroyAdapter
public void destroyAdapter(ObjectName adapterName) throws MalformedObjectNameException, CoreException Description copied from interface:AdapterRegistryMBean
Close the underlying adapter and unregister from JMX.Note that this uses
AdapterComponentMBean.requestClose()
which will block until the adapter is closed; if a timeout is required, then make sure to useAdapterComponentMBean.requestClose(long)
and possiblyAdapterManagerMBean.forceClose()
before invoking this method.- Specified by:
destroyAdapter
in interfaceAdapterRegistryMBean
- Parameters:
adapterName
- theAdapterManagerMBean
.- Throws:
MalformedObjectNameException
- if there was a problem with the objectname.CoreException
- an error accessing the underlying adapter.- See Also:
-
sendShutdownEvent
Convenience method for sending a shutdown event for every adapter.- Parameters:
adapterManagers
- set of managers.
-
start
Convenience method to start a set of adapter managers that usesAdapterComponentMBean.requestStart()
- Parameters:
adapterManagers
- set of managers.- Throws:
CoreException
-
close
Convenience method to close a set of adapter managers that usesAdapterComponentMBean.requestClose()
- Parameters:
adapterManagers
- set of managers.- Throws:
CoreException
- wrapping other exceptions
-
stop
Convenience method to close a set of adapter managers that usesAdapterComponentMBean.requestStop()
- Parameters:
adapterManagers
- set of managers.- Throws:
CoreException
- wrapping other exceptions
-
unregister
Convenience method to close a set of adapter managers that usesBaseComponentMBean.unregisterMBean()
- Parameters:
adapterManagers
- set of managers.- Throws:
CoreException
- wrapping other exceptions
-
getConfiguration
Description copied from interface:AdapterRegistryMBean
Return theBootstrapProperties
instance that was used to create this registry.- Specified by:
getConfiguration
in interfaceAdapterRegistryMBean
- Returns:
- a set of properties.
-
getVersionControl
Description copied from interface:AdapterRegistryMBean
Return the version control system that is currently in use based on RuntimeVersionControl.getImplementationName()- Specified by:
getVersionControl
in interfaceAdapterRegistryMBean
- Returns:
- the version control system that is currently configured for adapter runtime (null if none is available).
-
reloadFromVersionControl
public void reloadFromVersionControl() throws MalformedObjectNameException, CoreException, MalformedURLException, IOExceptionDescription copied from interface:AdapterRegistryMBean
Recreate all adapters associated with this AdapterRegistry from version control.Note that the adapters will not be started as part of this process; this needs to be done separately.
- Specified by:
reloadFromVersionControl
in interfaceAdapterRegistryMBean
- Throws:
MalformedObjectNameException
- if there was a problem with any objectname.CoreException
- an error creating the underlying adapter(s).MalformedURLException
- if there was a problem with the URL found from config.IOException
- if there was a with reading the URL where the adapter is hosted.
-
reloadFromConfig
public Set<ObjectName> reloadFromConfig() throws MalformedObjectNameException, CoreException, MalformedURLException, IOExceptionDescription copied from interface:AdapterRegistryMBean
Recreate all adapters associated with this AdapterRegistry from their associated bootstrap file.Note that the adapters will not be started as part of this process; this needs to be done separately.
- Specified by:
reloadFromConfig
in interfaceAdapterRegistryMBean
- Returns:
- a set of object name representing for the associated
AdapterManagerMBean
instances created. - Throws:
MalformedObjectNameException
- if there was a problem with any objectname.CoreException
- an error creating the underlying adapter(s).MalformedURLException
- if there was a problem with the URL found from config.IOException
- if there was a with reading the URL where the adapter is hosted.
-
reloadFromConfig
public ObjectName reloadFromConfig(ObjectName obj) throws MalformedObjectNameException, CoreException, IOException Description copied from interface:AdapterRegistryMBean
Recreate the adapters associated with the specified objectname from their associated bootstrap file.Note that the adapter will not be started as part of this process; this needs to be done separately.
- Specified by:
reloadFromConfig
in interfaceAdapterRegistryMBean
- Parameters:
obj
- the ObjectName to reload from config.- Returns:
- The ObjectName representing for the associated
AdapterManagerMBean
instances created. - Throws:
MalformedObjectNameException
- if there was a problem with any objectname.CoreException
- an error creating the underlying adapter(s).IOException
- if there was a with reading the URL where the adapter is hosted.MalformedURLException
- if there was a problem with the URL found from config.
-
reloadFromVersionControl
public ObjectName reloadFromVersionControl(ObjectName obj) throws MalformedObjectNameException, CoreException, IOException Description copied from interface:AdapterRegistryMBean
Recreate the adapter associated with the specified objectname from their associated bootstrap file.Note that the adapter will not be started as part of this process; this needs to be done separately.
- Specified by:
reloadFromVersionControl
in interfaceAdapterRegistryMBean
- Parameters:
obj
- the ObjectName to restart.- Returns:
- The ObjectName representing for the associated
AdapterManagerMBean
instances created. - Throws:
MalformedObjectNameException
- if there was a problem with any objectname.CoreException
- an error creating the underlying adapter(s).IOException
- if there was a with reading the URL where the adapter is hosted.MalformedURLException
- if there was a problem with the URL found from config.
-
addConfiguration
- Specified by:
addConfiguration
in interfaceAdapterRegistryMBean
- Throws:
MalformedObjectNameException
CoreException
-
validateConfig
Description copied from interface:AdapterRegistryMBean
Attempts to unmarshal the component within this target runtime unit.This will verify that the component that was configured can be unmarshalled within the target runtime system. It is largely similar to the
AdapterRegistryMBean.createAdapter(String)
method, however it does not try to register a newAdapterManagerMBean
as part of the operation.- Specified by:
validateConfig
in interfaceAdapterRegistryMBean
- Parameters:
config
- the String representation of a component.- Throws:
CoreException
- if there was an exception unmarshalling.- See Also:
-
getClassDefinition
Description copied from interface:AdapterRegistryMBean
In JSON format return the full class description, including subclasses and annotation detail.- Specified by:
getClassDefinition
in interfaceAdapterRegistryMBean
- Parameters:
className
- - fully qualified- Returns:
- JSON class definition.
- Throws:
CoreException
-
getBuilders
Description copied from interface:AdapterRegistryMBean
Get All the builders object names.- Specified by:
getBuilders
in interfaceAdapterRegistryMBean
- Returns:
- all the available builders object names.
-
getBuilder
Description copied from interface:AdapterRegistryMBean
Get a reference to theAdapterBuilderMBean
instance that built the correspondingAdapterManagerMBean
instance.- Specified by:
getBuilder
in interfaceAdapterRegistryMBean
- Parameters:
p
- a reference to theAdapterManagerMBean
- Returns:
- a reference to the
AdapterBuilderMBean
- Throws:
InstanceNotFoundException
- if there was no associated builder.
-
getBuilderMBean
Description copied from interface:AdapterRegistryMBean
Get a reference to theAdapterBuilderMBean
instance that built the correspondingAdapterManagerMBean
instance.- Specified by:
getBuilderMBean
in interfaceAdapterRegistryMBean
- Parameters:
p
- a reference to theAdapterManagerMBean
- Returns:
- a reference to the
AdapterBuilderMBean
- Throws:
InstanceNotFoundException
- if there was no associated builder.
-
getBuilder
Description copied from interface:AdapterRegistryMBean
Get theAdapterBuilderMBean
associated with givenProperties
object.- Specified by:
getBuilder
in interfaceAdapterRegistryMBean
- Throws:
InstanceNotFoundException
-
builders
Description copied from interface:AdapterRegistryMBean
Get All the builders.- Specified by:
builders
in interfaceAdapterRegistryMBean
- Returns:
- all the available builders.
-
addManagementComponentInfo
-
getManagementComponentInfo
Description copied from interface:AdapterRegistryMBean
Will return a Map ofManagementComponentInfo
's. The key to the map is the name of the configured management component.- Specified by:
getManagementComponentInfo
in interfaceAdapterRegistryMBean
- Returns:
- Basic information on configured management components
-
setManagementComponentInfo
Description copied from interface:AdapterRegistryMBean
Set the list of configured management components.- Specified by:
setManagementComponentInfo
in interfaceAdapterRegistryMBean
-