/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* <p>Implementation of the {@link RMIConnection} interface. User
* code will not usually reference this class.</p>
*
* @since 1.5
*/
/*
* Notice that we omit the type parameter from MarshalledObject everywhere,
* even though it would add useful information to the documentation. The
* reason is that it was only added in Mustang (Java SE 6), whereas versions
* 1.4 and 2.0 of the JMX API must be implementable on Tiger per our
* commitments for JSR 255.
*/
/**
* Constructs a new {@link RMIConnection}. This connection can be
* used with either the JRMP or IIOP transport. This object does
* not export itself: it is the responsibility of the caller to
* export it appropriately (see {@link
* RMIJRMPServerImpl#makeClient(String,Subject)} and {@link
* RMIIIOPServerImpl#makeClient(String,Subject)}.
*
* @param rmiServer The RMIServerImpl object for which this
* connection is created. The behavior is unspecified if this
* parameter is null.
* @param connectionId The ID for this connection. The behavior
* is unspecified if this parameter is null.
* @param defaultClassLoader The default ClassLoader to be used
* when deserializing marshalled objects. Can be null, to signify
* the bootstrap class loader.
* @param subject the authenticated subject to be used for
* authorization. Can be null, to signify that no subject has
* been authenticated.
* @param env the environment containing attributes for the new
* <code>RMIServerImpl</code>. Can be null, equivalent to an
* empty map.
*/
throw new NullPointerException("Illegal null argument");
this.connectionId = connectionId;
this.defaultClassLoader = defaultClassLoader;
this.subjectDelegator = new SubjectDelegator();
this.removeCallerContext = false;
} else {
this.removeCallerContext =
if (this.removeCallerContext) {
this.acc =
} else {
this.acc =
}
}
this.classLoaderWithRepository =
public ClassLoaderWithRepository run() {
return new ClassLoaderWithRepository(
dcl);
}
},
new RuntimePermission("createClassLoader"))
);
this.defaultContextClassLoader =
new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
dcl);
}
});
serverCommunicatorAdmin = new
}
}
}
// Lazily created when first use. Mainly when
// addNotificationListener is first called.
if (serverNotifForwarder == null)
env,
return serverNotifForwarder;
}
// We should call reqIncomming() here... shouldn't we?
return connectionId;
}
synchronized (this) {
if (terminated) {
return;
}
terminated = true;
if (serverCommunicatorAdmin != null) {
}
if (serverNotifForwarder != null) {
}
}
rmiServer.clientClosed(this);
}
public void unreferenced() {
try {
close();
} catch (IOException e) {
}
}
//-------------------------------------------------------------------------
// MBeanServerConnection Wrapper
//-------------------------------------------------------------------------
throws
try {
return (ObjectInstance)
} catch (PrivilegedActionException pe) {
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof InstanceAlreadyExistsException)
throw (InstanceAlreadyExistsException) e;
if (e instanceof MBeanRegistrationException)
throw (MBeanRegistrationException) e;
if (e instanceof MBeanException)
throw (MBeanException) e;
if (e instanceof NotCompliantMBeanException)
throw (NotCompliantMBeanException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
try {
"connectionId=" + connectionId
+", className=" + className
+", name=" + name
+", loaderName=" + loaderName);
return (ObjectInstance)
} catch (PrivilegedActionException pe) {
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof InstanceAlreadyExistsException)
throw (InstanceAlreadyExistsException) e;
if (e instanceof MBeanRegistrationException)
throw (MBeanRegistrationException) e;
if (e instanceof MBeanException)
throw (MBeanException) e;
if (e instanceof NotCompliantMBeanException)
throw (NotCompliantMBeanException) e;
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
"createMBean(String,ObjectName,Object[],String[])",
"connectionId=" + connectionId
+", unwrapping parameters using classLoaderWithRepository.");
values =
try {
nullIsEmpty(signature) };
if (debug)
"connectionId=" + connectionId
+", className=" + className
+", name=" + name
return (ObjectInstance)
} catch (PrivilegedActionException pe) {
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof InstanceAlreadyExistsException)
throw (InstanceAlreadyExistsException) e;
if (e instanceof MBeanRegistrationException)
throw (MBeanRegistrationException) e;
if (e instanceof MBeanException)
throw (MBeanException) e;
if (e instanceof NotCompliantMBeanException)
throw (NotCompliantMBeanException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
"createMBean(String,ObjectName,ObjectName,Object[],String[])",
"connectionId=" + connectionId
+", unwrapping params with MBean extended ClassLoader.");
Object[].class));
try {
nullIsEmpty(signature) };
"createMBean(String,ObjectName,ObjectName,Object[],String[])",
"connectionId=" + connectionId
+", className=" + className
+", name=" + name
+", loaderName=" + loaderName
return (ObjectInstance)
} catch (PrivilegedActionException pe) {
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof InstanceAlreadyExistsException)
throw (InstanceAlreadyExistsException) e;
if (e instanceof MBeanRegistrationException)
throw (MBeanRegistrationException) e;
if (e instanceof MBeanException)
throw (MBeanException) e;
if (e instanceof NotCompliantMBeanException)
throw (NotCompliantMBeanException) e;
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
try {
"connectionId=" + connectionId
+", name="+name);
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof MBeanRegistrationException)
throw (MBeanRegistrationException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
try {
"connectionId=" + connectionId
+", name="+name);
return (ObjectInstance)
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
public Set<ObjectInstance>
throws IOException {
final QueryExp queryValue;
"connectionId=" + connectionId
+" unwrapping query with defaultClassLoader.");
try {
"connectionId=" + connectionId
return cast(
} catch (PrivilegedActionException pe) {
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
public Set<ObjectName>
throws IOException {
final QueryExp queryValue;
"connectionId=" + connectionId
+" unwrapping query with defaultClassLoader.");
try {
"connectionId=" + connectionId
return cast(
} catch (PrivilegedActionException pe) {
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
try {
return ((Boolean)
} catch (PrivilegedActionException pe) {
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws IOException {
try {
"connectionId=" + connectionId);
return (Integer)
} catch (PrivilegedActionException pe) {
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
try {
"connectionId=" + connectionId
+", name=" + name
+", attribute="+ attribute);
return
} catch (PrivilegedActionException pe) {
if (e instanceof MBeanException)
throw (MBeanException) e;
if (e instanceof AttributeNotFoundException)
throw (AttributeNotFoundException) e;
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
String[] attributes,
throws
try {
"connectionId=" + connectionId
+", name=" + name
return (AttributeList)
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
"connectionId=" + connectionId
+" unwrapping attribute with MBean extended ClassLoader.");
Attribute.class);
try {
"connectionId=" + connectionId
+", name="+name
+", attribute="+attr);
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof AttributeNotFoundException)
throw (AttributeNotFoundException) e;
if (e instanceof InvalidAttributeValueException)
throw (InvalidAttributeValueException) e;
if (e instanceof MBeanException)
throw (MBeanException) e;
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
final AttributeList attrlist;
"connectionId=" + connectionId
+" unwrapping attributes with MBean extended ClassLoader.");
attrlist =
AttributeList.class);
try {
"connectionId=" + connectionId
+", name="+name
+", attributes="+attrlist);
return (AttributeList)
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
"connectionId=" + connectionId
+" unwrapping params with MBean extended ClassLoader.");
Object[].class));
try {
nullIsEmpty(signature) };
"connectionId=" + connectionId
+", name="+name
+", operationName="+operationName
return
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof MBeanException)
throw (MBeanException) e;
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws IOException {
try {
"connectionId=" + connectionId);
return (String)
} catch (PrivilegedActionException pe) {
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
try {
"connectionId=" + connectionId);
return (String[])
} catch (PrivilegedActionException pe) {
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
try {
"connectionId=" + connectionId
+", name="+name);
return (MBeanInfo)
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof IntrospectionException)
throw (IntrospectionException) e;
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws InstanceNotFoundException, IOException {
try {
"connectionId=" + connectionId
+", name="+name
+", className="+className);
return ((Boolean)
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws InstanceNotFoundException, IOException {
throw new IllegalArgumentException("Got null arguments.");
}
"The value lengths of 3 parameters are not same.";
throw new IllegalArgumentException(msg);
}
throw new IllegalArgumentException("Null Object name.");
}
}
int i=0;
try {
"(ObjectName,NotificationFilter)",
"connectionId=" + connectionId +
" unwrapping filter with target extended ClassLoader.");
filterValues[i] =
NotificationFilter.class);
"(ObjectName,NotificationFilter)",
"connectionId=" + connectionId
+", name=" + names[i]
+", filter=" + filterValues[i]);
filterValues[i] },
sbjs[i]);
}
return ids;
} catch (Exception e) {
// remove all registered listeners
for (int j=0; j<i; j++) {
try {
ids[j]);
// strange
}
}
if (e instanceof PrivilegedActionException) {
e = extractException(e);
}
if (e instanceof ClassCastException) {
throw (ClassCastException) e;
} else if (e instanceof IOException) {
throw (IOException)e;
} else if (e instanceof InstanceNotFoundException) {
throw (InstanceNotFoundException) e;
} else if (e instanceof RuntimeException) {
throw (RuntimeException) e;
} else {
throw newIOException("Got unexpected server exception: "+e,e);
}
}
}
throws InstanceNotFoundException, IOException {
final NotificationFilter filterValue;
final Object handbackValue;
"(ObjectName,ObjectName,NotificationFilter,Object)",
"connectionId=" + connectionId
+" unwrapping filter with target extended ClassLoader.");
"(ObjectName,ObjectName,NotificationFilter,Object)",
"connectionId=" + connectionId
+" unwrapping handback with target extended ClassLoader.");
try {
"(ObjectName,ObjectName,NotificationFilter,Object)",
"connectionId=" + connectionId
+", name=" + name
+", listenerName=" + listener
+", filter=" + filterValue
+", handback=" + handbackValue);
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
throw new IllegalArgumentException("Illegal null parameter");
if (listenerIDs[i] == null)
throw new IllegalArgumentException("Null listener ID");
}
try {
"(ObjectName,Integer[])",
"connectionId=" + connectionId
+", name=" + name
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof ListenerNotFoundException)
throw (ListenerNotFoundException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
try {
"(ObjectName,ObjectName)",
"connectionId=" + connectionId
+", name=" + name
+", listenerName=" + listener);
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof ListenerNotFoundException)
throw (ListenerNotFoundException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
throws
final NotificationFilter filterValue;
final Object handbackValue;
"(ObjectName,ObjectName,NotificationFilter,Object)",
"connectionId=" + connectionId
+" unwrapping filter with target extended ClassLoader.");
"(ObjectName,ObjectName,NotificationFilter,Object)",
"connectionId=" + connectionId
+" unwrapping handback with target extended ClassLoader.");
try {
"(ObjectName,ObjectName,NotificationFilter,Object)",
"connectionId=" + connectionId
+", name=" + name
+", listenerName=" + listener
+", filter=" + filterValue
+", handback=" + handbackValue);
} catch (PrivilegedActionException pe) {
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof ListenerNotFoundException)
throw (ListenerNotFoundException) e;
if (e instanceof IOException)
throw (IOException) e;
throw newIOException("Got unexpected server exception: " + e, e);
}
}
int maxNotifications,
long timeout)
throws IOException {
"connectionId=" + connectionId
+", timeout=" + timeout);
throw new IllegalArgumentException("Illegal negative argument");
final boolean serverTerminated =
try {
if (serverTerminated) {
// we must not call fetchNotifs() if the server is
// terminated (timeout elapsed).
//
new TargetedNotification[0]);
}
final long csn = clientSequenceNumber;
final int mn = maxNotifications;
final long t = timeout;
new PrivilegedAction<NotificationResult>() {
public NotificationResult run() {
}
};
else
} finally {
}
}
/**
* <p>Returns a string representation of this object. In general,
* the <code>toString</code> method returns a string that
* "textually represents" this object. The result should be a
* concise but informative representation that is easy for a
* person to read.</p>
*
* @return a String representation of this object.
**/
}
//------------------------------------------------------------------------
// private classes
//------------------------------------------------------------------------
private class PrivilegedOperation
implements PrivilegedExceptionAction<Object> {
}
}
private int operation;
}
//------------------------------------------------------------------------
// private classes
//------------------------------------------------------------------------
super(timeout);
}
protected void doStop() {
try {
close();
} catch (IOException ie) {
"Failed to close: " + ie);
}
}
}
//------------------------------------------------------------------------
// private methods
//------------------------------------------------------------------------
throws InstanceNotFoundException {
try {
return
new PrivilegedExceptionAction<ClassLoader>() {
}
},
);
} catch (PrivilegedActionException pe) {
}
}
throws InstanceNotFoundException {
try {
return (ClassLoader)
new PrivilegedExceptionAction<Object>() {
}
},
);
} catch (PrivilegedActionException pe) {
}
}
final Subject delegationSubject)
throws PrivilegedActionException, IOException {
try {
final AccessControlContext reqACC;
if (delegationSubject == null)
else {
"Subject delegation cannot be enabled unless " +
"an authenticated subject is put in place";
throw new SecurityException(msg);
}
}
try {
} catch (Exception e) {
if (e instanceof RuntimeException)
throw (RuntimeException) e;
throw new PrivilegedActionException(e);
}
} else {
}
} catch (Error e) {
throw new JMXServerErrorException(e.toString(),e);
} finally {
}
}
throws Exception {
switch (operation) {
case CREATE_MBEAN:
case CREATE_MBEAN_LOADER:
case CREATE_MBEAN_PARAMS:
case GET_ATTRIBUTE:
case GET_ATTRIBUTES:
case GET_DEFAULT_DOMAIN:
return mbeanServer.getDefaultDomain();
case GET_DOMAINS:
return mbeanServer.getDomains();
case GET_MBEAN_COUNT:
return mbeanServer.getMBeanCount();
case GET_MBEAN_INFO:
case GET_OBJECT_INSTANCE:
case INVOKE:
case IS_INSTANCE_OF:
case IS_REGISTERED:
case QUERY_MBEANS:
case QUERY_NAMES:
case SET_ATTRIBUTE:
return null;
case SET_ATTRIBUTES:
case UNREGISTER_MBEAN:
return null;
return getServerNotifFwd().addNotificationListener(
params[3]);
return null;
return null;
return null;
params[3]);
return null;
default:
throw new IllegalArgumentException("Invalid operation");
}
}
this.classLoader = classLoader;
}
return old;
}
}
final ClassLoader cl,
final Class<T> wrappedClass)
throws IOException {
return null;
}
try {
try {
} catch (ClassNotFoundException cnfe) {
} finally {
}
} catch (PrivilegedActionException pe) {
if (e instanceof IOException) {
throw (IOException) e;
}
if (e instanceof ClassNotFoundException) {
throw new UnmarshalException(e.toString(), e);
}
}
return null;
}
final ClassLoader cl1,
final ClassLoader cl2,
final Class<T> wrappedClass)
throws IOException {
return null;
}
try {
new PrivilegedExceptionAction<ClassLoader>() {
}
}
);
} catch (PrivilegedActionException pe) {
if (e instanceof IOException) {
throw (IOException) e;
}
if (e instanceof ClassNotFoundException) {
throw new UnmarshalException(e.toString(), e);
}
}
return null;
}
/**
* Construct a new IOException with a nested exception.
* The nested exception is set only if JDK >= 1.4
*/
}
/**
* Iterate until we extract the real exception
* from a stack of PrivilegedActionExceptions.
*/
while (e instanceof PrivilegedActionException) {
e = ((PrivilegedActionException)e).getException();
}
return e;
}
/*
* The JMX spec doesn't explicitly say that a null Object[] or
* String[] in e.g. MBeanServer.invoke is equivalent to an empty
* array, but the RI behaves that way. In the interests of
* maximal interoperability, we make it so even when we're
* connected to some other JMX implementation that might not do
* that. This should be clarified in the next version of JMX.
*/
}
}
/*
* Similarly, the JMX spec says for some but not all methods in
* MBeanServer that take an ObjectName target, that if it's null
* you get this exception. We specify it for all of them, and
* make it so for the ones where it's not specified in JMX even if
* the JMX implementation doesn't do so.
*/
if (x == null) {
throw new RuntimeOperationsException(wrapped);
}
}
//------------------------------------------------------------------------
// private variables
//------------------------------------------------------------------------
private final boolean removeCallerContext;
private boolean terminated = false;
// Method IDs for doOperation
//---------------------------
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
private final static int
// SERVER NOTIFICATION
//--------------------
// TRACES & DEBUG
//---------------
return "null";
else
}
}
super(cl);
}
throws ClassNotFoundException {
}
};
super(parent);
}
throws ClassNotFoundException {
try {
} catch(Exception e) {
if(t instanceof SecurityException) {
}
}
}
return cl;
}
}
}