public class

EnvHelp

extends Object
java.lang.Object
   ↳ com.sun.jmx.remote.util.EnvHelp

Summary

Constants
String BUFFER_SIZE_PROPERTY

Name of the attribute that specifies the size of a notification buffer for a connector server.

String CLIENT_CONNECTION_CHECK_PERIOD

Name of the attribute that specifies the period in millisecond for a client to check its connection.

String DEFAULT_HIDDEN_ATTRIBUTES Default list of attributes not to show.
String DEFAULT_ORB
String FETCH_TIMEOUT

Name of the attribute that specifies the timeout for a client to fetch notifications from its server.

String HIDDEN_ATTRIBUTES The value of this attribute, if present, is a string specifying what other attributes should not appear in JMXConnectorServer.getAttributes().
String MAX_FETCH_NOTIFS

Name of the attribute that specifies the maximum number of notifications that a client will fetch from its server..

String SERVER_CONNECTION_TIMEOUT

Name of the attribute that specifies the timeout to keep a server side connection after answering last client request.

Public Constructors
EnvHelp()
Public Methods
static void checkAttributes(Map attributes)
static boolean computeBooleanFromString(Map env, String prop)
Computes a boolean value from a string value retrieved from a property in the given map.
static <V> Map<String, V> filterAttributes(Map<String, V> attributes)
static Throwable getCause(Throwable t)
Returns the cause field of a Throwable object.
static long getConnectionCheckPeriod(Map env)
Returns the client connection check period.
static long getFetchTimeout(Map env)
Returns the timeout for a client to fetch notifications.
static long getIntegerAttribute(Map env, String name, long defaultValue, long minValue, long maxValue)
Get an integer-valued attribute with name name from env.
static int getMaxFetchNotifNumber(Map env)
Returns the maximum notification number which a client will fetch every time.
static int getNotifBufferSize(Map env)
Returns the size of a notification buffer for a connector server.
static long getServerConnectionTimeout(Map env)
Returns the server side connection timeout.
static <T extends Throwable> T initCause(T throwable, Throwable cause)
Initialize the cause field of a Throwable object.
static <K, V> Hashtable<K, V> mapToHashtable(Map<K, V> map)
Converts a map into a valid hash table, i.e.
static ClassLoader resolveClientClassLoader(Map env)
Get the Connector Client default class loader.
static ClassLoader resolveServerClassLoader(Map env, MBeanServer mbs)
Get the Connector Server default class loader.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String BUFFER_SIZE_PROPERTY

Name of the attribute that specifies the size of a notification buffer for a connector server. The default value is 1000.

Constant Value: "jmx.remote.x.notification.buffer.size"

public static final String CLIENT_CONNECTION_CHECK_PERIOD

Name of the attribute that specifies the period in millisecond for a client to check its connection. The default value is 60000 milliseconds.

Constant Value: "jmx.remote.x.client.connection.check.period"

public static final String DEFAULT_HIDDEN_ATTRIBUTES

Default list of attributes not to show.

Constant Value: "java.naming.security.* jmx.remote.authenticator jmx.remote.context jmx.remote.default.class.loader jmx.remote.message.connection.server jmx.remote.object.wrapping jmx.remote.rmi.client.socket.factory jmx.remote.rmi.server.socket.factory jmx.remote.sasl.callback.handler jmx.remote.tls.socket.factory jmx.remote.x.access.file jmx.remote.x.password.file "

public static final String DEFAULT_ORB

Constant Value: "java.naming.corba.orb"

public static final String FETCH_TIMEOUT

Name of the attribute that specifies the timeout for a client to fetch notifications from its server. The value associated with this attribute should be a Long object. The default value is 60000 milliseconds.

Constant Value: "jmx.remote.x.notification.fetch.timeout"

public static final String HIDDEN_ATTRIBUTES

The value of this attribute, if present, is a string specifying what other attributes should not appear in JMXConnectorServer.getAttributes(). It is a space-separated list of attribute patterns, where each pattern is either an attribute name, or an attribute prefix followed by a "*" character. The "*" has no special significance anywhere except at the end of a pattern. By default, this list is added to the list defined by DEFAULT_HIDDEN_ATTRIBUTES (which uses the same format). If the value of this attribute begins with an "=", then the remainder of the string defines the complete list of attribute patterns.

Constant Value: "jmx.remote.x.hidden.attributes"

public static final String MAX_FETCH_NOTIFS

