org.apache.servicemix.jbi.jmx
Class ConnectorServerFactoryBean

java.lang.Object
  extended by org.apache.servicemix.jbi.jmx.ConnectorServerFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

public class ConnectorServerFactoryBean
extends Object
implements org.springframework.beans.factory.FactoryBean, 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. This xbean-enabled factory is a wrapper on top of the existing Spring factory bean. It also logs the serviceUrl when starting.

Author:
gnodet

Field Summary
static int REGISTRATION_FAIL_ON_EXISTING
          Constant indicating that registration should fail when attempting to register an MBean under a name that already exists.
static int REGISTRATION_IGNORE_EXISTING
          Constant indicating that registration should ignore the affected MBean when attempting to register an MBean under a name that already exists.
static int REGISTRATION_REPLACE_EXISTING
          Constant indicating that registration should replace the affected MBean when attempting to register an MBean under a name that already exists.
 
Constructor Summary
ConnectorServerFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
 void destroy()
           
 Object getObject()
           
 Class getObjectType()
           
 boolean isSingleton()
           
 void setDaemon(boolean daemon)
          Set whether any threads started for the JMXConnectorServer should be started as daemon threads.
 void setEnvironment(Map environment)
          Set the environment properties used to construct the JMXConnector as a Map of String keys and arbitrary Object values.
 void setObjectName(String objectName)
          Set the ObjectName used to register the JMXConnectorServer itself with the MBeanServer.
 void setRegistrationBehavior(int registrationBehavior)
          Specify what action should be taken when attempting to register an MBean under an ObjectName that already exists.
 void setRegistrationBehaviorName(String behavior)
          Set the registration behavior by the name of the corresponding constant, e.g.
 void setServer(MBeanServer server)
          Specify the MBeanServer instance with which all beans should be registered.
 void setServiceUrl(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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REGISTRATION_FAIL_ON_EXISTING

public static final int REGISTRATION_FAIL_ON_EXISTING
Constant indicating that registration should fail when attempting to register an MBean under a name that already exists.

This is the default registration behavior.

See Also:
Constant Field Values

REGISTRATION_IGNORE_EXISTING

public static final int REGISTRATION_IGNORE_EXISTING
Constant indicating that registration should ignore the affected MBean when attempting to register an MBean under a name that already exists.

See Also:
Constant Field Values

REGISTRATION_REPLACE_EXISTING

public static final int REGISTRATION_REPLACE_EXISTING
Constant indicating that registration should replace the affected MBean when attempting to register an MBean under a name that already exists.

See Also:
Constant Field Values
Constructor Detail

ConnectorServerFactoryBean

public ConnectorServerFactoryBean()
Method Detail

setDaemon

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

Parameters:
daemon -
See Also:
ConnectorServerFactoryBean.setDaemon(boolean)

setEnvironment

public void setEnvironment(Map environment)
Set the environment properties used to construct the JMXConnector as a Map of String keys and arbitrary Object values.

Parameters:
environment -
See Also:
ConnectorServerFactoryBean.setEnvironmentMap(java.util.Map)

setObjectName

public void setObjectName(String objectName)
                   throws MalformedObjectNameException
Set the ObjectName used to register the JMXConnectorServer itself with the MBeanServer.

Parameters:
objectName -
Throws:
MalformedObjectNameException - if the ObjectName is malformed
See Also:
org.springframework.jmx.support.ConnectorServerFactoryBean#setObjectName(java.lang.String)

setRegistrationBehavior

public void setRegistrationBehavior(int registrationBehavior)
Specify what action should be taken when attempting to register an MBean under an ObjectName that already exists.

Default is REGISTRATION_FAIL_ON_EXISTING.

Parameters:
registrationBehavior -
See Also:
setRegistrationBehaviorName(String), REGISTRATION_FAIL_ON_EXISTING, REGISTRATION_IGNORE_EXISTING, REGISTRATION_REPLACE_EXISTING, MBeanRegistrationSupport.setRegistrationBehavior(int)

setRegistrationBehaviorName

public void setRegistrationBehaviorName(String behavior)
Set the registration behavior by the name of the corresponding constant, e.g. "REGISTRATION_IGNORE_EXISTING".

Parameters:
behavior -
See Also:
setRegistrationBehavior(int), REGISTRATION_FAIL_ON_EXISTING, REGISTRATION_IGNORE_EXISTING, REGISTRATION_REPLACE_EXISTING, MBeanRegistrationSupport.setRegistrationBehaviorName(java.lang.String)

setServer

public void setServer(MBeanServer server)
Specify the MBeanServer instance with which all beans should be registered. The MBeanExporter will attempt to locate an existing MBeanServer if none is supplied.

Parameters:
server -
See Also:
MBeanRegistrationSupport.setServer(javax.management.MBeanServer)

setServiceUrl

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

Parameters:
serviceUrl -
See Also:
ConnectorServerFactoryBean.setServiceUrl(java.lang.String)

setThreaded

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

Parameters:
threaded -
See Also:
ConnectorServerFactoryBean.setThreaded(boolean)

getObject

public Object getObject()
                 throws Exception
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean
Throws:
Exception

getObjectType

public Class getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
Exception


Copyright © 2005-2008 Apache Software Foundation. All Rights Reserved.