Top Inners Fields Constructors Methods
com.sun.jmx.remote.util

public Class EnvHelp

extends Object
Class Inheritance
Imports
java.io.IOException, .ObjectOutputStream, .OutputStream, java.util.Collection, .HashMap, .Hashtable, .Iterator, .Map, .SortedMap, .SortedSet, .StringTokenizer, .TreeMap, .TreeSet, java.security.AccessController, javax.management.ObjectName, .MBeanServer, .InstanceNotFoundException, javax.management.remote.JMXConnectorFactory, .JMXConnectorServerFactory, com.sun.jmx.mbeanserver.GetPropertyAction, com.sun.jmx.remote.security.NotificationAccessController

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
public static final String
BUFFER_SIZE_PROPERTY

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

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.

private static final String
DEFAULT_CLASS_LOADER

Name of the attribute that specifies a default class loader object.

private static final String
DEFAULT_CLASS_LOADER_NAME

Name of the attribute that specifies a default class loader ObjectName.

public static final String
DEFAULT_HIDDEN_ATTRIBUTES

Default list of attributes not to show.

public static final String
private static final SortedSet<String>
private static final SortedSet<String>
public static final String
FETCH_TIMEOUT

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

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().

public static final String
JMX_SERVER_DAEMON

Name of the attribute that specifies whether a connector server should not prevent the VM from exiting

private static final ClassLogger
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.

public static final String
NOTIF_ACCESS_CONTROLLER

Name of the attribute that specifies an object that will check accesses to add/removeNotificationListener and also attempts to receive notifications.

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.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
checkAttributes(Map<?, ?> attributes)

public static boolean

Returns:

  • false if stringBoolean is null
  • false if stringBoolean.equalsIgnoreCase("false") is true
  • true if stringBoolean.equalsIgnoreCase("true") is true
computeBooleanFromString
(String
the string value that must be converted into a boolean value.
stringBoolean
)

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

public static boolean

Returns:

  • defaultValue if stringBoolean is null
  • false if stringBoolean.equalsIgnoreCase("false") is true
  • true if stringBoolean.equalsIgnoreCase("true") is true
computeBooleanFromString
(String
the string value that must be converted into a boolean value.
stringBoolean
,
boolean
a default value to return in case no property was defined.
defaultValue
)

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

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

public static Throwable

Returns:

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

Returns the cause field of a Throwable object.

public static long
getConnectionCheckPeriod(Map<String, ?> env)

Returns the client connection check period.

public static long
getFetchTimeout(Map<String, ?> env)

Returns the timeout for a client to fetch notifications.

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

Get an integer-valued attribute with name name from env.

public static int
getMaxFetchNotifNumber(Map<String, ?> env)

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

public static int
getNotifBufferSize(Map<String, ?> env)

Returns the size of a notification buffer for a connector server.

public static NotificationAccessController
public static long
getServerConnectionTimeout(Map<String, ?> env)

Returns the server side connection timeout.

private static void
public static <T extends Throwable> T

Returns:

the Throwable with the cause field initialized.
initCause
(T
The Throwable on which the cause is set.
throwable
,
Throwable
The cause to set on the supplied Throwable.
cause
)

Initialize the cause field of a Throwable object.

public static boolean
isServerDaemon(Map<String, ?> env)

Returns true if jmx.remote.x.daemon is specified in the env as a key and its value is a String and it is equal to true ignoring case.

public static <K, V> 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.

private static void
parseHiddenAttributes(String hide, SortedSet<String> hiddenStrings, SortedSet<String> hiddenPrefixes)

private static void
purgeUnserializable(Collection<?> objects)

Remove from the given Collection any element that is not a serializable object.

public static ClassLoader

Returns:

The connector client default class loader.
resolveClientClassLoader
(Map<String, ?> env)

Get the Connector Client default class loader.

public static ClassLoader

Returns:

the connector server's default class loader.
resolveServerClassLoader
(Map<String, ?>
Environment attributes.
env
,
MBeanServer
The MBeanServer for which the connector server provides remote access.
mbs
)

Get the Connector Server default class loader.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUFFER_SIZE_PROPERTYback to summary
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.

CLIENT_CONNECTION_CHECK_PERIODback to summary
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.

DEFAULT_CLASS_LOADERback to summary
private static final String DEFAULT_CLASS_LOADER

Name of the attribute that specifies a default class loader object. The value associated with this attribute is a ClassLoader object.

DEFAULT_CLASS_LOADER_NAMEback to summary
private static final String DEFAULT_CLASS_LOADER_NAME

Name of the attribute that specifies a default class loader ObjectName. The value associated with this attribute is an ObjectName object.

DEFAULT_HIDDEN_ATTRIBUTESback to summary
public static final String DEFAULT_HIDDEN_ATTRIBUTES

Default list of attributes not to show.

See Also
HIDDEN_ATTRIBUTES
DEFAULT_ORBback to summary
public static final String DEFAULT_ORB
defaultHiddenPrefixesback to summary
private static final SortedSet<String> defaultHiddenPrefixes
defaultHiddenStringsback to summary
private static final SortedSet<String> defaultHiddenStrings
FETCH_TIMEOUTback to summary
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.

HIDDEN_ATTRIBUTESback to summary
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.

JMX_SERVER_DAEMONback to summary
public static final String JMX_SERVER_DAEMON

Name of the attribute that specifies whether a connector server should not prevent the VM from exiting

loggerback to summary
private static final ClassLogger logger
MAX_FETCH_NOTIFSback to summary
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.