Name of the attribute that specifies the maximum number of notifications that a client will fetch from its server.. The value associated with this attribute should be an Integer object. The default value is 1000.

Constant Value: "jmx.remote.x.notification.fetch.max"

public static final String SERVER_CONNECTION_TIMEOUT

Name of the attribute that specifies the timeout to keep a server side connection after answering last client request. The default value is 120000 milliseconds.

Constant Value: "jmx.remote.x.server.connection.timeout"

Public Constructors

public EnvHelp ()

Public Methods

public static void checkAttributes (Map attributes)

public static boolean computeBooleanFromString (Map env, String prop)

Computes a boolean value from a string value retrieved from a property in the given map.

Parameters
env the environment map.
prop the name of the property in the environment map whose returned string value must be converted into a boolean value.
Returns
    • false if env.get(prop) is null
    • false if ((String)env.get(prop)).equalsIgnoreCase("false") is true
    • true if ((String)env.get(prop)).equalsIgnoreCase("true") is true
Throws
IllegalArgumentException if env is null or env.get(prop) is not null and ((String)env.get(prop)).equalsIgnoreCase("false") and ((String)env.get(prop)).equalsIgnoreCase("true") are false.
ClassCastException if env.get(prop) cannot be cast to String.

public static Map<String, V> filterAttributes (Map<String, V> attributes)

public static Throwable getCause (Throwable t)

Returns the cause field of a Throwable object. The cause field can be got only if t has an getCause() method (JDK Version >= 1.4)

Parameters
t Throwable on which the cause must be set.
Returns
  • the cause if getCause() succeeded and the got value is not null, otherwise return the t.

public static long getConnectionCheckPeriod (Map env)

Returns the client connection check period.

public static long getFetchTimeout (Map env)

Returns the timeout for a client to fetch notifications.

public static long getIntegerAttribute (Map env, String name, long defaultValue, long minValue, long maxValue)

Get an integer-valued attribute with name name from env. If env is null, or does not contain an entry for name, return defaultValue. The value may be a Number, or it may be a String that is parsable as a long. It must be at least minValue and at mostmaxValue.

Throws
IllegalArgumentException if env contains an entry for name but it does not meet the constraints above.

public static int getMaxFetchNotifNumber (Map env)

Returns the maximum notification number which a client will fetch every time.

public static int getNotifBufferSize (Map env)

Returns the size of a notification buffer for a connector server. The default value is 1000.

public static long getServerConnectionTimeout (Map env)

Returns the server side connection timeout.

public static T initCause (T throwable, Throwable cause)

Initialize the cause field of a Throwable object.

Parameters
throwable The Throwable on which the cause is set.
cause The cause to set on the supplied Throwable.
Returns
  • the Throwable with the cause field initialized.

public static Hashtable<K, V> mapToHashtable (Map<K, V> map)

Converts a map into a valid hash table, i.e. it removes all the 'null' values from the map.

public static ClassLoader resolveClientClassLoader (Map env)

Get the Connector Client default class loader.

Returns:

  • The ClassLoader object found in env for jmx.remote.default.class.loader, if any.
  • The Thread.currentThread().getContextClassLoader() otherwise.

Usually a Connector Client will call

 ClassLoader dcl = EnvHelp.resolveClientClassLoader(env);
 
in its connect(Map env) method.

Returns
  • The connector client default class loader.
Throws
IllegalArgumentException if jmx.remote.default.class.loader is specified and is not an instance of ClassLoader.

public static ClassLoader resolveServerClassLoader (Map env, MBeanServer mbs)

Get the Connector Server default class loader.

Returns:

  • The ClassLoader object found in env for jmx.remote.default.class.loader, if any.
  • The ClassLoader pointed to by the ObjectName found in env for jmx.remote.default.class.loader.name, and registered in mbs if any.
  • The current thread's context classloader otherwise.

Parameters
env Environment attributes.
mbs The MBeanServer for which the connector server provides remote access.
Returns
  • the connector server's default class loader.
Throws
IllegalArgumentException if one of the following is true:
  • both jmx.remote.default.class.loader and jmx.remote.default.class.loader.name are specified,
  • or jmx.remote.default.class.loader is not an instance of ClassLoader,
  • or jmx.remote.default.class.loader.name is not an instance of ObjectName,
  • or jmx.remote.default.class.loader.name is specified but mbs is null.
InstanceNotFoundException if jmx.remote.default.class.loader.name is specified and the ClassLoader MBean is not found in mbs.