📄 rmiconnectionimpl.java
字号:
return mbeanServer.createMBean((String)params[0], (ObjectName)params[1]); case CREATE_MBEAN_LOADER: return mbeanServer.createMBean((String)params[0], (ObjectName)params[1], (ObjectName)params[2]); case CREATE_MBEAN_PARAMS: return mbeanServer.createMBean((String)params[0], (ObjectName)params[1], (Object[])params[2], (String[])params[3]); case CREATE_MBEAN_LOADER_PARAMS: return mbeanServer.createMBean((String)params[0], (ObjectName)params[1], (ObjectName)params[2], (Object[])params[3], (String[])params[4]); case GET_ATTRIBUTE: return mbeanServer.getAttribute((ObjectName)params[0], (String)params[1]); case GET_ATTRIBUTES: return mbeanServer.getAttributes((ObjectName)params[0], (String[])params[1]); case GET_DEFAULT_DOMAIN: return mbeanServer.getDefaultDomain(); case GET_DOMAINS: return mbeanServer.getDomains(); case GET_MBEAN_COUNT: return mbeanServer.getMBeanCount(); case GET_MBEAN_INFO: return mbeanServer.getMBeanInfo((ObjectName)params[0]); case GET_OBJECT_INSTANCE: return mbeanServer.getObjectInstance((ObjectName)params[0]); case INVOKE: return mbeanServer.invoke((ObjectName)params[0], (String)params[1], (Object[])params[2], (String[])params[3]); case IS_INSTANCE_OF: return mbeanServer.isInstanceOf((ObjectName)params[0], (String)params[1]) ? Boolean.TRUE : Boolean.FALSE; case IS_REGISTERED: return mbeanServer.isRegistered((ObjectName)params[0]) ? Boolean.TRUE : Boolean.FALSE; case QUERY_MBEANS: return mbeanServer.queryMBeans((ObjectName)params[0], (QueryExp)params[1]); case QUERY_NAMES: return mbeanServer.queryNames((ObjectName)params[0], (QueryExp)params[1]); case SET_ATTRIBUTE: 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"); } } private static <T> T unwrap(final MarshalledObject mo, final ClassLoader cl, final Class<T> wrappedClass) throws IOException { if (mo == null) { return null; } try { return AccessController.doPrivileged( new PrivilegedExceptionAction<T>() { public T run() throws IOException { final ClassLoader old = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(cl); try { return wrappedClass.cast(mo.get()); } 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 <T> T unwrap(final MarshalledObject mo, final ClassLoader cl1, final ClassLoader cl2, final Class<T> wrappedClass) throws IOException { if (mo == null) { return null; } try { return AccessController.doPrivileged( new PrivilegedExceptionAction<T>() { public T run() throws IOException { return unwrap(mo, new OrderClassLoaders(cl1, cl2), wrappedClass); } }); } 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 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 boolean removeCallerContext; 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 String objects(final Object[] objs) { if (objs == null) return "null"; else return Arrays.asList(objs).toString(); } private static String strings(final String[] strs) { return objects(strs); } private static final ClassLogger logger = new ClassLogger("javax.management.remote.rmi", "RMIConnectionImpl");}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -