📄 rmiconnectionimpl.java
字号:
+", listenerIDs=" + objects(listenerIDs)); doPrivilegedOperation( REMOVE_NOTIFICATION_LISTENER, params, delegationSubject); } catch (PrivilegedActionException pe) { Exception e = extractException(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); } } public void removeNotificationListener(ObjectName name, ObjectName listener, Subject delegationSubject) throws InstanceNotFoundException, ListenerNotFoundException, IOException { checkNonNull("Target MBean name", name); checkNonNull("Listener MBean name", listener); try { final Object params[] = new Object[] { name, listener }; if (logger.debugOn()) logger.debug("removeNotificationListener"+ "(ObjectName,ObjectName)", "connectionId=" + connectionId +", name=" + name +", listenerName=" + listener); doPrivilegedOperation( REMOVE_NOTIFICATION_LISTENER_OBJECTNAME, params, delegationSubject); } catch (PrivilegedActionException pe) { Exception e = extractException(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); } } public void removeNotificationListener(ObjectName name, ObjectName listener, MarshalledObject filter, MarshalledObject handback, Subject delegationSubject) throws InstanceNotFoundException, ListenerNotFoundException, IOException { checkNonNull("Target MBean name", name); checkNonNull("Listener MBean name", listener); final NotificationFilter filterValue; final Object handbackValue; final boolean debug=logger.debugOn(); final ClassLoader targetCl = getClassLoaderFor(name); if (debug) logger.debug("removeNotificationListener"+ "(ObjectName,ObjectName,NotificationFilter,Object)", "connectionId=" + connectionId +" unwrapping filter with target extended ClassLoader."); filterValue = (NotificationFilter) unwrap(filter, targetCl, defaultClassLoader); if (debug) logger.debug("removeNotificationListener"+ "(ObjectName,ObjectName,NotificationFilter,Object)", "connectionId=" + connectionId +" unwrapping handback with target extended ClassLoader."); handbackValue = unwrap(handback, targetCl, defaultClassLoader); try { final Object params[] = new Object[] { name, listener, filterValue, handbackValue }; if (debug) logger.debug("removeNotificationListener"+ "(ObjectName,ObjectName,NotificationFilter,Object)", "connectionId=" + connectionId +", name=" + name +", listenerName=" + listener +", filter=" + filterValue +", handback=" + handbackValue); doPrivilegedOperation( REMOVE_NOTIFICATION_LISTENER_OBJECTNAME_FILTER_HANDBACK, params, delegationSubject); } catch (PrivilegedActionException pe) { Exception e = extractException(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); } } public NotificationResult fetchNotifications(long clientSequenceNumber, int maxNotifications, long timeout) throws IOException { if (logger.debugOn()) logger.debug("fetchNotifications", "connectionId=" + connectionId +", timeout=" + timeout); if (maxNotifications < 0 || timeout < 0) throw new IllegalArgumentException("Illegal negative argument"); final boolean serverTerminated = serverCommunicatorAdmin.reqIncoming(); try { if (serverTerminated) { // we must not call fetchNotifs() if the server is // terminated (timeout elapsed). // return new NotificationResult(0L, 0L, new TargetedNotification[0]); } return getServerNotifFwd().fetchNotifs(clientSequenceNumber, timeout, maxNotifications); } finally { serverCommunicatorAdmin.rspOutgoing(); } } /** * <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. **/ public String toString() { return super.toString() + ": connectionId=" + connectionId; } //------------------------------------------------------------------------ // private classes //------------------------------------------------------------------------ private class PrivilegedOperation implements PrivilegedExceptionAction { public PrivilegedOperation(int operation, Object[] params) { this.operation = operation; this.params = params; } public Object run() throws Exception { return doOperation(operation, params); } private int operation; private Object[] params; } //------------------------------------------------------------------------ // private classes //------------------------------------------------------------------------ private class RMIServerCommunicatorAdmin extends ServerCommunicatorAdmin { public RMIServerCommunicatorAdmin(long timeout) { super(timeout); } protected void doStop() { try { close(); } catch (IOException ie) { logger.warning("RMIServerCommunicatorAdmin-doStop", "Failed to close: " + ie); logger.debug("RMIServerCommunicatorAdmin-doStop",ie); } } } //------------------------------------------------------------------------ // private methods //------------------------------------------------------------------------ private ClassLoaderRepository getClassLoaderRepository() { return (ClassLoaderRepository) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return mbeanServer.getClassLoaderRepository(); } }); } private ClassLoader getClassLoader(final ObjectName name) throws InstanceNotFoundException { try { return (ClassLoader) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws InstanceNotFoundException { return mbeanServer.getClassLoader(name); } }); } catch (PrivilegedActionException pe) { throw (InstanceNotFoundException) extractException(pe); } } private ClassLoader getClassLoaderFor(final ObjectName name) throws InstanceNotFoundException { try { return (ClassLoader) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws InstanceNotFoundException { return mbeanServer.getClassLoaderFor(name); } }); } catch (PrivilegedActionException pe) { throw (InstanceNotFoundException) extractException(pe); } } private Object doPrivilegedOperation(final int operation, final Object[] params, final Subject delegationSubject) throws PrivilegedActionException, IOException { serverCommunicatorAdmin.reqIncoming(); try { final AccessControlContext reqACC; if (delegationSubject == null) reqACC = acc; else { if (subject == null) { final String msg = "Subject delegation cannot be enabled unless " + "an authenticated subject is put in place"; throw new SecurityException(msg); } reqACC = subjectDelegator.delegatedContext(acc, delegationSubject); } PrivilegedOperation op = new PrivilegedOperation(operation, params); if (reqACC == null) { try { return op.run(); } catch (Exception e) { if (e instanceof RuntimeException) throw (RuntimeException) e; throw new PrivilegedActionException(e); } } else { return AccessController.doPrivileged(op, reqACC); } } catch (Error e) { throw new JMXServerErrorException(e.toString(),e); } finally { serverCommunicatorAdmin.rspOutgoing(); } } private Object doOperation(int operation, Object[] params) throws Exception { switch (operation) { case CREATE_MBEAN: 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:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -