Top Description Inners Fields Constructors Methods
org.springframework.jmx.support

public Class MBeanServerConnectionFactoryBean

extends Object
implements FactoryBean<MBeanServerConnection>, BeanClassLoaderAware, InitializingBean, DisposableBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.Aware, org.springframework.beans.factory.FactoryBean
Imports
java.io.IOException, java.net.MalformedURLException, java.util.HashMap, .Map, .Properties, javax.management.MBeanServerConnection, javax.management.remote.JMXConnector, .JMXConnectorFactory, .JMXServiceURL, org.springframework.aop.TargetSource, org.springframework.aop.framework.ProxyFactory, org.springframework.aop.target.AbstractLazyCreationTargetSource, org.springframework.beans.factory.BeanClassLoaderAware, .DisposableBean, .FactoryBean, .InitializingBean, org.springframework.lang.Nullable, org.springframework.util.Assert, .ClassUtils, .CollectionUtils

FactoryBean that creates a JMX 1.2 MBeanServerConnection to a remote MBeanServer exposed via a JMXServerConnector. Exposes the MBeanServer for bean references.
Authors
Rob Harrop, Juergen Hoeller
Since
1.2
See Also
MBeanServerFactoryBean, ConnectorServerFactoryBean, org.springframework.jmx.access.MBeanClientInterceptor#setServer, org.springframework.jmx.access.NotificationListenerRegistrar#setServer

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
MBeanServerConnectionFactoryBean.JMXConnectorLazyInitTargetSource

Lazily creates a JMXConnector using the configured service URL and environment properties.

private class

Field Summary

Modifier and TypeField and Description
private ClassLoader
private MBeanServerConnection
private boolean
private JMXConnector
private MBeanServerConnectionFactoryBean.JMXConnectorLazyInitTargetSource
private final Map<String, Object>
private JMXServiceURL

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Creates a JMXConnector for the given settings and exposes the associated MBeanServerConnection.

private void
connect()

Connects to the remote MBeanServer using the configured service URL and environment properties.

private void
createLazyConnection()

Creates lazy proxies for the JMXConnector and MBeanServerConnection.

public void
destroy()

Implements org.springframework.beans.factory.DisposableBean.destroy.

Closes the underlying JMXConnector.

public MBeanServerConnection
getObject()

Implements org.springframework.beans.factory.FactoryBean.getObject.

Return an instance (possibly shared or independent) of the object managed by this factory.

public Class<? extends MBeanServerConnection>
getObjectType()

Implements org.springframework.beans.factory.FactoryBean.getObjectType.

Return the type of object that this FactoryBean creates, or null if not known in advance.

public boolean
isSingleton()

Overrides default org.springframework.beans.factory.FactoryBean.isSingleton.

Is the object managed by this factory a singleton?

public void
setBeanClassLoader(ClassLoader
the owning class loader
classLoader
)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class loader to a bean instance.

public void
setConnectOnStartup(boolean connectOnStartup)

Set whether to connect to the server on startup.

public void
setEnvironment(Properties environment)

Set the environment properties used to construct the JMXConnector as java.util.Properties (String key/value pairs).

public void
setEnvironmentMap(Map<String, ?> environment)

Set the environment properties used to construct the JMXConnector as a Map of String keys and arbitrary Object values.

public void
setServiceUrl(String url)

Set the service URL of the remote MBeanServer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

beanClassLoaderback to summary
private ClassLoader beanClassLoader
Annotations
@Nullable
connectionback to summary
private MBeanServerConnection connection
Annotations
@Nullable
connectOnStartupback to summary
private boolean connectOnStartup
connectorback to summary
private JMXConnector connector
Annotations
@Nullable
connectorTargetSourceback to summary
private MBeanServerConnectionFactoryBean.JMXConnectorLazyInitTargetSource connectorTargetSource
Annotations
@Nullable
environmentback to summary
private final Map<String, Object> environment
serviceUrlback to summary
private JMXServiceURL serviceUrl
Annotations
@Nullable

Constructor Detail

MBeanServerConnectionFactoryBeanback to summary
public MBeanServerConnectionFactoryBean()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws IOException

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Creates a JMXConnector for the given settings and exposes the associated MBeanServerConnection.

Annotations
@Override
connectback to summary
private void connect() throws IOException

Connects to the remote MBeanServer using the configured service URL and environment properties.

createLazyConnectionback to summary
private void createLazyConnection()