NOTIF_ACCESS_CONTROLLERback to summary
public static final String NOTIF_ACCESS_CONTROLLER

Name of the attribute that specifies an object that will check accesses to add/removeNotificationListener and also attempts to receive notifications. The value associated with this attribute should be a NotificationAccessController object. The default value is null.

This field is not public because of its com.sun dependency.

SERVER_CONNECTION_TIMEOUTback to summary
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.

Constructor Detail

EnvHelpback to summary
public EnvHelp()

Method Detail

checkAttributesback to summary
public static void checkAttributes(Map<?, ?> attributes)
computeBooleanFromStringback to summary
public static boolean computeBooleanFromString(String stringBoolean)

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

Parameters
stringBoolean:String

the string value that must be converted into a boolean value.

Returns:boolean

  • false if stringBoolean is null
  • false if stringBoolean.equalsIgnoreCase("false") is true
  • true if stringBoolean.equalsIgnoreCase("true") is true
Exceptions
IllegalArgumentException:
if ((String)env.get(prop)).equalsIgnoreCase("false") and ((String)env.get(prop)).equalsIgnoreCase("true") are false.
computeBooleanFromStringback to summary
public static boolean computeBooleanFromString(String stringBoolean, boolean defaultValue)

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

Parameters
stringBoolean:String

the string value that must be converted into a boolean value.

defaultValue:boolean

a default value to return in case no property was defined.

Returns:boolean

  • defaultValue if stringBoolean is null
  • false if stringBoolean.equalsIgnoreCase("false") is true
  • true if stringBoolean.equalsIgnoreCase("true") is true
Exceptions
IllegalArgumentException:
if ((String)env.get(prop)).equalsIgnoreCase("false") and ((String)env.get(prop)).equalsIgnoreCase("true") are false.
filterAttributesback to summary
public static <V> Map<String, V> filterAttributes(Map<String, V> attributes)
getCauseback to summary
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 Throwable#getCause() method (JDK Version >= 1.4)

Parameters
t:Throwable

Throwable on which the cause must be set.

Returns:Throwable

the cause if getCause() succeeded and the got value is not null, otherwise return the t.

getConnectionCheckPeriodback to summary
public static long getConnectionCheckPeriod(Map<String, ?> env)

Returns the client connection check period.

getFetchTimeoutback to summary
public static long getFetchTimeout(Map<String, ?> env)

Returns the timeout for a client to fetch notifications.

getIntegerAttributeback to summary
public static long getIntegerAttribute(Map<String, ?> 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.

Exceptions
IllegalArgumentException:
if env contains an entry for name but it does not meet the constraints above.
getMaxFetchNotifNumberback to summary
public static int getMaxFetchNotifNumber(Map<String, ?> env)

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

getNotifBufferSizeback to summary
public static int getNotifBufferSize(Map<String, ?> env)

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

Annotations
@SuppressWarnings:removal
getNotificationAccessControllerback to summary
public static NotificationAccessController getNotificationAccessController(Map<String, ?> env)
getServerConnectionTimeoutback to summary
public static long getServerConnectionTimeout(Map<String, ?> env)

Returns the server side connection timeout.

hideAttributesback to summary
private static void hideAttributes(SortedMap<String, ?> map)
initCauseback to summary
public static <T extends Throwable> T initCause(T throwable, Throwable cause)

Initialize the cause field of a Throwable object.

Parameters
throwable:T

The Throwable on which the cause is set.

cause:Throwable

The cause to set on the supplied Throwable.

Returns:T

the Throwable with the cause field initialized.

isServerDaemonback to summary
public static boolean isServerDaemon(Map<String, ?> env)

Returns true if jmx.remote.x.daemon is specified in the env as a key and its value is a String and it is equal to true ignoring case.

mapToHashtableback to summary
public static <K, V> 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.

parseHiddenAttributesback to summary
private static void parseHiddenAttributes(String hide, SortedSet<String> hiddenStrings, SortedSet<String> hiddenPrefixes)
purgeUnserializableback to summary
private static void purgeUnserializable(Collection<?> objects)

Remove from the given Collection any element that is not a serializable object.

resolveClientClassLoaderback to summary
public static ClassLoader resolveClientClassLoader(Map<String, ?> 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:ClassLoader

The connector client default class loader.

Exceptions
IllegalArgumentException:
if jmx.remote.default.class.loader is specified and is not an instance of ClassLoader.
resolveServerClassLoaderback to summary
public static ClassLoader resolveServerClassLoader(Map<String, ?> env, MBeanServer mbs) throws InstanceNotFoundException

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:Map<String, ?>

Environment attributes.

mbs:MBeanServer

The MBeanServer for which the connector server provides remote access.

Returns:ClassLoader

the connector server's default class loader.

Exceptions
InstanceNotFoundException:
if jmx.remote.default.class.loader.name is specified and the ClassLoader MBean is not found in mbs.
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.
com.sun.jmx.remote.util back to summary

private final Class EnvHelp.SinkOutputStream

extends OutputStream
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
write(byte[]
the data.
b
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

public void
write(int
the byte.
b
)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

Inherited from java.io.OutputStream:
closeflushnullOutputStreamwrite

Constructor Detail

SinkOutputStreamback to summary
private SinkOutputStream()

Method Detail

writeback to summary
public void write(byte[] b, int off, int len)

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Parameters
b:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

writeback to summary
public void write(int b)

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Parameters
b:int

the byte.