spring-context

org.springframework.jmx.support
Class ConnectorServerFactoryBean

java.lang.Object
  extended by org.springframework.jmx.support.MBeanRegistrationSupport
      extended by org.springframework.jmx.support.ConnectorServerFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean<javax.management.remote.JMXConnectorServer>, org.springframework.beans.factory.InitializingBean

public class ConnectorServerFactoryBean
extends MBeanRegistrationSupport
implements org.springframework.beans.factory.FactoryBean<javax.management.remote.JMXConnectorServer>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean

FactoryBean that creates a JSR-160 JMXConnectorServer, optionally registers it with the MBeanServer and then starts it.

The JMXConnectorServer can be started in a separate thread by setting the threaded property to true. You can configure this thread to be a daemon thread by setting the daemon property to true.

The JMXConnectorServer is correctly shutdown when an instance of this class is destroyed on shutdown of the containing ApplicationContext.

Since:
1.2
Author:
Rob Harrop, Juergen Hoeller
See Also:
FactoryBean, JMXConnectorServer, MBeanServer

Field Summary
static java.lang.String DEFAULT_SERVICE_URL
          The default service URL
 
Fields inherited from class org.springframework.jmx.support.MBeanRegistrationSupport
logger, registeredBeans, REGISTRATION_FAIL_ON_EXISTING, REGISTRATION_IGNORE_EXISTING, REGISTRATION_REPLACE_EXISTING, server
 
Constructor Summary
ConnectorServerFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
          Start the connector server.
 void destroy()
          Stop the JMXConnectorServer managed by an instance of this class.
 javax.management.remote.JMXConnectorServer getObject()
           
 java.lang.Class<? extends javax.management.remote.JMXConnectorServer> getObjectType()
           
 boolean isSingleton()
           
 void setDaemon(boolean daemon)
          Set whether any threads started for the JMXConnectorServer should be started as daemon threads.
 void setEnvironment(java.util.Properties environment)
          Set the environment properties used to construct the JMXConnectorServer as java.util.Properties (String key/value pairs).
 void setEnvironmentMap(java.util.Map<java.lang.String,?> environment)
          Set the environment properties used to construct the JMXConnector as a Map of String keys and arbitrary Object values.
 void setForwarder(javax.management.remote.MBeanServerForwarder forwarder)
          Set an MBeanServerForwarder to be applied to the JMXConnectorServer.
 void setObjectName(java.lang.Object objectName)
          Set the ObjectName used to register the JMXConnectorServer itself with the MBeanServer, as ObjectName instance or as String.
 void setServiceUrl(java.lang.String serviceUrl)
          Set the service URL for the JMXConnectorServer.
 void setThreaded(boolean threaded)
          Set whether the JMXConnectorServer should be started in a separate thread.
 
Methods inherited from class org.springframework.jmx.support.MBeanRegistrationSupport
doRegister, doUnregister, getRegisteredObjectNames, getServer, onRegister, onRegister, onUnregister, setRegistrationBehavior, setRegistrationBehaviorName, setServer, unregisterBeans
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SERVICE_URL

public static final java.lang.String DEFAULT_SERVICE_URL
The default service URL

See Also:
Constant Field Values
Constructor Detail

ConnectorServerFactoryBean

public ConnectorServerFactoryBean()
Method Detail

setServiceUrl

public void setServiceUrl(java.lang.String serviceUrl)
Set the service URL for the JMXConnectorServer.


setEnvironment

public void setEnvironment(java.util.Properties environment)
Set the environment properties used to construct the JMXConnectorServer as java.util.Properties (String key/value pairs).


setEnvironmentMap

public void setEnvironmentMap(java.util.Map<java.lang.String,?> environment)
Set the environment properties used to construct the JMXConnector as a Map of String keys and arbitrary Object values.


setForwarder

public void setForwarder(javax.management.remote.MBeanServerForwarder forwarder)
Set an MBeanServerForwarder to be applied to the JMXConnectorServer.


setObjectName

public void setObjectName(java.lang.Object objectName)
                   throws javax.management.MalformedObjectNameException
Set the ObjectName used to register the JMXConnectorServer itself with the MBeanServer, as ObjectName instance or as String.

Throws:
javax.management.MalformedObjectNameException - if the ObjectName is malformed

setThreaded

public void setThreaded(boolean threaded)
Set whether the JMXConnectorServer should be started in a separate thread.


setDaemon

public void setDaemon(boolean daemon)
Set whether any threads started for the JMXConnectorServer should be started as daemon threads.


afterPropertiesSet

public void afterPropertiesSet()
                        throws javax.management.JMException,
                               java.io.IOException
Start the connector server. If the threaded flag is set to true, the JMXConnectorServer will be started in a separate thread. If the daemon flag is set to true, that thread will be started as a daemon thread.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
javax.management.JMException - if a problem occured when registering the connector server with the MBeanServer
java.io.IOException - if there is a problem starting the connector server

getObject

public javax.management.remote.JMXConnectorServer getObject()
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<javax.management.remote.JMXConnectorServer>

getObjectType

public java.lang.Class<? extends javax.management.remote.JMXConnectorServer> getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<javax.management.remote.JMXConnectorServer>

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<javax.management.remote.JMXConnectorServer>

destroy

public void destroy()
             throws java.io.IOException
Stop the JMXConnectorServer managed by an instance of this class. Automatically called on ApplicationContext shutdown.

Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
java.io.IOException - if there is an error stopping the connector server

spring-context