Creates lazy proxies for the JMXConnector and MBeanServerConnection.

destroyback to summary
public void destroy() throws IOException

Implements org.springframework.beans.factory.DisposableBean.destroy.

Closes the underlying JMXConnector.

Annotations
@Override
getObjectback to summary
public MBeanServerConnection getObject()

Implements org.springframework.beans.factory.FactoryBean.getObject.

Doc from org.springframework.beans.factory.FactoryBean.getObject.

Return an instance (possibly shared or independent) of the object managed by this factory.

As with a BeanFactory, this allows support for both the Singleton and Prototype design pattern.

If this FactoryBean is not fully initialized yet at the time of the call (for example because it is involved in a circular reference), throw a corresponding FactoryBeanNotInitializedException.

As of Spring 2.0, FactoryBeans are allowed to return null objects. The factory will consider this as normal value to be used; it will not throw a FactoryBeanNotInitializedException in this case anymore. FactoryBean implementations are encouraged to throw FactoryBeanNotInitializedException themselves now, as appropriate.

Returns:MBeanServerConnection

an instance of the bean (can be null)

Annotations
@Override
@Nullable
getObjectTypeback to summary
public Class<? extends MBeanServerConnection> getObjectType()

Implements org.springframework.beans.factory.FactoryBean.getObjectType.

Doc from org.springframework.beans.factory.FactoryBean.getObjectType.

Return the type of object that this FactoryBean creates, or null if not known in advance.

This allows one to check for specific types of beans without instantiating objects, for example on autowiring.

In the case of implementations that are creating a singleton object, this method should try to avoid singleton creation as far as possible; it should rather estimate the type in advance. For prototypes, returning a meaningful type here is advisable too.

This method can be called before this FactoryBean has been fully initialized. It must not rely on state created during initialization; of course, it can still use such state if available.

Note

Autowiring will simply ignore FactoryBeans that return null here. Therefore, it is highly recommended to implement this method properly, using the current state of the FactoryBean.

Returns:Class<? extends MBeanServerConnection>

the type of object that this FactoryBean creates, or null if not known at the time of the call

Annotations
@Override
isSingletonback to summary
public boolean isSingleton()

Overrides default org.springframework.beans.factory.FactoryBean.isSingleton.

Doc from org.springframework.beans.factory.FactoryBean.isSingleton.

Is the object managed by this factory a singleton? That is, will getObject() always return the same object (a reference that can be cached)?

Note

If a FactoryBean indicates to hold a singleton object, the object returned from getObject() might get cached by the owning BeanFactory. Hence, do not return true unless the FactoryBean always exposes the same reference.

The singleton status of the FactoryBean itself will generally be provided by the owning BeanFactory; usually, it has to be defined as singleton there.

Note

This method returning false does not necessarily indicate that returned objects are independent instances. An implementation of the extended SmartFactoryBean interface may explicitly indicate independent instances through its SmartFactoryBean#isPrototype() method. Plain FactoryBean implementations which do not implement this extended interface are simply assumed to always return independent instances if the isSingleton() implementation returns false.

The default implementation returns true, since a FactoryBean typically manages a singleton instance.

Returns:boolean

whether the exposed object is a singleton

Annotations
@Override
setBeanClassLoaderback to summary
public void setBeanClassLoader(ClassLoader classLoader)

Implements org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Doc from org.springframework.beans.factory.BeanClassLoaderAware.setBeanClassLoader.

Callback that supplies the bean class loader to a bean instance.

Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean's InitializingBean#afterPropertiesSet() method or a custom init-method.

Parameters
classLoader:ClassLoader

the owning class loader

Annotations
@Override
setConnectOnStartupback to summary
public void setConnectOnStartup(boolean connectOnStartup)

Set whether to connect to the server on startup.

Default is true.

Can be turned off to allow for late start of the JMX server. In this case, the JMX connector will be fetched on first access.

setEnvironmentback to summary
public void setEnvironment(Properties environment)

Set the environment properties used to construct the JMXConnector as java.util.Properties (String key/value pairs).

setEnvironmentMapback to summary
public void setEnvironmentMap(Map<String, ?> environment)

Set the environment properties used to construct the JMXConnector as a Map of String keys and arbitrary Object values.

setServiceUrlback to summary
public void setServiceUrl(String url) throws MalformedURLException

Set the service URL of the remote MBeanServer.

org.springframework.jmx.support back to summary

private Class MBeanServerConnectionFactoryBean.JMXConnectorLazyInitTargetSource

