javax.management.remote.generic
Interface ObjectWrapping


public interface ObjectWrapping

An interface that defines how to wrap parameters that use a non-default class loader. A GenericConnector can specify an instance of this interface to define a connection-specific wrapping.

Certain parameters to MBeanServerConnection methods have to be wrapped because their class loader is not necessarily known to the remote connector server.

For example, when calling setAttribute on an MBean X, the attribute value v to be set might be of a class that is known to X's class loader but not to the class loader of the connector server. If v were not wrapped, the connector server would receive it at the same time as it received other information such as X's ObjectName. The whole request would fail because of the inability to find the v's class.

Object wrapping solves this problem by encoding v inside an object of a type that is known to the connector server, such as byte[] or String. Then v is recreated using X's class loader, which the connector server can know once X's name has been successfully received.

An instance of this class can be communicated to the Generic Connector or Generic Connector Server using the attribute GenericConnector.OBJECT_WRAPPING.

The default ObjectWrapping wraps objects in a byte array that contains the output of ObjectOutputStream.writeObject for the given object in a new ObjectOutputStream.


Method Summary
 Object unwrap(Object wrapped, ClassLoader cloader)
          Unwraps an object.
 Object wrap(Object obj)
          Wraps an object.
 

Method Detail

wrap

Object wrap(Object obj)
            throws IOException
Wraps an object.

Parameters:
obj - the object to be wrapped.
Returns:
the wrapped object.
Throws:
IOException - if the object cannot be wrapped for some reason.

unwrap

Object unwrap(Object wrapped,
              ClassLoader cloader)
              throws IOException,
                     ClassNotFoundException
Unwraps an object.

Parameters:
wrapped - the wrapped object to be unwrapped.
cloader - the class loader to be used to load the object's class. Can be null, meaning the bootstrap class loader.
Returns:
the unwrapped object.
Throws:
ClassNotFoundException - if the class that the unwrapped object should have is not known to the given class loader.
IOException - if the object cannot be unwrapped for some reason.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.