⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rmiconnectionimpl.java

📁 JAVA的一些源码 JAVA2 STANDARD EDITION DEVELOPMENT KIT 5.0
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	    mbeanServer.setAttribute((ObjectName)params[0],				     (Attribute)params[1]);	    return null;			case SET_ATTRIBUTES:	    return mbeanServer.setAttributes((ObjectName)params[0],                                             (AttributeList)params[1]);	case UNREGISTER_MBEAN:	    mbeanServer.unregisterMBean((ObjectName)params[0]);	    return null;	case ADD_NOTIFICATION_LISTENERS:	    return getServerNotifFwd().addNotificationListener(						(ObjectName)params[0],						(NotificationFilter)params[1]);	    	case ADD_NOTIFICATION_LISTENER_OBJECTNAME:	    mbeanServer.addNotificationListener((ObjectName)params[0],                                                (ObjectName)params[1],                                                (NotificationFilter)params[2],                                                (Object)params[3]);	    return null;	    	case REMOVE_NOTIFICATION_LISTENER:	    getServerNotifFwd().removeNotificationListener(                                                   (ObjectName)params[0],                                                   (Integer[])params[1]);	    return null;	case REMOVE_NOTIFICATION_LISTENER_OBJECTNAME:	    mbeanServer.removeNotificationListener((ObjectName)params[0],                                                   (ObjectName)params[1]);	    return null;	case REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK:	    mbeanServer.removeNotificationListener(                                          (ObjectName)params[0],                                          (ObjectName)params[1],                                          (NotificationFilter)params[2],                                          (Object)params[3]);	    return null;	default:	    throw new IllegalArgumentException("Invalid operation");	}    }    /*       Parameters to certain MBeanServer operations are passed       remotely wrapped inside a MarshalledObject, so that they can be       unwrapped with the right class loader.  This loader is       typically the target MBean's class loader.       MarshalledObject.get() uses the context class loader to load       classes as it deserializes, which is what we want.  However,       before consulting the context class loader, it consults the       calling class's loader, if that's not null.  So, in the       standalone version of javax.management.remote, if the class       you're looking for is known to RMIConnectionImpl's class loader       (typically the system class loader) then that loader will load       it. This contradicts the class-loading semantics defined in JSR       160, and can lead to problems if the same class name is known       to RMIConnectionImpl's class loader and to the class loader of       the target MBean in an invoke, setAttribute, or createMBean       operation. If it is deserialized by the former, it can't be       passed to the MBean, which expects the latter.       We therefore call MarshalledObject.get() from within a class       that is loaded by a NoCallStackClassLoader.  This loader       doesn't know any other classes, so cannot load any that it is       not supposed to.       This is not needed in J2SE 5, where javax.management.remote       is loaded by the bootstrap class loader.       The byteCodeString below encodes the following Java class,       compiled with "javac -g:none" on J2SE 1.4.2.	package com.sun.jmx.remote.internal;	import java.io.IOException;	import java.rmi.MarshalledObject;	public class MOGet implements Unmarshal {	    public Object get(MarshalledObject mo)		    throws IOException, ClassNotFoundException {		return mo.get();	    }	}          */    private static final String unmarshalClassName =	"com.sun.jmx.remote.internal.MOGet";    private static boolean bootstrapLoaded =	(RMIConnectionImpl.class.getClassLoader() ==	 Object.class.getClassLoader());    private static final Unmarshal unmarshal;    static {	final String byteCodeString =	    "\312\376\272\276\0\0\0.\0\30\12\0\4\0\16\12\0\17\0\20\7\0\21\7\0"+	    "\22\7\0\23\1\0\6<init>\1\0\3()V\1\0\4Code\1\0\3get\1\0/(Ljava/r"+	    "mi/MarshalledObject;)Ljava/lang/Object;\1\0\12Exceptions\7\0\24"+	    "\7\0\25\14\0\6\0\7\7\0\26\14\0\11\0\27\1\0!com/sun/jmx/remote/i"+	    "nternal/MOGet\1\0\20java/lang/Object\1\0%com/sun/jmx/remote/int"+	    "ernal/Unmarshal\1\0\23java/io/IOException\1\0\40java/lang/Class"+	    "NotFoundException\1\0\31java/rmi/MarshalledObject\1\0\24()Ljava"+	    "/lang/Object;\0!\0\3\0\4\0\1\0\5\0\0\0\2\0\1\0\6\0\7\0\1\0\10\0"+	    "\0\0\21\0\1\0\1\0\0\0\5*\267\0\1\261\0\0\0\0\0\1\0\11\0\12\0\2\0"+	    "\10\0\0\0\21\0\1\0\2\0\0\0\5+\266\0\2\260\0\0\0\0\0\13\0\0\0\6\0"+	    "\2\0\14\0\15\0\0";	if (bootstrapLoaded)	    unmarshal = null;	else {	    final byte[] byteCode =		NoCallStackClassLoader.stringToBytes(byteCodeString);	    final String[] otherClassNames = {		Unmarshal.class.getName()	    };	    final Class thisClass = RMIConnectionImpl.class;	    final ClassLoader thisClassLoader = thisClass.getClassLoader();	    final PrivilegedExceptionAction action =		new PrivilegedExceptionAction() {		    public Object run() throws Exception {			final ProtectionDomain thisProtectionDomain =			    thisClass.getProtectionDomain();			ClassLoader cl =			    new NoCallStackClassLoader(unmarshalClassName,						       byteCode,						       otherClassNames,						       thisClassLoader,						       thisProtectionDomain);			Class c = cl.loadClass(unmarshalClassName);			return c.newInstance();		    }		};	    try {		unmarshal = (Unmarshal) AccessController.doPrivileged(action);	    } catch (PrivilegedActionException e) {		Error error = new Error("Internal error: " + e);		EnvHelp.initCause(error, e);		throw error;	    }	}    }    private static Object unwrap(final MarshalledObject mo,				 final ClassLoader cl)	    throws IOException {        if (mo == null) {            return null;        }        try {            return AccessController.doPrivileged(		new PrivilegedExceptionAction() {                    public Object run()			    throws IOException {                        final ClassLoader old =                            Thread.currentThread().getContextClassLoader();                        Thread.currentThread().setContextClassLoader(cl);                        try {			    if (bootstrapLoaded)				return mo.get();			    else				return unmarshal.get(mo);			} catch (ClassNotFoundException cnfe) {			    throw new UnmarshalException(cnfe.toString(), cnfe);                        } finally {                            Thread.currentThread().setContextClassLoader(old);                        }                    }                });        } catch (PrivilegedActionException pe) {            Exception e = extractException(pe);            if (e instanceof IOException) {                throw (IOException) e;            }            if (e instanceof ClassNotFoundException) {		throw new UnmarshalException(e.toString(), e);            }	    logger.warning("unwrap", "Failed to unmarshall object: " + e);	    logger.debug("unwrap", e);        }        return null;    }    private static Object unwrap(final MarshalledObject mo,				 final ClassLoader cl1,				 final ClassLoader cl2)        throws IOException {        if (mo == null) {            return null;        }        try {            return AccessController.doPrivileged(                   new PrivilegedExceptionAction() {                       public Object run()                           throws IOException {                           return unwrap(mo, new OrderClassLoaders(cl1, cl2));                       }                   });        } catch (PrivilegedActionException pe) {            Exception e = extractException(pe);            if (e instanceof IOException) {                throw (IOException) e;            }            if (e instanceof ClassNotFoundException) {                throw new UnmarshalException(e.toString(), e);            }	    logger.warning("unwrap", "Failed to unmarshall object: " + e);	    logger.debug("unwrap", e);        }        return null;    }    /**     * Construct a new IOException with a nested exception.     * The nested exception is set only if JDK >= 1.4     */    private static IOException newIOException(String message,                                               Throwable cause) {        final IOException x = new IOException(message);        return (IOException) EnvHelp.initCause(x,cause);    }    /**     * Iterate until we extract the real exception     * from a stack of PrivilegedActionExceptions.     */    private static Exception extractException(Exception e) {        while (e instanceof PrivilegedActionException) {            e = ((PrivilegedActionException)e).getException();         }        return e;    }    private static final Object[] NO_OBJECTS = new Object[0];    private static final String[] NO_STRINGS = new String[0];    /*     * 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.     */    private static Object[] nullIsEmpty(Object[] array) {	return (array == null) ? NO_OBJECTS : array;    }    private static String[] nullIsEmpty(String[] array) {	return (array == null) ? NO_STRINGS : array;    }    /*     * 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.     */    private static void checkNonNull(String what, Object x) {	if (x == null) {	    RuntimeException wrapped =		new IllegalArgumentException(what + " must not be null");	    throw new RuntimeOperationsException(wrapped);	}    }    //------------------------------------------------------------------------    // private variables    //------------------------------------------------------------------------    private final Subject subject;    private final SubjectDelegator subjectDelegator;    private final AccessControlContext acc;    private final RMIServerImpl rmiServer;    private final MBeanServer mbeanServer;    private final ClassLoader defaultClassLoader;    private final ClassLoaderWithRepository classLoaderWithRepository;        private boolean terminated = false;        private final String connectionId;    private final ServerCommunicatorAdmin serverCommunicatorAdmin;    // Method IDs for doOperation    //---------------------------    private final static int        ADD_NOTIFICATION_LISTENERS                              = 1;    private final static int        ADD_NOTIFICATION_LISTENER_OBJECTNAME                    = 2;    private final static int        CREATE_MBEAN                                            = 3;    private final static int        CREATE_MBEAN_PARAMS                                     = 4;    private final static int        CREATE_MBEAN_LOADER                                     = 5;    private final static int        CREATE_MBEAN_LOADER_PARAMS                              = 6;    private final static int        GET_ATTRIBUTE                                           = 7;    private final static int        GET_ATTRIBUTES                                          = 8;    private final static int        GET_DEFAULT_DOMAIN                                      = 9;    private final static int        GET_DOMAINS                                             = 10;    private final static int        GET_MBEAN_COUNT                                         = 11;    private final static int        GET_MBEAN_INFO                                          = 12;    private final static int        GET_OBJECT_INSTANCE                                     = 13;    private final static int        INVOKE                                                  = 14;    private final static int        IS_INSTANCE_OF                                          = 15;    private final static int        IS_REGISTERED                                           = 16;    private final static int        QUERY_MBEANS                                            = 17;    private final static int        QUERY_NAMES                                             = 18;    private final static int        REMOVE_NOTIFICATION_LISTENER                            = 19;    private final static int        REMOVE_NOTIFICATION_LISTENER_FILTER_HANDBACK            = 20;    private final static int        REMOVE_NOTIFICATION_LISTENER_OBJECTNAME                 = 21;    private final static int        REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK = 22;    private final static int        SET_ATTRIBUTE                                           = 23;    private final static int        SET_ATTRIBUTES                                          = 24;    private final static int        UNREGISTER_MBEAN                                        = 25;    // SERVER NOTIFICATION    //--------------------    private ServerNotifForwarder serverNotifForwarder;    private Map env;        // TRACES & DEBUG    //---------------    private static S

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -