APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.jmx.mbeanserver

public Class MBeanInstantiator

extends Object
Class Inheritance
Static Imports
com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER

Implements the MBeanInstantiator interface. Provides methods for instantiating objects, finding the class given its name and using different class loaders, deserializing objects in the context of a given class loader.
Since
1.5

Field Summary

Modifier and TypeField and Description
private final ModifiableClassLoaderRepository
private static final Map<String, Class<?>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public ObjectInputStream

Returns:

The de-serialized object stream.
deserialize
(ClassLoader
the classloader to use for de-serialization
loader
,
byte[]
The byte array to be de-sererialized.
data
)

De-serializes a byte array in the context of a classloader.

public ObjectInputStream

Returns:

The de-serialized object stream.
deserialize
(String
The name of the class whose class loader should be used for the de-serialization.
className
,
ObjectName
The name of the class loader to be used for loading the specified class. If null, a default one has to be provided (for a MBean Server, its own class loader will be used).
loaderName
,
byte[]
The byte array to be de-sererialized.
data
,
ClassLoader loader)

De-serializes a byte array in the context of a given MBean class loader.

private static void
public Class<?>
findClass(String className, ClassLoader loader)

Gets the class for the specified class name using the MBean Interceptor's classloader

public Class<?>
findClass(String className, ObjectName aLoader)

Gets the class for the specified class name using the specified class loader

public Class<?>
findClassWithDefaultLoaderRepository(String className)

Loads the class with the specified name using this object's Default Loader Repository.

private Constructor<?>
findConstructor(Class<?> c, Class<?>[] params)

public Class<?>[]
findSignatureClasses(String[] signature, ClassLoader loader)

Return an array of Class corresponding to the given signature, using the specified class loader.

private ClassLoader
public ModifiableClassLoaderRepository
getClassLoaderRepository()

Return the Default Loader Repository used by this instantiator object.

public Object
instantiate(Class<?> theClass)

Instantiates an object given its class, using its empty constructor.

public Object
instantiate(Class<?> theClass, Object[] params, String[] signature, ClassLoader loader)

Instantiates an object given its class, the parameters and signature of its constructor The call returns a reference to the newly created object.

public Object

Returns:

The newly instantiated object.
instantiate
(String
The class name of the object to be instantiated.
className
)

Instantiates an object using the list of all class loaders registered in the MBean Interceptor (using its javax.management.loading.ClassLoaderRepository).

public Object

Returns:

The newly instantiated object.
instantiate
(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the class loader to be used.
loaderName
,
ClassLoader loader)

Instantiates an object using the class Loader specified by its ObjectName.

public Object

Returns:

The newly instantiated object.
instantiate
(String
The class name of the object to be instantiated.
className
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
,
ClassLoader loader)

Instantiates an object using the list of all class loaders registered in the MBean server (using its javax.management.loading.ClassLoaderRepository).

public Object

Returns:

The newly instantiated object.
instantiate
(String
The class name of the object to be instantiated.
className
,
ObjectName
The object name of the class loader to be used.
loaderName
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
,
ClassLoader loader)

Instantiates an object.

pack-priv static Class<?>
loadClass(String className, ClassLoader loader)

Load a class with the specified loader, or with this object class loader if the specified loader is null.

pack-priv static Class<?>[]
loadSignatureClasses(String[] signature, ClassLoader loader)

Load the classes specified in the signature with the given loader, or with this object class loader.

public void
testCreation(Class<?> c)

This methods tests if the MBean class makes it possible to instantiate an MBean of this class in the MBeanServer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clrback to summary
private final ModifiableClassLoaderRepository clr
primitiveClassesback to summary
private static final Map<String, Class<?>> primitiveClasses

Constructor Detail

MBeanInstantiatorback to summary
pack-priv MBeanInstantiator(ModifiableClassLoaderRepository clr)

Method Detail

deserializeback to summary
public ObjectInputStream deserialize(ClassLoader loader, byte[] data) throws OperationsException

De-serializes a byte array in the context of a classloader.

Parameters
loader:ClassLoader

the classloader to use for de-serialization

data:byte[]

The byte array to be de-sererialized.

Returns:ObjectInputStream

The de-serialized object stream.

Exceptions
OperationsException:
Any of the usual Input/Output related exceptions.
deserializeback to summary
public ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] data, ClassLoader loader) throws InstanceNotFoundException, OperationsException, ReflectionException

De-serializes a byte array in the context of a given MBean class loader.

The class loader is the one that loaded the class with name "className".

The name of the class loader to be used for loading the specified class is specified. If null, a default one has to be provided (for a MBean Server, its own class loader will be used).

Parameters
className:String

The name of the class whose class loader should be used for the de-serialization.

loaderName:ObjectName

The name of the class loader to be used for loading the specified class. If null, a default one has to be provided (for a MBean Server, its own class loader will be used).

data:byte[]

The byte array to be de-sererialized.

Returns:ObjectInputStream

The de-serialized object stream.

Exceptions
InstanceNotFoundException:
The specified class loader MBean is not found.
OperationsException:
Any of the usual Input/Output related exceptions.
ReflectionException:
The specified class could not be loaded by the specified class loader.
ensureClassAccessback to summary
private static void ensureClassAccess(Class<?> clazz) throws IllegalAccessException
findClassback to summary
public Class<?> findClass(String className, ClassLoader loader) throws ReflectionException

Gets the class for the specified class name using the MBean Interceptor's classloader

findClassback to summary
public Class<?> findClass(String className, ObjectName aLoader) throws ReflectionException, InstanceNotFoundException

Gets the class for the specified class name using the specified class loader

