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

📄 rmiconnectionimpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            if (debug) logger.debug("addNotificationListener"+                 "(ObjectName,ObjectName,NotificationFilter,Object)",                             "connectionId=" + connectionId                             +", name=" + name                             +", listenerName=" + listener                             +", filter=" + filterValue                             +", handback=" + handbackValue);            doPrivilegedOperation(              ADD_NOTIFICATION_LISTENER_OBJECTNAME,              params,              delegationSubject);        } catch (PrivilegedActionException pe) {            Exception e = extractException(pe);            if (e instanceof InstanceNotFoundException)                throw (InstanceNotFoundException) e;            if (e instanceof IOException)                throw (IOException) e;            throw newIOException("Got unexpected server exception: " + e, e);        }    }    public void removeNotificationListeners(ObjectName name,					    Integer[] listenerIDs,					    Subject delegationSubject)        throws        InstanceNotFoundException,        ListenerNotFoundException,        IOException {	if (name == null || listenerIDs == null)	    throw new IllegalArgumentException("Illegal null parameter");	for (int i = 0; i < listenerIDs.length; i++) {	    if (listenerIDs[i] == null)		throw new IllegalArgumentException("Null listener ID");	}        try {            final Object params[] = new Object[] { name, listenerIDs };            if (logger.debugOn()) logger.debug("removeNotificationListener"+                                   "(ObjectName,Integer[])",                                   "connectionId=" + connectionId                                   +", name=" + name                                   +", 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 =            unwrap(filter, targetCl, defaultClassLoader, NotificationFilter.class);	if (debug) logger.debug("removeNotificationListener"+                 "(ObjectName,ObjectName,NotificationFilter,Object)",                 "connectionId=" + connectionId                 +" unwrapping handback with target extended ClassLoader.");	handbackValue =            unwrap(handback, targetCl, defaultClassLoader, Object.class);        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]);	    }            final long csn = clientSequenceNumber;            final int mn = maxNotifications;            final long t = timeout;            PrivilegedAction<NotificationResult> action =                new PrivilegedAction<NotificationResult>() {                    public NotificationResult run() {                        return getServerNotifFwd().fetchNotifs(csn, t, mn);                    }            };            if (acc == null)                return action.run();            else                return AccessController.doPrivileged(action, acc);	} 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, removeCallerContext);	    }	    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:

⌨️ 快捷键说明

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