org.jboss.system
Class ServiceConfigurator

java.lang.Object
  extended by org.jboss.system.ServiceConfigurator

public class ServiceConfigurator
extends Object

Service configuration helper.

Version:
$Revision: 86940 $
Author:
Marc Fleury, Hiram Chirino, David Jencks, Jason Dillon, Dimitris Andreadis, Adrian Brock

Constructor Summary
ServiceConfigurator(MBeanServer server, ServiceController serviceController, ServiceCreator serviceCreator)
          Deprecated. the service controller no longer uses the service configurator and vice-versa
 
Method Summary
static void configure(MBeanServer server, ServiceController controller, ObjectName objectName, ClassLoader cl, Collection<ServiceAttributeMetaData> attrs)
          Configure an MBean
static void configure(MBeanServer server, ServiceController controller, ObjectName objectName, ObjectName classLoaderName, Collection<ServiceAttributeMetaData> attrs)
          Configure an MBean
static HashMap<String,MBeanAttributeInfo> getAttributeMap(MBeanServer server, ObjectName objectName)
          Get an attribute map for the MBean
static String getConfiguration(MBeanServer server, ServiceController serviceController, ObjectName[] objectNames)
          Builds a string that consists of the configuration elements of the currently running MBeans registered in the server.
 String getConfiguration(ObjectName[] objectNames)
          Builds a string that consists of the configuration elements of the currently running MBeans registered in the server.
static StringBuffer getElementContent(Element element)
          A utility method that transforms the contents of the argument element into a StringBuffer representation that can be reparsed.
 List<ObjectName> install(Element config, ObjectName loaderName)
          Deprecated. the service controller no longer uses the service configurator and vice-versa
static Exception rethrow(String context, Throwable t)
          Rethrow an error as an exception
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceConfigurator

public ServiceConfigurator(MBeanServer server,
                           ServiceController serviceController,
                           ServiceCreator serviceCreator)
Deprecated. the service controller no longer uses the service configurator and vice-versa

Constructor

Parameters:
server - the mbean server
serviceController - the servie controller
serviceCreator - the service creator
Method Detail

rethrow

public static Exception rethrow(String context,
                                Throwable t)
                         throws Exception
Rethrow an error as an exception

Parameters:
context - the context
t - the original throwable
Returns:
never
Throws:
Exception - always

configure

public static void configure(MBeanServer server,
                             ServiceController controller,
                             ObjectName objectName,
                             ObjectName classLoaderName,
                             Collection<ServiceAttributeMetaData> attrs)
                      throws Exception
Configure an MBean

Parameters:
server - the server
controller - the service controller
objectName - the object name
classLoaderName - the classloader object name
attrs - the attributes
Throws:
Exception - for any error

configure

public static void configure(MBeanServer server,
                             ServiceController controller,
                             ObjectName objectName,
                             ClassLoader cl,
                             Collection<ServiceAttributeMetaData> attrs)
                      throws Exception
Configure an MBean

Parameters:
server - the server
controller - the service controller
objectName - the object name
cl - the classloader
attrs - the attributes
Throws:
Exception - for any error

getAttributeMap

public static HashMap<String,MBeanAttributeInfo> getAttributeMap(MBeanServer server,
                                                                 ObjectName objectName)
                                                          throws Exception
Get an attribute map for the MBean

Parameters:
server - the server
objectName - the object name
Returns:
a map of attribute name to attribute info
Throws:
Exception - for any error

install

public List<ObjectName> install(Element config,
                                ObjectName loaderName)
                         throws Exception
Deprecated. the service controller no longer uses the service configurator and vice-versa

The install method iterates through the mbean tags in the supplied xml configuration and creates and configures the mbeans shown. The mbean configuration can be nested.

Parameters:
config - the xml Element containing the configuration of the mbeans to create and configure.
loaderName - the classloader's ObjectName
Returns:
a List of ObjectNames of created mbeans.
Throws:
Exception - if an error occurs

getConfiguration

public static String getConfiguration(MBeanServer server,
                                      ServiceController serviceController,
                                      ObjectName[] objectNames)
                               throws Exception
Builds a string that consists of the configuration elements of the currently running MBeans registered in the server.

Parameters:
server - the MBeanServer
serviceController - the service controller
objectNames - the object names to retrieve
Returns:
the xml string
Throws:
Exception - Failed to construct configuration.

getConfiguration

public String getConfiguration(ObjectName[] objectNames)
                        throws Exception
Builds a string that consists of the configuration elements of the currently running MBeans registered in the server. TODO replace with more sophisticated mbean persistence mechanism.

Parameters:
objectNames - the object names
Returns:
the xml string
Throws:
Exception - Failed to construct configuration.

getElementContent

public static StringBuffer getElementContent(Element element)
                                      throws IOException,
                                             TransformerException
A utility method that transforms the contents of the argument element into a StringBuffer representation that can be reparsed. [FIXME] This is not a general DOMUtils method because of its funny contract. It does not support multiple child elements neither can it deal with text content.

Parameters:
element - - the parent dom element whose contents are to be extracted as an xml document string.
Returns:
the xml document string.
Throws:
IOException - for an error during IO
TransformerException - for an erro during transformation


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.