Version 6

    The MBeanConfigurator service is a service that will set attributes of any newly registered MBean based on a binding xml file.  This service depends on the ServiceBindingManger and uses the same format as would be found for an service binding.

     

     

    Example:

     

     

    An example of the MBeanConfigurator service can be found under the docs\examples\jmx\mbean-configurator.sar directory of JBoss 5.0 (hence is a new feature of JBoss 5.0).  In this example, the MBeanConfigurator will set the  'testAttribute' attribute of the SampleConfig mbean when it is first registered with the MBeanServer to be the value 'Changed Value'.  To run this example, copy the mbean-configurator.sar directory to your deploy directory (i.e. server\default\deploy\).  Once deployed, you will be able to see that the 'testAttribute' attribute values has been changed from its default value of 'Initial Value' to 'Change Value' using the JMX Console (look for name=SampleConfig under the sample domain).

     

     

    How the example works:

     

     

    First thing to notice is the jboss-service.xml under the mbean-configurator.sar\META-INF directory.  This contains three services; MBeanConfigurator, ServiceBindingManger, and SampleService.  The MBeanConfigurator depends on the ServiceBindingManager, as it depends on it to do the actual setting of the mbean attribute.  The SampleService is only there to create a standard mbean, SampleConfig (which is not an mbean service), upon startup and depends on MBeanConfigurator.  The ServiceBindingManger is configured to use sample-binding.xml for setting attributes on the SampleConfig mbean.

     

    When the MBeanConfigurator starts up, it will register with the MBeanServer to receive registration notifications when an mbean is registered.  Upon this notification, it will call the ServiceBindingManager to set the mbeans attributes.  The ServiceBindingManager will use the sample-binding.xml to see if the registered mbean has any attributes defined within the binding xml.  If so, it will set them.

     

     

    Use:

     

     

    To setup your own MBeanConfigurator, use the example as a template and remove the SampleService and SampleConfig.  Then in the sample-binding.xml (you can name it whatever you want, just as long as you change the name in the jboss-service.xml) change the mbean and attribute you want to set.  Then make sure the mbean-configurator.sar is in the deploy directory.

     

     

    Word of caution:

     

     

    This service should ONLY be used when you know that you need to change the attribute values of an mbean at startup.  Most mbeans are initialied internally, so changing attributes may cause unspecified behaviour.  Make sure you know what you are doing when you use this service, as should only be used in rare cases.