extends AbstractLazyCreationTargetSource
Class Inheritance

Lazily creates a JMXConnector using the configured service URL and environment properties.
See Also
MBeanServerConnectionFactoryBean#setServiceUrl(String), MBeanServerConnectionFactoryBean#setEnvironment(java.util.Properties)

Field Summary

Inherited from org.springframework.aop.target.AbstractLazyCreationTargetSource:
logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected Object
createObject()

Implements abstract org.springframework.aop.target.AbstractLazyCreationTargetSource.createObject.

Subclasses should implement this method to return the lazy initialized object.

public Class<?>
getTargetClass()

Overrides org.springframework.aop.target.AbstractLazyCreationTargetSource.getTargetClass.

Implements org.springframework.aop.TargetSource.getTargetClass.

This default implementation returns null if the target is null (it is hasn't yet been initialized), or the target class if the target has already been initialized.

Inherited from org.springframework.aop.target.AbstractLazyCreationTargetSource:
getTargetisInitialized

Constructor Detail

JMXConnectorLazyInitTargetSourceback to summary
private JMXConnectorLazyInitTargetSource()

Method Detail

createObjectback to summary
protected Object createObject() throws Exception

Implements abstract org.springframework.aop.target.AbstractLazyCreationTargetSource.createObject.

Doc from org.springframework.aop.target.AbstractLazyCreationTargetSource.createObject.

Subclasses should implement this method to return the lazy initialized object. Called the first time the proxy is invoked.

Returns:Object

the created object

Annotations
@Override
Exceptions
Exception:
if creation failed
getTargetClassback to summary
public Class<?> getTargetClass()

Overrides org.springframework.aop.target.AbstractLazyCreationTargetSource.getTargetClass.

Implements org.springframework.aop.TargetSource.getTargetClass.

Doc from org.springframework.aop.target.AbstractLazyCreationTargetSource.getTargetClass.

This default implementation returns null if the target is null (it is hasn't yet been initialized), or the target class if the target has already been initialized.

Subclasses may wish to override this method in order to provide a meaningful value when the target is still null.

Returns:Class<?>

Doc from org.springframework.aop.TargetSource.getTargetClass.

the type of targets returned by this TargetSource

Annotations
@Override
org.springframework.jmx.support back to summary

private Class MBeanServerConnectionFactoryBean.MBeanServerConnectionLazyInitTargetSource

extends AbstractLazyCreationTargetSource
Class Inheritance

Lazily creates an MBeanServerConnection.

Field Summary

Inherited from org.springframework.aop.target.AbstractLazyCreationTargetSource:
logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected Object
createObject()

Implements abstract org.springframework.aop.target.AbstractLazyCreationTargetSource.createObject.

Subclasses should implement this method to return the lazy initialized object.

public Class<?>
getTargetClass()

Overrides org.springframework.aop.target.AbstractLazyCreationTargetSource.getTargetClass.

Implements org.springframework.aop.TargetSource.getTargetClass.

This default implementation returns null if the target is null (it is hasn't yet been initialized), or the target class if the target has already been initialized.

Inherited from org.springframework.aop.target.AbstractLazyCreationTargetSource:
getTargetisInitialized

Constructor Detail

MBeanServerConnectionLazyInitTargetSourceback to summary
private MBeanServerConnectionLazyInitTargetSource()

Method Detail

createObjectback to summary
protected Object createObject() throws Exception

Implements abstract org.springframework.aop.target.AbstractLazyCreationTargetSource.createObject.

Doc from org.springframework.aop.target.AbstractLazyCreationTargetSource.createObject.

Subclasses should implement this method to return the lazy initialized object. Called the first time the proxy is invoked.

Returns:Object

the created object

Annotations
@Override
Exceptions
Exception:
if creation failed
getTargetClassback to summary
public Class<?> getTargetClass()

Overrides org.springframework.aop.target.AbstractLazyCreationTargetSource.getTargetClass.

Implements org.springframework.aop.TargetSource.getTargetClass.

Doc from org.springframework.aop.target.AbstractLazyCreationTargetSource.getTargetClass.

This default implementation returns null if the target is null (it is hasn't yet been initialized), or the target class if the target has already been initialized.

Subclasses may wish to override this method in order to provide a meaningful value when the target is still null.

Returns:Class<?>

Doc from org.springframework.aop.TargetSource.getTargetClass.

the type of targets returned by this TargetSource

Annotations
@Override