findClassWithDefaultLoaderRepositoryback to summary
public Class<?> findClassWithDefaultLoaderRepository(String className) throws ReflectionException

Loads the class with the specified name using this object's Default Loader Repository.

findConstructorback to summary
private Constructor<?> findConstructor(Class<?> c, Class<?>[] params)
findSignatureClassesback to summary
public Class<?>[] findSignatureClasses(String[] signature, ClassLoader loader) throws ReflectionException

Return an array of Class corresponding to the given signature, using the specified class loader.

getClassLoaderback to summary
private ClassLoader getClassLoader(final ObjectName name)
getClassLoaderRepositoryback to summary
public ModifiableClassLoaderRepository getClassLoaderRepository()

Return the Default Loader Repository used by this instantiator object.

instantiateback to summary
public Object instantiate(Class<?> theClass) throws ReflectionException, MBeanException

Instantiates an object given its class, using its empty constructor. The call returns a reference to the newly created object.

instantiateback to summary
public Object instantiate(Class<?> theClass, Object[] params, String[] signature, ClassLoader loader) throws ReflectionException, MBeanException

Instantiates an object given its class, the parameters and signature of its constructor The call returns a reference to the newly created object.

instantiateback to summary
public Object instantiate(String className) throws ReflectionException, MBeanException

Instantiates an object using the list of all class loaders registered in the MBean Interceptor (using its javax.management.loading.ClassLoaderRepository).

The object's class should have a public constructor.

It returns a reference to the newly created object.

The newly created object is not registered in the MBean Interceptor.

Parameters
className:String

The class name of the object to be instantiated.

Returns:Object

The newly instantiated object.

Exceptions
ReflectionException:
Wraps a java.lang.ClassNotFoundException or the java.lang.Exception that occurred when trying to invoke the object's constructor.
MBeanException:
The constructor of the object has thrown an exception
RuntimeOperationsException:
Wraps a java.lang.IllegalArgumentException: the className passed in parameter is null.
instantiateback to summary
public Object instantiate(String className, ObjectName loaderName, ClassLoader loader) throws ReflectionException, MBeanException, InstanceNotFoundException

Instantiates an object using the class Loader specified by its ObjectName.

If the loader name is null, a default one has to be provided (for a MBean Server, the ClassLoader that loaded it will be used).

The object's class should have a public constructor.

It returns a reference to the newly created object.

The newly created object is not registered in the MBean Interceptor.

Parameters
className:String

The class name of the MBean to be instantiated.

loaderName:ObjectName

The object name of the class loader to be used.

Returns:Object

The newly instantiated object.

Exceptions
ReflectionException:
Wraps a java.lang.ClassNotFoundException or the java.lang.Exception that occurred when trying to invoke the object's constructor.
MBeanException:
The constructor of the object has thrown an exception.
InstanceNotFoundException:
The specified class loader is not registered in the MBeanServerInterceptor.
RuntimeOperationsException:
Wraps a java.lang.IllegalArgumentException: the className passed in parameter is null.
instantiateback to summary
public Object instantiate(String className, Object[] params, String[] signature, ClassLoader loader) throws ReflectionException, MBeanException

Instantiates an object using the list of all class loaders registered in the MBean server (using its javax.management.loading.ClassLoaderRepository).

The object's class should have a public constructor.

The call returns a reference to the newly created object.

The newly created object is not registered in the MBean Interceptor.

Parameters
className:String

The class name of the object to be instantiated.

params:Object[]

An array containing the parameters of the constructor to be invoked.

signature:String[]

An array containing the signature of the constructor to be invoked.

Returns:Object

The newly instantiated object.

Exceptions
ReflectionException:
Wraps a java.lang.ClassNotFoundException or the java.lang.Exception that occurred when trying to invoke the object's constructor.
MBeanException:
The constructor of the object has thrown an exception
RuntimeOperationsException:
Wraps a java.lang.IllegalArgumentException: the className passed in parameter is null.
instantiateback to summary
public Object instantiate(String className, ObjectName loaderName, Object[] params, String[] signature, ClassLoader loader) throws ReflectionException, MBeanException, InstanceNotFoundException

Instantiates an object. The class loader to be used is identified by its object name.

If the object name of the loader is null, a default has to be provided (for example, for a MBean Server, the ClassLoader that loaded it will be used).

The object's class should have a public constructor.

The call returns a reference to the newly created object.

The newly created object is not registered in the MBean server.

Parameters
className:String

The class name of the object to be instantiated.

loaderName:ObjectName

The object name of the class loader to be used.

params:Object[]

An array containing the parameters of the constructor to be invoked.

signature:String[]

An array containing the signature of the constructor to be invoked.

Returns:Object

The newly instantiated object.

Exceptions
ReflectionException:
Wraps a java.lang.ClassNotFoundException or the java.lang.Exception that occurred when trying to invoke the object's constructor.
MBeanException:
The constructor of the object has thrown an exception
InstanceNotFoundException:
The specified class loader is not registered in the MBean Interceptor.
RuntimeOperationsException:
Wraps a java.lang.IllegalArgumentException: the className passed in parameter is null.
loadClassback to summary
pack-priv static Class<?> loadClass(String className, ClassLoader loader) throws ReflectionException

Load a class with the specified loader, or with this object class loader if the specified loader is null.

loadSignatureClassesback to summary
pack-priv static Class<?>[] loadSignatureClasses(String[] signature, ClassLoader loader) throws ReflectionException

Load the classes specified in the signature with the given loader, or with this object class loader.

testCreationback to summary
public void testCreation(Class<?> c) throws NotCompliantMBeanException

This methods tests if the MBean class makes it possible to instantiate an MBean of this class in the MBeanServer. e.g. it must have a public constructor, be a concrete class...