mx4j/src/tools/mx4j/tools/remote/local LocalConnectionHandler.java,NONE,1.1 LocalConnectionMBeanServerConnection.java,NONE,1.1 LocalServerInvoker.java,NONE,1.1 LocalSubjectInvoker.java,NONE,1.1 LocalConnection.java,1.3,1.4 LocalConnectionManager.java,1.3,1.4 LocalConnector.java,1.6,1.7 ClientInvoker.java,1.1,NONE LocalConnectionImpl.java,1.3,NONE ServerInvoker.java,1.2,NONE ServerSubjectInvoker.java,1.2,NONE
Simone Bordet <[email protected]>
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/local In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25813/src/tools/mx4j/tools/remote/local Modified Files: LocalConnection.java LocalConnectionManager.java LocalConnector.java Added Files: LocalConnectionHandler.java LocalConnectionMBeanServerConnection.java LocalServerInvoker.java LocalSubjectInvoker.java Removed Files: ClientInvoker.java LocalConnectionImpl.java ServerInvoker.java ServerSubjectInvoker.java Log Message: Refactoring of JSR 160 LocalConnector and LocalConnectorServer Index: LocalConnection.java =================================================================== RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/local/LocalConnection.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LocalConnection.java 2 Mar 2004 14:01:34 -0000 1.3 --- LocalConnection.java 10 Aug 2004 08:46:41 -0000 1.4 *************** *** 10,118 **** import java.io.IOException; - import java.util.Set; - - import javax.management.Attribute; - import javax.management.AttributeList; - import javax.management.AttributeNotFoundException; - import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; - import javax.management.IntrospectionException; - import javax.management.InvalidAttributeValueException; import javax.management.ListenerNotFoundException; - import javax.management.MBeanException; - import javax.management.MBeanInfo; - import javax.management.MBeanRegistrationException; - import javax.management.NotCompliantMBeanException; import javax.management.NotificationFilter; import javax.management.NotificationListener; - import javax.management.ObjectInstance; import javax.management.ObjectName; - import javax.management.QueryExp; - import javax.management.ReflectionException; import javax.security.auth.Subject; /** * @author <a href="mailto:[email protected]">Simone Bordet</a> * @version $Revision$ */ ! interface LocalConnection { - public void close() throws IOException; - - public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature, Subject delegate) - throws ReflectionException, - InstanceAlreadyExistsException, - MBeanRegistrationException, - MBeanException, - NotCompliantMBeanException, - IOException; - - public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature, Subject delegate) - throws ReflectionException, - InstanceAlreadyExistsException, - MBeanRegistrationException, - MBeanException, - NotCompliantMBeanException, - InstanceNotFoundException, - IOException; - - public void unregisterMBean(ObjectName name, Subject delegate) throws InstanceNotFoundException, MBeanRegistrationException, IOException; - - public ObjectInstance getObjectInstance(ObjectName name, Subject delegate) throws InstanceNotFoundException, IOException; - - public Set queryMBeans(ObjectName name, QueryExp query, Subject delegate) throws IOException; - - public Set queryNames(ObjectName name, QueryExp query, Subject delegate) throws IOException; - - public boolean isRegistered(ObjectName name, Subject delegate) throws IOException; - - public Integer getMBeanCount(Subject delegate) throws IOException; - - public Object getAttribute(ObjectName name, String attribute, Subject delegate) - throws MBeanException, - AttributeNotFoundException, - InstanceNotFoundException, - ReflectionException, - IOException; - - public AttributeList getAttributes(ObjectName name, String[] attributes, Subject delegate) - throws InstanceNotFoundException, ReflectionException, IOException; - - public void setAttribute(ObjectName name, Attribute attribute, Subject delegate) - throws InstanceNotFoundException, - AttributeNotFoundException, - InvalidAttributeValueException, - MBeanException, - ReflectionException, - IOException; - - public AttributeList setAttributes(ObjectName name, AttributeList attributes, Subject delegate) - throws InstanceNotFoundException, - ReflectionException, - IOException; - - public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature, Subject delegate) - throws InstanceNotFoundException, - MBeanException, - ReflectionException, - IOException; - - public String getDefaultDomain(Subject delegate) throws IOException; - - public String[] getDomains(Subject delegate) throws IOException; - - public MBeanInfo getMBeanInfo(ObjectName name, Subject delegate) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException; - - public boolean isInstanceOf(ObjectName name, String className, Subject delegate) throws InstanceNotFoundException, IOException; - - public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback, Subject delegate) - throws InstanceNotFoundException, IOException; - - public void removeNotificationListener(ObjectName name, ObjectName listener, Subject delegate) - throws InstanceNotFoundException, ListenerNotFoundException, IOException; - - public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback, Subject delegate) - throws InstanceNotFoundException, ListenerNotFoundException, IOException; - public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback, Subject delegate) throws InstanceNotFoundException, IOException; --- 10,28 ---- import java.io.IOException; import javax.management.InstanceNotFoundException; import javax.management.ListenerNotFoundException; import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectName; import javax.security.auth.Subject; + import mx4j.tools.remote.JMXConnection; + /** * @author <a href="mailto:[email protected]">Simone Bordet</a> * @version $Revision$ */ ! public interface LocalConnection extends JMXConnection { public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback, Subject delegate) throws InstanceNotFoundException, IOException; --- LocalConnectionImpl.java DELETED --- --- NEW FILE: LocalServerInvoker.java --- /* * Copyright (C) MX4J. * All rights reserved. * * This software is distributed under the terms of the MX4J License version 1.0. * See the terms of the MX4J License in the documentation provided with this software. */ package mx4j.tools.remote.local; import java.io.IOException; import java.util.HashSet; import java.util.Set; import javax.management.InstanceNotFoundException; import javax.management.ListenerNotFoundException; import javax.management.MBeanServer; import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectName; import javax.security.auth.Subject; import mx4j.remote.NotificationTuple; import mx4j.tools.remote.AbstractServerInvoker; /** * @author <a href="mailto:[email protected]">Simone Bordet</a> * @version $Revision: 1.1 $ */ class LocalServerInvoker extends AbstractServerInvoker implements LocalConnection { private final Set listeners = new HashSet(); LocalServerInvoker(MBeanServer server) { super(server); } public void close() throws IOException { NotificationTuple[] tuples = null; synchronized (listeners) { tuples = (NotificationTuple[])listeners.toArray(new NotificationTuple[listeners.size()]); listeners.clear(); } for (int i = 0; i < tuples.length; i++) { NotificationTuple tuple = tuples[i]; try { getServer().removeNotificationListener(tuple.getObjectName(), tuple.getNotificationListener(), tuple.getNotificationFilter(), tuple.getHandback()); } catch (InstanceNotFoundException ignored) { } catch (ListenerNotFoundException ignored) { } } } public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback, Subject delegate) throws InstanceNotFoundException, IOException { NotificationTuple tuple = new NotificationTuple(observed, listener, filter, handback); synchronized (listeners) { listeners.add(tuple); } getServer().addNotificationListener(observed, listener, filter, handback); } public void removeNotificationListener(ObjectName observed, NotificationListener listener, Subject delegate) throws InstanceNotFoundException, ListenerNotFoundException, IOException { NotificationTuple tuple = new NotificationTuple(observed, listener); synchronized (listeners) { listeners.remove(tuple); } getServer().removeNotificationListener(observed, listener); } public void removeNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback, Subject delegate) throws InstanceNotFoundException, ListenerNotFoundException, IOException { NotificationTuple tuple = new NotificationTuple(observed, listener, filter, handback); synchronized (listeners) { listeners.remove(tuple); } getServer().removeNotificationListener(observed, listener, filter, handback); } } Index: LocalConnectionManager.java =================================================================== RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/local/LocalConnectionManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LocalConnectionManager.java 22 Sep 2003 17:41:03 -0000 1.3 --- LocalConnectionManager.java 10 Aug 2004 08:46:41 -0000 1.4 *************** *** 11,17 **** import java.io.IOException; import java.util.Map; - - import javax.security.auth.Subject; import javax.management.MBeanServer; import mx4j.tools.remote.AbstractConnectionManager; --- 11,16 ---- import java.io.IOException; import java.util.Map; import javax.management.MBeanServer; + import javax.security.auth.Subject; import mx4j.tools.remote.AbstractConnectionManager; *************** *** 39,45 **** public Connection doConnect(String connectionId, Subject subject) throws IOException { ! LocalConnection serverInvoker = new ServerInvoker(mbeanServer); ! LocalConnection subjectInvoker = ServerSubjectInvoker.newInstance(serverInvoker, subject, getSecurityContext()); ! return new LocalConnectionImpl(connectionId, this, subjectInvoker); } --- 38,44 ---- public Connection doConnect(String connectionId, Subject subject) throws IOException { ! LocalConnection serverInvoker = new LocalServerInvoker(mbeanServer); ! LocalConnection subjectInvoker = LocalSubjectInvoker.newInstance(serverInvoker, subject, getSecurityContext()); ! return new LocalConnectionHandler(connectionId, this, subjectInvoker); } --- ServerInvoker.java DELETED --- --- ServerSubjectInvoker.java DELETED --- --- NEW FILE: LocalConnectionHandler.java --- /* * Copyright (C) MX4J. * All rights reserved. * * This software is distributed under the terms of the MX4J License version 1.0. * See the terms of the MX4J License in the documentation provided with this software. */ package mx4j.tools.remote.local; import java.io.IOException; import javax.management.InstanceNotFoundException; import javax.management.ListenerNotFoundException; import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectName; import javax.security.auth.Subject; import mx4j.tools.remote.JMXConnectionHandler; /** * @author <a href="mailto:[email protected]">Simone Bordet</a> * @version $Revision: 1.1 $ */ class LocalConnectionHandler extends JMXConnectionHandler implements LocalConnection { LocalConnectionHandler(String connectionId, LocalConnectionManager manager, LocalConnection target) { super(target, manager, connectionId); } public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback, Subject delegate) throws InstanceNotFoundException, IOException { if (isClosed()) throw new IOException("Connection has been closed"); ((LocalConnection)getConnection()).addNotificationListener(observed, listener, filter, handback, delegate); } public void removeNotificationListener(ObjectName observed, NotificationListener listener, Subject delegate) throws InstanceNotFoundException, ListenerNotFoundException, IOException { if (isClosed()) throw new IOException("Connection has been closed"); ((LocalConnection)getConnection()).removeNotificationListener(observed, listener, delegate); } public void removeNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback, Subject delegate) throws InstanceNotFoundException, ListenerNotFoundException, IOException { if (isClosed()) throw new IOException("Connection has been closed"); ((LocalConnection)getConnection()).removeNotificationListener(observed, listener, filter, handback, delegate); } } --- ClientInvoker.java DELETED --- --- NEW FILE: LocalConnectionMBeanServerConnection.java --- /* * Copyright (C) MX4J. * All rights reserved. * * This software is distributed under the terms of the MX4J License version 1.0. * See the terms of the MX4J License in the documentation provided with this software. */ package mx4j.tools.remote.local; import java.io.IOException; import java.util.Set; import javax.management.Attribute; import javax.management.AttributeList; import javax.management.AttributeNotFoundException; import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.IntrospectionException; import javax.management.InvalidAttributeValueException; import javax.management.ListenerNotFoundException; import javax.management.MBeanException; import javax.management.MBeanInfo; import javax.management.MBeanRegistrationException; import javax.management.MBeanServerConnection; import javax.management.NotCompliantMBeanException; import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.QueryExp; import javax.management.ReflectionException; import javax.security.auth.Subject; /** * @author <a href="mailto:[email protected]">Simone Bordet</a> * @version $Revision: 1.1 $ */ class LocalConnectionMBeanServerConnection implements MBeanServerConnection { private final LocalConnection connection; private final Subject delegate; LocalConnectionMBeanServerConnection(LocalConnection connection, Subject delegate) { this.connection = connection; this.delegate = delegate; } public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException { connection.addNotificationListener(observed, listener, filter, handback, delegate); } public void removeNotificationListener(ObjectName observed, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException { connection.removeNotificationListener(observed, listener, delegate); } public void removeNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException { connection.removeNotificationListener(observed, listener, filter, handback, delegate); } public void addNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, IOException { connection.addNotificationListener(observed, listener, filter, handback, delegate); } public void removeNotificationListener(ObjectName observed, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException { connection.removeNotificationListener(observed, listener, delegate); } public void removeNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException, IOException { connection.removeNotificationListener(observed, listener, filter, handback, delegate); } public MBeanInfo getMBeanInfo(ObjectName objectName) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException { return connection.getMBeanInfo(objectName, delegate); } public boolean isInstanceOf(ObjectName objectName, String className) throws InstanceNotFoundException, IOException { return connection.isInstanceOf(objectName, className, delegate); } public String[] getDomains() throws IOException { return connection.getDomains(delegate); } public String getDefaultDomain() throws IOException { return connection.getDefaultDomain(delegate); } public ObjectInstance createMBean(String className, ObjectName objectName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException { return connection.createMBean(className, objectName, null, null, delegate); } public ObjectInstance createMBean(String className, ObjectName objectName, Object[] args, String[] parameters) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException { return connection.createMBean(className, objectName, args, parameters, delegate); } public ObjectInstance createMBean(String className, ObjectName objectName, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException { return connection.createMBean(className, objectName, loaderName, null, null, delegate); } public ObjectInstance createMBean(String className, ObjectName objectName, ObjectName loaderName, Object[] args, String[] parameters) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException { return connection.createMBean(className, objectName, loaderName, args, parameters, delegate); } public void unregisterMBean(ObjectName objectName) throws InstanceNotFoundException, MBeanRegistrationException, IOException { connection.unregisterMBean(objectName, delegate); } public Object getAttribute(ObjectName objectName, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException, IOException { return connection.getAttribute(objectName, attribute, delegate); } public void setAttribute(ObjectName objectName, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException, IOException { connection.setAttribute(objectName, attribute, delegate); } public AttributeList getAttributes(ObjectName objectName, String[] attributes) throws InstanceNotFoundException, ReflectionException, IOException { return connection.getAttributes(objectName, attributes, delegate); } public AttributeList setAttributes(ObjectName objectName, AttributeList attributes) throws InstanceNotFoundException, ReflectionException, IOException { return connection.setAttributes(objectName, attributes, delegate); } public Object invoke(ObjectName objectName, String methodName, Object[] args, String[] parameters) throws InstanceNotFoundException, MBeanException, ReflectionException, IOException { return connection.invoke(objectName, methodName, args, parameters, delegate); } public Integer getMBeanCount() throws IOException { return connection.getMBeanCount(delegate); } public boolean isRegistered(ObjectName objectName) throws IOException { return connection.isRegistered(objectName, delegate); } public ObjectInstance getObjectInstance(ObjectName objectName) throws InstanceNotFoundException, IOException { return connection.getObjectInstance(objectName, delegate); } public Set queryMBeans(ObjectName patternName, QueryExp filter) throws IOException { return connection.queryMBeans(patternName, filter, delegate); } public Set queryNames(ObjectName patternName, QueryExp filter) throws IOException { return connection.queryNames(patternName, filter, delegate); } } Index: LocalConnector.java =================================================================== RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/local/LocalConnector.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LocalConnector.java 1 Mar 2004 18:04:45 -0000 1.6 --- LocalConnector.java 10 Aug 2004 08:46:41 -0000 1.7 *************** *** 12,16 **** import java.net.MalformedURLException; import java.util.Map; - import javax.management.MBeanServerConnection; import javax.management.remote.JMXServiceURL; --- 12,15 ---- *************** *** 19,24 **** import mx4j.remote.ConnectionResolver; import mx4j.tools.remote.AbstractJMXConnector; - import mx4j.tools.remote.ConnectionManager; import mx4j.tools.remote.Connection; /** --- 18,23 ---- import mx4j.remote.ConnectionResolver; import mx4j.tools.remote.AbstractJMXConnector; import mx4j.tools.remote.Connection; + import mx4j.tools.remote.ConnectionManager; /** *************** *** 56,60 **** protected MBeanServerConnection doGetMBeanServerConnection(Subject delegate) throws IOException { ! return new ClientInvoker((LocalConnection)connection, delegate); } --- 55,59 ---- protected MBeanServerConnection doGetMBeanServerConnection(Subject delegate) throws IOException { ! return new LocalConnectionMBeanServerConnection((LocalConnection)connection, delegate); } --- NEW FILE: LocalSubjectInvoker.java --- /* * Copyright (C) MX4J. * All rights reserved. * * This software is distributed under the terms of the MX4J License version 1.0. * See the terms of the MX4J License in the documentation provided with this software. */ package mx4j.tools.remote.local; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.security.AccessControlContext; import javax.security.auth.Subject; import mx4j.tools.remote.SubjectInvoker; /** * @author <a href="mailto:[email protected]">Simone Bordet</a> * @version $Revision: 1.1 $ */ class LocalSubjectInvoker extends SubjectInvoker { static LocalConnection newInstance(LocalConnection target, Subject subject, AccessControlContext context) { LocalSubjectInvoker handler = new LocalSubjectInvoker(target, subject, context); return (LocalConnection)Proxy.newProxyInstance(handler.getClass().getClassLoader(), new Class[]{LocalConnection.class}, handler); } private LocalSubjectInvoker(LocalConnection target, Subject subject, AccessControlContext context) { super(target, subject, context); } protected boolean isPlainInvoke(Method method) { boolean plain = super.isPlainInvoke(method); if (plain) return plain; String methodName = method.getName(); // LocalConnection methods that does not require the delegate subject if ("close".equals(methodName)) return true; return false; } } ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285