public class AdapterRegistry extends java.lang.Object implements AdapterRegistryMBean
JMX_REGISTRY_TYPE, REGISTRY_PREFIX, STANDARD_REGISTRY_JMX_NAME
Modifier and Type | Method and Description |
---|---|
void |
addAdapter(AdapterManagerMBean adapterManager)
Add an
AdapterManagerMBean instance to the registry. |
void |
addConfiguration(java.util.Properties cfg) |
void |
addManagementComponentInfo(ManagementComponentInfo componentInfo) |
static void |
close(java.util.Set<javax.management.ObjectName> adapterManagers)
Convenience method to close a set of adapter managers that uses
AdapterComponentMBean.requestClose() |
javax.management.ObjectName |
createAdapter(java.lang.String xml)
Create an adapter from the given string representation.
|
javax.management.ObjectName |
createAdapter(URLString url)
Create an adapter from the given URL.
|
javax.management.ObjectName |
createAdapterFromUrl(java.lang.String url)
Create an adapter from the given URL.
|
javax.management.ObjectName |
createObjectName()
Create the object name representation of the mbean.
|
void |
destroyAdapter(AdapterManagerMBean adapter)
Close the underlying adapter and unregister from JMX.
|
void |
destroyAdapter(javax.management.ObjectName adapterName)
Close the underlying adapter and unregister from JMX.
|
static AdapterRegistryMBean |
findInstance(java.util.Properties cfg) |
java.util.Set<javax.management.ObjectName> |
getAdapters()
Get all the adapters that have been registered.
|
javax.management.ObjectName |
getBuilder(javax.management.ObjectName p)
Get a reference to the
AdapterBuilderMBean instance that built the corresponding AdapterManagerMBean instance. |
AdapterBuilderMBean |
getBuilder(java.util.Properties p)
Get the
AdapterBuilderMBean associated with given Properties object. |
AdapterBuilderMBean |
getBuilderMBean(javax.management.ObjectName p)
Get a reference to the
AdapterBuilderMBean instance that built the corresponding AdapterManagerMBean instance. |
java.util.Set<javax.management.ObjectName> |
getBuilders()
Get All the builders.
|
java.lang.String |
getClassDefinition(java.lang.String className)
In JSON format return the full class description, including subclasses and annotation detail.
|
java.util.Properties |
getConfiguration()
Return the
BootstrapProperties instance that was used to create this registry. |
URLString |
getConfigurationURL(javax.management.ObjectName adapterName)
Get the URL that was used to create the adapter associated with that ObjectName.
|
java.lang.String |
getConfigurationURLString(javax.management.ObjectName adapterName)
Get the URL that was used to create the adapter associated with that ObjectName.
|
java.util.List<ManagementComponentInfo> |
getManagementComponentInfo()
Will return a Map of
ManagementComponentInfo 's. |
java.lang.String |
getVersionControl()
Return the version control system that is currently in use based on
RuntimeVersionControl.getImplementationName()
|
void |
persist(java.lang.String data,
URLString configUrl)
Persist some data the given URL.
|
void |
persistAdapter(AdapterManagerMBean adapter,
java.lang.String url)
Persist the adapter to the given URL.
|
void |
persistAdapter(AdapterManagerMBean adapter,
URLString url)
Persist the adapter to the given URL.
|
void |
persistAdapter(javax.management.ObjectName adapter,
java.lang.String url)
Persist the adapter to the given URL.
|
void |
persistAdapter(javax.management.ObjectName adapter,
URLString url)
Persist the adapter to the given URL.
|
void |
putConfigurationURL(javax.management.ObjectName adapterName,
java.lang.String configUrl)
Register a URL against a given ObjectName.
|
void |
putConfigurationURL(javax.management.ObjectName adapterName,
URLString configUrl)
Register a URL against a given ObjectName.
|
void |
registerMBean()
Register this component (and all children) against the default Platform MBeanServer.
|
java.util.Set<javax.management.ObjectName> |
reloadFromConfig()
Recreate all adapters associated with this AdapterRegistry from their associated bootstrap file.
|
javax.management.ObjectName |
reloadFromConfig(javax.management.ObjectName obj)
Recreate the adapters associated with the specified objectname from their associated bootstrap file.
|
void |
reloadFromVersionControl()
Recreate all adapters associated with this AdapterRegistry from version control.
|
javax.management.ObjectName |
reloadFromVersionControl(javax.management.ObjectName obj)
Recreate the adapter associated with the specified objectname from their associated bootstrap file.
|
boolean |
removeConfigurationURL(javax.management.ObjectName adapterName)
Remove the URL that was used to create the adapter associated with the ObjectName.
|
static void |
sendShutdownEvent(java.util.Set<javax.management.ObjectName> adapterManagers)
Convenience method for sending a shutdown event for every adapter.
|
void |
setManagementComponentInfo(java.util.List<ManagementComponentInfo> managementComponentInfo)
Set the list of configured management components.
|
static void |
start(java.util.Set<javax.management.ObjectName> adapterManagers)
Convenience method to start a set of adapter managers that uses
AdapterComponentMBean.requestStart() |
static void |
stop(java.util.Set<javax.management.ObjectName> adapterManagers)
Convenience method to close a set of adapter managers that uses
AdapterComponentMBean.requestStop() |
static void |
unregister(java.util.Set<javax.management.ObjectName> adapterManagers)
Convenience method to close a set of adapter managers that uses
BaseComponentMBean.unregisterMBean() |
void |
unregisterMBean()
Unregister this component (and all children) from the default Platform MBeanServer.
|
void |
validateConfig(java.lang.String config)
Attempts to unmarshal the component within this target runtime unit.
|
public static AdapterRegistryMBean findInstance(java.util.Properties cfg) throws javax.management.MalformedObjectNameException, CoreException
javax.management.MalformedObjectNameException
CoreException
public javax.management.ObjectName createObjectName()
BaseComponentMBean
createObjectName
in interface BaseComponentMBean
public void registerMBean() throws CoreException
BaseComponentMBean
registerMBean
in interface BaseComponentMBean
CoreException
- wrapping any exceptionManagementFactory.getPlatformMBeanServer()
public void unregisterMBean() throws CoreException
BaseComponentMBean
unregisterMBean
in interface BaseComponentMBean
CoreException
- wrapping any exceptionManagementFactory.getPlatformMBeanServer()
public java.util.Set<javax.management.ObjectName> getAdapters()
AdapterRegistryMBean
getAdapters
in interface AdapterRegistryMBean
public URLString getConfigurationURL(javax.management.ObjectName adapterName)
AdapterRegistryMBean
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 from
bootstrap.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); }
getConfigurationURL
in interface AdapterRegistryMBean
adapterName
- object name representation for the associated AdapterManagerMBean
public java.lang.String getConfigurationURLString(javax.management.ObjectName adapterName)
AdapterRegistryMBean
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 from bootstrap.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);
getConfigurationURLString
in interface AdapterRegistryMBean
adapterName
- object name representation for the associated AdapterManagerMBean
public boolean removeConfigurationURL(javax.management.ObjectName adapterName)
AdapterRegistryMBean
Note that calling either AdapterRegistryMBean.destroyAdapter(AdapterManagerMBean) or AdapterRegistryMBean.destroyAdapter(ObjectName) will NOT
removeConfigurationURL
in interface AdapterRegistryMBean
adapterName
- object name representation for the associated AdapterManagerMBean
public void putConfigurationURL(javax.management.ObjectName adapterName, URLString configUrl)
AdapterRegistryMBean
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.
putConfigurationURL
in interface AdapterRegistryMBean
adapterName
- object name representation for the associated AdapterManagerMBean
configUrl
- the URL to be stored against the objectnamepublic void putConfigurationURL(javax.management.ObjectName adapterName, java.lang.String configUrl) throws java.io.IOException
AdapterRegistryMBean
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.
putConfigurationURL
in interface AdapterRegistryMBean
adapterName
- object name representation for the associated AdapterManagerMBean
configUrl
- the URL to be stored against the objectnamejava.io.IOException
public void persistAdapter(AdapterManagerMBean adapter, URLString url) throws CoreException, java.io.IOException
AdapterRegistryMBean
persistAdapter
in interface AdapterRegistryMBean
adapter
- the adapter Manager.url
- the url.CoreException
java.io.IOException
public void persistAdapter(AdapterManagerMBean adapter, java.lang.String url) throws CoreException, java.io.IOException
AdapterRegistryMBean
persistAdapter
in interface AdapterRegistryMBean
adapter
- the adapter Manager.url
- the url.CoreException
java.io.IOException
public void persistAdapter(javax.management.ObjectName adapter, URLString url) throws CoreException, java.io.IOException
AdapterRegistryMBean
persistAdapter
in interface AdapterRegistryMBean
adapter
- the AdapterManagerMBean
ObjectName.url
- the url.CoreException
java.io.IOException
public void persistAdapter(javax.management.ObjectName adapter, java.lang.String url) throws CoreException, java.io.IOException
AdapterRegistryMBean
persistAdapter
in interface AdapterRegistryMBean
adapter
- the AdapterManagerMBean
ObjectName.url
- the url.CoreException
java.io.IOException
public void persist(java.lang.String data, URLString configUrl) throws CoreException, java.io.IOException
AdapterRegistryMBean
persist
in interface AdapterRegistryMBean
data
- the data.configUrl
- the url.CoreException
java.io.IOException
public javax.management.ObjectName createAdapter(URLString url) throws java.io.IOException, javax.management.MalformedObjectNameException, CoreException
AdapterRegistryMBean
Create an adapter from the given URL; the license associated with this adapter is one that was derived from
bootstrap.properties
.
createAdapter
in interface AdapterRegistryMBean
url
- the urlAdapterManagerMBean
java.io.IOException
- an error accessing the URL.javax.management.MalformedObjectNameException
- if there was a problemCoreException
- an error creating the underlying adapter.public javax.management.ObjectName createAdapterFromUrl(java.lang.String url) throws java.io.IOException, javax.management.MalformedObjectNameException, CoreException
AdapterRegistryMBean
Create an adapter from the given URL; the license associated with this adapter is one that was derived from
bootstrap.properties
.
createAdapterFromUrl
in interface AdapterRegistryMBean
url
- the urlAdapterManagerMBean
java.io.IOException
- an error accessing the URL.javax.management.MalformedObjectNameException
- if there was a problemCoreException
- an error creating the underlying adapter.public javax.management.ObjectName createAdapter(java.lang.String xml) throws java.io.IOException, javax.management.MalformedObjectNameException, CoreException
AdapterRegistryMBean
Create an adapter from the given string; the license associated with this adapter is one that was derived from
bootstrap.properties
.
createAdapter
in interface AdapterRegistryMBean
xml
- the string representation (generally XML).AdapterManagerMBean
java.io.IOException
- an error accessing the URL.javax.management.MalformedObjectNameException
- if there was a problem with the objectname.CoreException
- an error creating the underlying adapter.public void addAdapter(AdapterManagerMBean adapterManager) throws javax.management.MalformedObjectNameException, CoreException
AdapterRegistryMBean
AdapterManagerMBean
instance to the registry.addAdapter
in interface AdapterRegistryMBean
adapterManager
- the AdapterManagerMBean
instance.javax.management.MalformedObjectNameException
- if there was a problem with the objectnameCoreException
- if the objectname already exists in the registry.public void destroyAdapter(AdapterManagerMBean adapter) throws CoreException, javax.management.MalformedObjectNameException
AdapterRegistryMBean
Note that this uses AdapterComponentMBean.requestClose()
which will block until the adapter is closed; if a timeout is
required, then make sure to use AdapterComponentMBean.requestClose(long)
and possibly
AdapterManagerMBean.forceClose()
before invoking this method.
destroyAdapter
in interface AdapterRegistryMBean
adapter
- the AdapterManagerMBean
.CoreException
- an error accessing the underlying adapter.javax.management.MalformedObjectNameException
- if there was a problem with the objectname.public void destroyAdapter(javax.management.ObjectName adapterName) throws javax.management.MalformedObjectNameException, CoreException
AdapterRegistryMBean
Note that this uses AdapterComponentMBean.requestClose()
which will block until the adapter is closed; if a timeout is
required, then make sure to use AdapterComponentMBean.requestClose(long)
and possibly
AdapterManagerMBean.forceClose()
before invoking this method.
destroyAdapter
in interface AdapterRegistryMBean
adapterName
- the AdapterManagerMBean
.javax.management.MalformedObjectNameException
- if there was a problem with the objectname.CoreException
- an error accessing the underlying adapter.AdapterRegistryMBean.destroyAdapter(AdapterManagerMBean)
public static void sendShutdownEvent(java.util.Set<javax.management.ObjectName> adapterManagers)
adapterManagers
- set of managers.public static void start(java.util.Set<javax.management.ObjectName> adapterManagers) throws CoreException
AdapterComponentMBean.requestStart()
adapterManagers
- set of managers.CoreException
public static void close(java.util.Set<javax.management.ObjectName> adapterManagers) throws CoreException
AdapterComponentMBean.requestClose()
adapterManagers
- set of managers.CoreException
- wrapping other exceptionspublic static void stop(java.util.Set<javax.management.ObjectName> adapterManagers) throws CoreException
AdapterComponentMBean.requestStop()
adapterManagers
- set of managers.CoreException
- wrapping other exceptionspublic static void unregister(java.util.Set<javax.management.ObjectName> adapterManagers) throws CoreException
BaseComponentMBean.unregisterMBean()
adapterManagers
- set of managers.CoreException
- wrapping other exceptionspublic java.util.Properties getConfiguration()
AdapterRegistryMBean
BootstrapProperties
instance that was used to create this registry.getConfiguration
in interface AdapterRegistryMBean
public java.lang.String getVersionControl()
AdapterRegistryMBean
getVersionControl
in interface AdapterRegistryMBean
public void reloadFromVersionControl() throws javax.management.MalformedObjectNameException, CoreException, java.net.MalformedURLException, java.io.IOException
AdapterRegistryMBean
Note that the adapters will not be started as part of this process; this needs to be done separately.
reloadFromVersionControl
in interface AdapterRegistryMBean
javax.management.MalformedObjectNameException
- if there was a problem with any objectname.CoreException
- an error creating the underlying adapter(s).java.net.MalformedURLException
- if there was a problem with the URL found from config.java.io.IOException
- if there was a with reading the URL where the adapter is hosted.public java.util.Set<javax.management.ObjectName> reloadFromConfig() throws javax.management.MalformedObjectNameException, CoreException, java.net.MalformedURLException, java.io.IOException
AdapterRegistryMBean
Note that the adapters will not be started as part of this process; this needs to be done separately.
reloadFromConfig
in interface AdapterRegistryMBean
AdapterManagerMBean
instances created.javax.management.MalformedObjectNameException
- if there was a problem with any objectname.CoreException
- an error creating the underlying adapter(s).java.net.MalformedURLException
- if there was a problem with the URL found from config.java.io.IOException
- if there was a with reading the URL where the adapter is hosted.public javax.management.ObjectName reloadFromConfig(javax.management.ObjectName obj) throws javax.management.MalformedObjectNameException, CoreException, java.io.IOException
AdapterRegistryMBean
Note that the adapter will not be started as part of this process; this needs to be done separately.
reloadFromConfig
in interface AdapterRegistryMBean
obj
- the ObjectName to reload from config.AdapterManagerMBean
instances created.javax.management.MalformedObjectNameException
- if there was a problem with any objectname.CoreException
- an error creating the underlying adapter(s).java.io.IOException
- if there was a with reading the URL where the adapter is hosted.java.net.MalformedURLException
- if there was a problem with the URL found from config.public javax.management.ObjectName reloadFromVersionControl(javax.management.ObjectName obj) throws javax.management.MalformedObjectNameException, CoreException, java.io.IOException
AdapterRegistryMBean
Note that the adapter will not be started as part of this process; this needs to be done separately.
reloadFromVersionControl
in interface AdapterRegistryMBean
obj
- the ObjectName to restart.AdapterManagerMBean
instances created.javax.management.MalformedObjectNameException
- if there was a problem with any objectname.CoreException
- an error creating the underlying adapter(s).java.io.IOException
- if there was a with reading the URL where the adapter is hosted.java.net.MalformedURLException
- if there was a problem with the URL found from config.public void addConfiguration(java.util.Properties cfg) throws javax.management.MalformedObjectNameException, CoreException
addConfiguration
in interface AdapterRegistryMBean
javax.management.MalformedObjectNameException
CoreException
public void validateConfig(java.lang.String config) throws CoreException
AdapterRegistryMBean
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 new AdapterManagerMBean
as
part of the operation.
validateConfig
in interface AdapterRegistryMBean
config
- the String representation of a component.CoreException
- if there was an exception unmarshalling.AdapterRegistryMBean.createAdapter(String)
public java.lang.String getClassDefinition(java.lang.String className) throws CoreException
AdapterRegistryMBean
getClassDefinition
in interface AdapterRegistryMBean
className
- - fully qualifiedCoreException
public java.util.Set<javax.management.ObjectName> getBuilders()
AdapterRegistryMBean
getBuilders
in interface AdapterRegistryMBean
public javax.management.ObjectName getBuilder(javax.management.ObjectName p) throws javax.management.InstanceNotFoundException
AdapterRegistryMBean
AdapterBuilderMBean
instance that built the corresponding AdapterManagerMBean
instance.getBuilder
in interface AdapterRegistryMBean
p
- a reference to the AdapterManagerMBean
AdapterBuilderMBean
javax.management.InstanceNotFoundException
- if there was no associated builder.public AdapterBuilderMBean getBuilderMBean(javax.management.ObjectName p) throws javax.management.InstanceNotFoundException
AdapterRegistryMBean
AdapterBuilderMBean
instance that built the corresponding AdapterManagerMBean
instance.getBuilderMBean
in interface AdapterRegistryMBean
p
- a reference to the AdapterManagerMBean
AdapterBuilderMBean
javax.management.InstanceNotFoundException
- if there was no associated builder.public AdapterBuilderMBean getBuilder(java.util.Properties p) throws javax.management.InstanceNotFoundException
AdapterRegistryMBean
AdapterBuilderMBean
associated with given Properties
object.getBuilder
in interface AdapterRegistryMBean
javax.management.InstanceNotFoundException
public void addManagementComponentInfo(ManagementComponentInfo componentInfo)
public java.util.List<ManagementComponentInfo> getManagementComponentInfo()
AdapterRegistryMBean
ManagementComponentInfo
's. The key to the map
is the name of the configured management component.getManagementComponentInfo
in interface AdapterRegistryMBean
public void setManagementComponentInfo(java.util.List<ManagementComponentInfo> managementComponentInfo)
AdapterRegistryMBean
setManagementComponentInfo
in interface AdapterRegistryMBean