org.apache.tools.ant.taskdefs.optional.jmx.connector
Interface JMXConnector

All Known Implementing Classes:
AbstractJMXConnector

public interface JMXConnector

Interface that provides access to a remote JMX server. JMXConnector provides a consistent interface for functions required by the Ant JMX tasks not current covered adequately by the JMX specification.

Implementations of this interface are instantiated by JMXConnectorFactory. JMXConnectorFactory will locate the correct JMXConnector implementation based on the value of the serverType attribute that appears on the ANT task.

JMXConnectorFactory locates the JMXConnector implementation by first using the serverType argument as part of the package name according to the following template: org.apache.tools.ant.taskdefs.optional.jmx.connector..Connector

If this technique fails to find a class that implements JMXConnector, then it is assumed that serverType is the fully qualified class name for the JMXConnector implementation (e.g. serverType = org.someone.MyJMXServer).

Version:
$Id: JMXConnector.java,v 1.4 2003/05/28 22:28:26 bdueck Exp $
Author:
Brian Dueck

Method Summary
 javax.management.ObjectName createMBean(java.lang.String type, javax.management.ObjectName objectName, javax.management.MBeanServer mbserver)
          Creates & registers an MBean with an MBeanServer.
 java.lang.String getActiveDomain(javax.management.MBeanServer mbserver)
          Returns the active/default domain for this JMXServer.
 java.util.Hashtable getInitialContextProperties(java.util.Hashtable contextProps)
          Returns a base set of initial context properties that apply to this JMXServer adaptor.
 java.util.Hashtable getInitialContextProperties(java.lang.String providerUrl, java.lang.String user, java.lang.String password)
          Returns a base set of initial context properties that apply to this JMXServer adaptor.
 javax.management.MBeanServer getMBeanServer(java.util.Hashtable contextProps, java.lang.String jndiLookupName)
          Connects to a JMX server and returns the MBeanServer to use during task execution.
 

Method Detail

getInitialContextProperties

public java.util.Hashtable getInitialContextProperties(java.util.Hashtable contextProps)
Returns a base set of initial context properties that apply to this JMXServer adaptor. These properties will be used in conjuntion with additional properties obtained from the task - for example, user and password information. Prior to invoking this method, the caller will extract information from the Ant task and place these values in the property list according to the following mapping:

Context.PROVIDER_URL = providerUrl

Context.SECURITY_PRINCIPAL = user

Context.SECURITY_CREDENTIALS = password

The implementation of this method may examine/modify/delete/add to the properties as appropriate for the implementation.

Minimally, the implementation is expected to add the Context.INITIAL_CONTEXT_FACTORY value that is appropriate for this JMXConnector implementation. For example:

contextProps.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, weblogic.jndi.WLInitialContextFactory.class.getName());

After this method returns, the caller may further augment the properties as required - but typically does not.

These resulting properties will be passed to the getMBeanServer() method of this interface after this call returns.


getInitialContextProperties

public java.util.Hashtable getInitialContextProperties(java.lang.String providerUrl,
                                                       java.lang.String user,
                                                       java.lang.String password)
Returns a base set of initial context properties that apply to this JMXServer adaptor. These properties will be used in conjuntion with additional properties obtained from the task - for example, user and password information. This is a convenience wrapper to allow minimimum set of properties to be specified without manipulating the hashtable directly. NOTE: If any of these values are null, they will be ignored.

getMBeanServer

public javax.management.MBeanServer getMBeanServer(java.util.Hashtable contextProps,
                                                   java.lang.String jndiLookupName)
                                            throws org.apache.tools.ant.BuildException
Connects to a JMX server and returns the MBeanServer to use during task execution. The caller is responsible for invoking this method prior to invoking createMBean() or getActiveDomain() methods on this interface. The getInitialContextProperties() method will be invoked prior to this method.
Parameters:
context - The set of properties used to locate and connect to the JMX server.
jndiLookupName - The JNDI entry name for the MBeanServer.

createMBean

public javax.management.ObjectName createMBean(java.lang.String type,
                                               javax.management.ObjectName objectName,
                                               javax.management.MBeanServer mbserver)
                                        throws javax.management.MBeanRegistrationException
Creates & registers an MBean with an MBeanServer. While MBeanServer does have a standard createMBean() method, it is insufficiently supported in some implementations and therefore can't be used directly all the time. If a JMX server does not support MBean creation and registration, this method should always throw javax.management.MBeanRegistrationException, causing the task to fail.
Parameters:
type - The type or classname of the MBean to create.
objectName - The name of the MBean to create.
mbserver - The server where the new MBean will be created.

getActiveDomain

public java.lang.String getActiveDomain(javax.management.MBeanServer mbserver)
Returns the active/default domain for this JMXServer.