com.jrockit.mc.rjmx
Class JMXDescriptorBuilder

java.lang.Object
  extended by com.jrockit.mc.rjmx.JMXDescriptorBuilder

public class JMXDescriptorBuilder
extends java.lang.Object

This class hides the complexities of building a default JMX ConnectionDescriptor in a type safe way. It lets you specify various optional arguments, which are all checked upon building the descriptor.

Author:
Marcus Hirt

Field Summary
static int DEFAULT_PORT
          Port number designator meaning that the default port for the selected protocol should be used.
static int LOOPBACK_PORT
          Port number designator used in conjunction with "localhost" to connect to the in-memory agent.
 
Constructor Summary
JMXDescriptorBuilder()
           
 
Method Summary
 IConnectionDescriptor build()
          Builds the IConnectionDescriptor.
 JMXDescriptorBuilder encryptedPassword(java.lang.String encryptedPassword, java.lang.String encryptionScheme)
          Sets the encrypted password, and what encryption scheme that was used to create it.
 JMXDescriptorBuilder environment(java.util.Map environment)
          Sets the JMX environment.
 JMXDescriptorBuilder exportPassword(boolean exportPassword)
          Sets whether or not to export passwords.
 JMXDescriptorBuilder extendedProperties(java.util.Map extendedProperties)
          Sets the extended properties.
 JMXDescriptorBuilder GUID(java.lang.String guid)
          Sets the globally unique ID to use.
 JMXDescriptorBuilder hostName(java.lang.String hostName)
          Sets the host name.
 JMXDescriptorBuilder name(java.lang.String name)
          Sets the symbolic name of the connection.
 JMXDescriptorBuilder password(java.lang.String password)
          Sets the password.
 JMXDescriptorBuilder port(int port)
          Sets the port for the selected protocol.
 JMXDescriptorBuilder url(javax.management.remote.JMXServiceURL url)
          Sets the service URL.
 JMXDescriptorBuilder useRMP(boolean useRMP)
          Sets whether or not to use RMP.
 JMXDescriptorBuilder userName(java.lang.String userName)
          Sets the user name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOOPBACK_PORT

public static final int LOOPBACK_PORT
Port number designator used in conjunction with "localhost" to connect to the in-memory agent. It has the value 0.

See Also:
Constant Field Values

DEFAULT_PORT

public static final int DEFAULT_PORT
Port number designator meaning that the default port for the selected protocol should be used. It has the value -1.

See Also:
Constant Field Values
Constructor Detail

JMXDescriptorBuilder

public JMXDescriptorBuilder()
Method Detail

url

public JMXDescriptorBuilder url(javax.management.remote.JMXServiceURL url)
Sets the service URL.

Parameters:
url - the JMXServiceURL to use. If the URL is set it will override any host and port settings.
Returns:
the Builder currently being configured.

environment

public JMXDescriptorBuilder environment(java.util.Map environment)
Sets the JMX environment.

Parameters:
environment - the JMX environment to use. Is by default empty.
Returns:
the Builder currently being configured.

extendedProperties

public JMXDescriptorBuilder extendedProperties(java.util.Map extendedProperties)
Sets the extended properties.

Parameters:
extendedProperties - the map of extended properties to use. Is by default empty.
Returns:
the Builder currently being configured.

name

public JMXDescriptorBuilder name(java.lang.String name)
Sets the symbolic name of the connection. Can be a path.

Parameters:
name - the symbolic name of this connection. Is by default derived from the service url. Can be a path, in which case the extended properties ExtendedPropertyKeys.EXTENDED_PROPERTY_KEY_PATH will contain the path element, and the ConnectionName will be set to the name part of the path, if one exists.
Returns:
the Builder currently being configured.

hostName

public JMXDescriptorBuilder hostName(java.lang.String hostName)
Sets the host name.

Parameters:
hostName - the host name to set.
Returns:
the Builder currently being configured.

port

public JMXDescriptorBuilder port(int port)
Sets the port for the selected protocol. This will be the RMI Registry port for jmxrmi. For RMP it will be the management server port.

Parameters:
port - port or DEFAULT_PORT for the default port for the selected protocol. Is DEFAULT_PORT by default.
Returns:
the Builder currently being configured.

userName

public JMXDescriptorBuilder userName(java.lang.String userName)
Sets the user name.

Parameters:
userName - the user name to use in the credentials. Is by default null.
Returns:
the Builder currently being configured.

password

public JMXDescriptorBuilder password(java.lang.String password)
Sets the password.

Parameters:
password - the password to use in the credentials. Is by default null.
Returns:
the Builder currently being configured.

useRMP

public JMXDescriptorBuilder useRMP(boolean useRMP)
Sets whether or not to use RMP.

Parameters:
useRMP - true if JMX over RMP should be used (the old JRockit specific legacy protocol used by JDK 1.4 versions of JRockit, false to use JMX over RMI. Is true by default if running in a JDK 1.4 or less.
Returns:
the Builder currently being configured.

GUID

public JMXDescriptorBuilder GUID(java.lang.String guid)
Sets the globally unique ID to use.

Parameters:
guid - explicitly sets the GUID to be used. Defaults to generating one.
Returns:
the Builder currently being configured.

exportPassword

public JMXDescriptorBuilder exportPassword(boolean exportPassword)
Sets whether or not to export passwords.

Parameters:
exportPassword - set to true to export the password when exporting the connection descriptor to XML. False otherwise. Is false by default.
Returns:
the Builder currently being configured.

encryptedPassword

public JMXDescriptorBuilder encryptedPassword(java.lang.String encryptedPassword,
                                              java.lang.String encryptionScheme)
Sets the encrypted password, and what encryption scheme that was used to create it.

Parameters:
encryptedPassword - the encrypted password.
encryptionScheme - the encryption scheme.
Returns:
the Builder currently being configured.
See Also:
ISecurityManager.getEncryptionScheme()

build

public IConnectionDescriptor build()
                            throws java.lang.IllegalStateException
Builds the IConnectionDescriptor.

Returns:
a freshly created IConnectionDescriptor initialized as per the builder settings.
Throws:
java.lang.IllegalStateException - if the settings were not sufficient to create a proper IConnectionDescriptor.


Copyright © 1999, 2011, Oracle and/or its affiliates. All rights reserved.