geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r106387 - in geronimo/trunk/modules: connector/src/java/org/apache/geronimo/connector connector/src/java/org/apache/geronimo/connector/outbound jetty/src/test/org/apache/geronimo/jetty kernel/src/java/org/apache/geronimo/gbean/jmx kernel/src/java/org/apache/geronimo/kernel kernel/src/java/org/apache/geronimo/kernel/jmx kernel/src/java/org/apache/geronimo/kernel/proxy kernel/src/test/org/apache/geronimo/gbean remoting/src/test/org/apache/geronimo/remoting security/src/java/org/apache/geronimo/security/jaas security/src/java/org/apache/geronimo/security/realm security/src/test/org/apache/geronimo/security/remoting/jmx
Date Wed, 24 Nov 2004 06:16:55 GMT
Author: dain
Date: Tue Nov 23 22:16:54 2004
New Revision: 106387

Added:
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyCollection.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGetAttributeInvoker.java
      - copied, changed from r106284, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvocationHandler.java
      - copied, changed from r106284, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGBeanInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXOperationInvoker.java
      - copied, changed from r106284, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXOperationInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXSetAttributeInvoker.java
      - copied, changed from r106284, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXSetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/DeadProxyException.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelGetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelOperationInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelSetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyFactory.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyMethodInterceptor.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawGetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawOperationInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawSetAttributeInvoker.java
Removed:
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CGLibMethodInterceptor.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CGLibProxyFactory.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/DeadProxyException.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionProxy.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleProxy.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGBeanInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXOperationInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXSetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/NoSuchOperationError.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyFactory.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyMethodInterceptor.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawGetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawOperationInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawSetAttributeInvoker.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/VMMethodInterceptor.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/VMProxyFactory.java
Modified:
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
   geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/AbstractGBeanReference.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionReference.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleReference.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
   geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java
   geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java
   geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java
   geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java
   geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java
   geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java
Log:
Moved all proxy creation code to a ProxyManager kernel service.
Don't use this yet, we may remove it or change it.


Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java?view=diff&rev=106387&p1=geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java&r1=106386&p2=geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/ConnectorMethodInterceptor.java	Tue Nov 23 22:16:54 2004
@@ -24,7 +24,8 @@
 import net.sf.cglib.proxy.MethodInterceptor;
 import net.sf.cglib.proxy.MethodProxy;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.gbean.jmx.DeadProxyException;
+import org.apache.geronimo.kernel.proxy.DeadProxyException;
+import org.apache.geronimo.kernel.proxy.DeadProxyException;
 
 /**
  * MethodInterceptor used by various Proxies.  The important part of this class is the

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java?view=diff&rev=106387&p1=geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java&r1=106386&p2=geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java	(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java	Tue Nov 23 22:16:54 2004
@@ -244,7 +244,8 @@
             try {
                 GeronimoContextManager.unbind(globalJNDIName);
             } catch (NamingException e) {
-                throw new RuntimeException(e);
+                // this will happen on failure since doStop is called twice
+                // the error is not important
             }
         }
     }

Modified: geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java?view=diff&rev=106387&p1=geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java&r1=106386&p2=geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java	(original)
+++ geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/SecurityTest.java	Tue Nov 23 22:16:54 2004
@@ -25,7 +25,6 @@
 import java.net.URL;
 
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
-import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
 import org.apache.geronimo.security.SecurityService;
 import org.apache.geronimo.security.deploy.AutoMapAssistant;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
@@ -156,73 +155,79 @@
         securityConfig.getRoleNames().add("content-administrator");
         securityConfig.getRoleNames().add("auto-administrator");
 
-        securityConfig.autoGenerate((SecurityService) MBeanProxyFactory.getProxy(SecurityService.class, kernel.getMBeanServer(), securityServiceName));
+        SecurityService securityService = null;
+        try {
+            securityService = (SecurityService) kernel.getProxyManager().createProxy(securityServiceName, SecurityService.class);
+            securityConfig.autoGenerate(securityService);
 
-        startWebApp(securityConfig);
+            startWebApp(securityConfig);
 
-        HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
-
-        String cookie = connection.getHeaderField("Set-Cookie");
-        cookie = cookie.substring(0, cookie.lastIndexOf(';'));
-        String location = connection.getHeaderField("Location");
+            HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-        connection = (HttpURLConnection) new URL(location).openConnection();
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            String cookie = connection.getHeaderField("Set-Cookie");
+            cookie = cookie.substring(0, cookie.lastIndexOf(';'));
+            String location = connection.getHeaderField("Location");
 
-        location = location.substring(0, location.lastIndexOf('/')) + "/j_security_check?j_username=izumi&j_password=violin";
+            connection = (HttpURLConnection) new URL(location).openConnection();
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
 
-        connection = (HttpURLConnection) new URL(location).openConnection();
-        connection.setRequestMethod("POST");
-        connection.setRequestProperty("Cookie", cookie);
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
+            location = location.substring(0, location.lastIndexOf('/')) + "/j_security_check?j_username=izumi&j_password=violin";
 
-        connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
-        connection.setRequestProperty("Cookie", cookie);
-        connection.setInstanceFollowRedirects(false);
-        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            connection = (HttpURLConnection) new URL(location).openConnection();
+            connection.setRequestMethod("POST");
+            connection.setRequestProperty("Cookie", cookie);
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
-        assertEquals("Hello World", reader.readLine());
-        connection.disconnect();
+            connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+            connection.setRequestProperty("Cookie", cookie);
+            connection.setInstanceFollowRedirects(false);
+            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
 
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            assertEquals("Hello World", reader.readLine());
+            connection.disconnect();
 
-        connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-        cookie = connection.getHeaderField("Set-Cookie");
-        cookie = cookie.substring(0, cookie.lastIndexOf(';'));
-        location = connection.getHeaderField("Location");
+            connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-        connection = (HttpURLConnection) new URL(location).openConnection();
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            cookie = connection.getHeaderField("Set-Cookie");
+            cookie = cookie.substring(0, cookie.lastIndexOf(';'));
+            location = connection.getHeaderField("Location");
 
-        location = location.substring(0, location.lastIndexOf('/')) + "/j_security_check?j_username=alan&j_password=starcraft";
+            connection = (HttpURLConnection) new URL(location).openConnection();
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
 
-        connection = (HttpURLConnection) new URL(location).openConnection();
-        connection.setRequestMethod("POST");
-        connection.setRequestProperty("Cookie", cookie);
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
+            location = location.substring(0, location.lastIndexOf('/')) + "/j_security_check?j_username=alan&j_password=starcraft";
 
-        try {
-            connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+            connection = (HttpURLConnection) new URL(location).openConnection();
+            connection.setRequestMethod("POST");
             connection.setRequestProperty("Cookie", cookie);
             connection.setInstanceFollowRedirects(false);
-            reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-            fail("Should throw an IOException for HTTP 403 response");
-        } catch (IOException e) {
+            try {
+                connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+                connection.setRequestProperty("Cookie", cookie);
+                connection.setInstanceFollowRedirects(false);
+                reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+
+                fail("Should throw an IOException for HTTP 403 response");
+            } catch (IOException e) {
+            }
+
+            assertEquals(HttpURLConnection.HTTP_FORBIDDEN, connection.getResponseCode());
+            connection.disconnect();
+            stopWebApp();
+        } finally {
+            kernel.getProxyManager().destroyProxy(securityService);
         }
-
-        assertEquals(HttpURLConnection.HTTP_FORBIDDEN, connection.getResponseCode());
-        connection.disconnect();
-        stopWebApp();
     }
 
     /**
@@ -242,91 +247,97 @@
         securityConfig.getRoleNames().add("content-administrator");
         securityConfig.getRoleNames().add("auto-administrator");
 
-        securityConfig.autoGenerate((SecurityService) MBeanProxyFactory.getProxy(SecurityService.class, kernel.getMBeanServer(), securityServiceName));
-
-        DefaultPrincipal defaultPrincipal = new DefaultPrincipal();
-        defaultPrincipal.setRealmName("demo-properties-realm");
-        Principal principal = new Principal();
-        principal.setClassName("org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal");
-        principal.setPrincipalName("izumi");
-        defaultPrincipal.setPrincipal(principal);
-
-        securityConfig.setDefaultPrincipal(defaultPrincipal);
-
-        Role role = new Role();
-        role.setRoleName("content-administrator");
-        principal = new Principal();
-        principal.setClassName("org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal");
-        principal.setPrincipalName("it");
-        Realm realm = new Realm();
-        realm.setRealmName("demo-properties-realm");
-        realm.getPrincipals().add(principal);
-        role.getRealms().put(realm.getRealmName(), realm);
+        SecurityService securityService = null;
+        try {
+            securityService = (SecurityService) kernel.getProxyManager().createProxy(securityServiceName, SecurityService.class);
+            securityConfig.autoGenerate(securityService);
 
-        securityConfig.append(role);
+            DefaultPrincipal defaultPrincipal = new DefaultPrincipal();
+            defaultPrincipal.setRealmName("demo-properties-realm");
+            Principal principal = new Principal();
+            principal.setClassName("org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal");
+            principal.setPrincipalName("izumi");
+            defaultPrincipal.setPrincipal(principal);
+
+            securityConfig.setDefaultPrincipal(defaultPrincipal);
+
+            Role role = new Role();
+            role.setRoleName("content-administrator");
+            principal = new Principal();
+            principal.setClassName("org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal");
+            principal.setPrincipalName("it");
+            Realm realm = new Realm();
+            realm.setRealmName("demo-properties-realm");
+            realm.getPrincipals().add(principal);
+            role.getRealms().put(realm.getRealmName(), realm);
 
-        startWebApp(securityConfig);
+            securityConfig.append(role);
 
-        HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
+            startWebApp(securityConfig);
 
-        String cookie = connection.getHeaderField("Set-Cookie");
-        cookie = cookie.substring(0, cookie.lastIndexOf(';'));
-        String location = connection.getHeaderField("Location");
+            HttpURLConnection connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-        connection = (HttpURLConnection) new URL(location).openConnection();
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            String cookie = connection.getHeaderField("Set-Cookie");
+            cookie = cookie.substring(0, cookie.lastIndexOf(';'));
+            String location = connection.getHeaderField("Location");
 
-        location = location.substring(0, location.lastIndexOf('/')) + "/j_security_check?j_username=izumi&j_password=violin";
+            connection = (HttpURLConnection) new URL(location).openConnection();
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
 
-        connection = (HttpURLConnection) new URL(location).openConnection();
-        connection.setRequestMethod("POST");
-        connection.setRequestProperty("Cookie", cookie);
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
+            location = location.substring(0, location.lastIndexOf('/')) + "/j_security_check?j_username=izumi&j_password=violin";
 
-        connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
-        connection.setRequestProperty("Cookie", cookie);
-        connection.setInstanceFollowRedirects(false);
-        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            connection = (HttpURLConnection) new URL(location).openConnection();
+            connection.setRequestMethod("POST");
+            connection.setRequestProperty("Cookie", cookie);
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
-        assertEquals("Hello World", reader.readLine());
-        connection.disconnect();
+            connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+            connection.setRequestProperty("Cookie", cookie);
+            connection.setInstanceFollowRedirects(false);
+            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
 
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            assertEquals("Hello World", reader.readLine());
+            connection.disconnect();
 
-        connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-        cookie = connection.getHeaderField("Set-Cookie");
-        cookie = cookie.substring(0, cookie.lastIndexOf(';'));
-        location = connection.getHeaderField("Location");
+            connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-        connection = (HttpURLConnection) new URL(location).openConnection();
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            cookie = connection.getHeaderField("Set-Cookie");
+            cookie = cookie.substring(0, cookie.lastIndexOf(';'));
+            location = connection.getHeaderField("Location");
 
-        location = location.substring(0, location.lastIndexOf('/')) + "/j_security_check?j_username=alan&j_password=starcraft";
+            connection = (HttpURLConnection) new URL(location).openConnection();
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
 
-        connection = (HttpURLConnection) new URL(location).openConnection();
-        connection.setRequestMethod("POST");
-        connection.setRequestProperty("Cookie", cookie);
-        connection.setInstanceFollowRedirects(false);
-        assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
+            location = location.substring(0, location.lastIndexOf('/')) + "/j_security_check?j_username=alan&j_password=starcraft";
 
-        connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
-        connection.setRequestProperty("Cookie", cookie);
-        connection.setInstanceFollowRedirects(false);
-        reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+            connection = (HttpURLConnection) new URL(location).openConnection();
+            connection.setRequestMethod("POST");
+            connection.setRequestProperty("Cookie", cookie);
+            connection.setInstanceFollowRedirects(false);
+            assertEquals(HttpURLConnection.HTTP_MOVED_TEMP, connection.getResponseCode());
 
-        assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
-        assertEquals("Hello World", reader.readLine());
-        connection.disconnect();
+            connection = (HttpURLConnection) new URL("http://localhost:5678/test/protected/hello.txt").openConnection();
+            connection.setRequestProperty("Cookie", cookie);
+            connection.setInstanceFollowRedirects(false);
+            reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
 
-        stopWebApp();
+            assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+            assertEquals("Hello World", reader.readLine());
+            connection.disconnect();
+
+            stopWebApp();
+        } finally {
+            kernel.getProxyManager().destroyProxy(securityService);
+        }
     }
 
     protected void startWebApp(Security securityConfig) throws Exception {

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/AbstractGBeanReference.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/AbstractGBeanReference.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/AbstractGBeanReference.java&r1=106386&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/AbstractGBeanReference.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/AbstractGBeanReference.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/AbstractGBeanReference.java	Tue Nov 23 22:16:54 2004
@@ -26,14 +26,12 @@
 import javax.management.InstanceNotFoundException;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.kernel.LifecycleAdapter;
-import org.apache.geronimo.kernel.LifecycleListener;
 import org.apache.geronimo.gbean.GReferenceInfo;
 import org.apache.geronimo.gbean.InvalidConfigurationException;
 import org.apache.geronimo.kernel.ClassLoading;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.LifecycleListener;
 import org.apache.geronimo.kernel.LifecycleAdapter;
+import org.apache.geronimo.kernel.LifecycleListener;
 import org.apache.geronimo.kernel.management.State;
 
 /**
@@ -81,6 +79,11 @@
      */
     private Kernel kernel;
 
+    /**
+     * Proxy for this reference
+     */
+    private Object proxy;
+
     public AbstractGBeanReference(GBeanMBean gmbean, GReferenceInfo referenceInfo, Class constructorType) throws InvalidConfigurationException {
         this.gmbean = gmbean;
         this.name = referenceInfo.getName();
@@ -133,6 +136,15 @@
 
     public final Class getType() {
         return type;
+    }
+
+
+    public Object getProxy() {
+        return proxy;
+    }
+
+    protected void setProxy(Object proxy) {
+        this.proxy = proxy;
     }
 
     public final Set getPatterns() {

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CGLibMethodInterceptor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CGLibMethodInterceptor.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CGLibProxyFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CGLibProxyFactory.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/DeadProxyException.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/DeadProxyException.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionProxy.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionProxy.java?view=auto&rev=106386
==============================================================================

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionReference.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionReference.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionReference.java&r1=106386&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionReference.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionReference.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanCollectionReference.java	Tue Nov 23 22:16:54 2004
@@ -26,11 +26,6 @@
  * @version $Rev: 71492 $ $Date: 2004-11-14 21:31:50 -0800 (Sun, 14 Nov 2004) $
  */
 public class GBeanCollectionReference extends AbstractGBeanReference {
-    /**
-     * Proxy to the to this connection.
-     */
-    private GBeanCollectionProxy proxy;
-
     public GBeanCollectionReference(GBeanMBean gmbean, GReferenceInfo referenceInfo, Class constructorType) throws InvalidConfigurationException {
         super(gmbean, referenceInfo, constructorType);
     }
@@ -42,36 +37,31 @@
         }
 
         // if we already have a proxy then we have already been started
-        if (proxy != null) {
+        if (getProxy() != null) {
             return;
         }
 
         // add a dependency on our target and create the proxy
-        proxy = new GBeanCollectionProxy(getKernel(), getName(), getType(), getTargets());
+        setProxy(new ProxyCollection(getName(), getType(), getKernel().getProxyManager(), getTargets()));
     }
 
     public synchronized void stop() {
+        ProxyCollection proxy = (ProxyCollection) getProxy();
         if (proxy != null) {
             proxy.destroy();
-            proxy = null;
-        }
-    }
-
-    public Object getProxy() {
-        if (proxy == null) {
-            return null;
-        } else {
-            return proxy.getProxy();
+            setProxy(null);
         }
     }
 
     public synchronized void targetAdded(ObjectName target) {
+        ProxyCollection proxy = (ProxyCollection) getProxy();
         if (proxy != null) {
             proxy.addTarget(target);
         }
     }
 
     public synchronized void targetRemoved(ObjectName target) {
+        ProxyCollection proxy = (ProxyCollection) getProxy();
         if (proxy != null) {
             proxy.removeTarget(target);
         }

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanInvoker.java?view=auto&rev=106386
==============================================================================

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java&r1=106386&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java	Tue Nov 23 22:16:54 2004
@@ -70,8 +70,9 @@
 public class GBeanMBean extends AbstractManagedObject implements DynamicMBean {
     /**
      * Attribute name used to retrieve the RawInvoker for the GBean
+     * @deprecated DO NOT USE THIS... THIS WILL BE REMOVED!!!!!!
      */
-    static final String RAW_INVOKER = "$$RAW_INVOKER$$";
+    public static final String RAW_INVOKER = "$$RAW_INVOKER$$";
 
     /**
      * Attribute name used to retrieve the GBeanData for the GBean
@@ -661,17 +662,19 @@
             references[i].stop();
         }
 
-        // stop all of the attributes
-        for (int i = 0; i < attributes.length; i++) {
-            GBeanMBeanAttribute attribute = attributes[i];
-            if (attribute.isPersistent() && attribute.isReadable()) {
-                // copy the current attribute value to the persistent value
-                Object value = attribute.getValue();
-                attribute.setPersistentValue(value);
+        if (target != null) {
+            // stop all of the attributes
+            for (int i = 0; i < attributes.length; i++) {
+                GBeanMBeanAttribute attribute = attributes[i];
+                if (attribute.isPersistent() && attribute.isReadable()) {
+                    // copy the current attribute value to the persistent value
+                    Object value = attribute.getValue();
+                    attribute.setPersistentValue(value);
+                }
             }
-        }
 
-        target = null;
+            target = null;
+        }
     }
 
     protected void doFail() {

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleProxy.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleProxy.java?view=auto&rev=106386
==============================================================================

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleReference.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleReference.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleReference.java&r1=106386&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleReference.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleReference.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanSingleReference.java	Tue Nov 23 22:16:54 2004
@@ -40,9 +40,9 @@
     private boolean waitingForMe = false;
 
     /**
-     * Proxy to the to this connection.
+     * The object to which the proxy is bound
      */
-    private GBeanSingleProxy proxy;
+    private ObjectName proxyTarget;
 
     public GBeanSingleReference(GBeanMBean gmbean, GReferenceInfo referenceInfo, Class constructorType) throws InvalidConfigurationException {
         super(gmbean, referenceInfo, constructorType);
@@ -55,7 +55,7 @@
         }
 
         // if we already have a proxy then we have already been started
-        if (proxy != null) {
+        if (getProxy() != null) {
             return;
         }
 
@@ -79,8 +79,9 @@
 
         // add a dependency on our target and create the proxy
         ObjectName target = (ObjectName) targets.iterator().next();
+        setProxy(kernel.getProxyManager().createProxy(target, getType()));
+        proxyTarget = target;
         kernel.getDependencyManager().addDependency(objectName, target);
-        proxy = new GBeanSingleProxy(kernel, getType(), target);
     }
 
     public synchronized void stop() {
@@ -92,18 +93,12 @@
             kernel.getDependencyManager().removeStartHolds(objectName, patterns);
         }
 
+        Object proxy = getProxy();
         if (proxy != null) {
-            kernel.getDependencyManager().removeDependency(objectName, proxy.getTarget());
-            proxy.destroy();
-            proxy = null;
-        }
-    }
-
-    public Object getProxy() {
-        if (proxy == null) {
-            return null;
-        } else {
-            return proxy.getProxy();
+            kernel.getDependencyManager().removeDependency(objectName, proxyTarget);
+            kernel.getProxyManager().destroyProxy(proxy);
+            setProxy(null);
+            proxyTarget = null;
         }
     }
 

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGBeanInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGBeanInvoker.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGetAttributeInvoker.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXOperationInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXOperationInvoker.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXSetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXSetAttributeInvoker.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/NoSuchOperationError.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/NoSuchOperationError.java?view=auto&rev=106386
==============================================================================

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyCollection.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyCollection.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyCollection.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,243 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.gbean.jmx;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.ObjectName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.ReferenceCollection;
+import org.apache.geronimo.gbean.ReferenceCollectionEvent;
+import org.apache.geronimo.gbean.ReferenceCollectionListener;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
+import org.apache.geronimo.kernel.proxy.ProxyFactory;
+
+/**
+ * @version $Rev$ $Date$
+ */
+class ProxyCollection implements ReferenceCollection {
+    private static final Log log = LogFactory.getLog(ProxyCollection.class);
+    private final String name;
+    private final ProxyManager proxyManager;
+    private final ProxyFactory factory;
+    private final Map proxies = new HashMap();
+    private final Set listeners = new HashSet();
+    private boolean stopped = false;
+
+    public ProxyCollection(String name, Class type, ProxyManager proxyManager, Set targets) {
+        this.name = name;
+        this.proxyManager = proxyManager;
+        factory = proxyManager.createProxyFactory(type);
+
+        for (Iterator iterator = targets.iterator(); iterator.hasNext();) {
+            addTarget((ObjectName) iterator.next());
+        }
+    }
+
+    synchronized void destroy() {
+        stopped = true;
+        for (Iterator iterator = proxies.values().iterator(); iterator.hasNext();) {
+            proxyManager.destroyProxy(iterator.next());
+        }
+        proxies.clear();
+        listeners.clear();
+    }
+
+    void addTarget(ObjectName target) {
+        Object proxy;
+        ArrayList listenerCopy;
+        synchronized (this) {
+            // if this is not a new target return
+            if (proxies.containsKey(target)) {
+                return;
+            }
+
+            // create and add the proxy
+            proxy = factory.createProxy(target);
+            proxies.put(target, proxy);
+
+            // make a snapshot of the listeners
+            listenerCopy = new ArrayList(listeners);
+        }
+
+        // fire the member added event
+        for (Iterator iterator = listenerCopy.iterator(); iterator.hasNext();) {
+            ReferenceCollectionListener listener = (ReferenceCollectionListener) iterator.next();
+            try {
+                listener.memberAdded(new ReferenceCollectionEvent(name, proxy));
+            } catch (Throwable t) {
+                log.error("Listener threw exception", t);
+            }
+        }
+    }
+
+    void removeTarget(ObjectName target) {
+        Object proxy;
+        ArrayList listenerCopy;
+        synchronized (this) {
+            // remove the proxy
+            proxy = proxies.remove(target);
+
+            // if this was not a target return
+            if (proxy == null) {
+                return;
+            }
+
+            // make a snapshot of the listeners
+            listenerCopy = new ArrayList(listeners);
+        }
+
+        // fire the member removed event
+        for (Iterator iterator = listenerCopy.iterator(); iterator.hasNext();) {
+            ReferenceCollectionListener listener = (ReferenceCollectionListener) iterator.next();
+            try {
+                listener.memberRemoved(new ReferenceCollectionEvent(name, proxy));
+            } catch (Throwable t) {
+                log.error("Listener threw exception", t);
+            }
+        }
+
+        // destroy the proxy
+        proxyManager.destroyProxy(proxy);
+    }
+
+    public synchronized boolean isStopped() {
+        return stopped;
+    }
+
+    public synchronized void addReferenceCollectionListener(ReferenceCollectionListener listener) {
+        listeners.add(listener);
+    }
+
+    public synchronized void removeReferenceCollectionListener(ReferenceCollectionListener listener) {
+        listeners.remove(listener);
+    }
+
+    public synchronized int size() {
+        if (stopped) {
+            return 0;
+        }
+        return proxies.size();
+    }
+
+    public synchronized boolean isEmpty() {
+        if (stopped) {
+            return true;
+        }
+        return proxies.isEmpty();
+    }
+
+    public synchronized boolean contains(Object o) {
+        if (stopped) {
+            return false;
+        }
+        return proxies.containsValue(o);
+    }
+
+    public synchronized Iterator iterator() {
+        if (stopped) {
+            return new Iterator() {
+                public boolean hasNext() {
+                    return false;
+                }
+
+                public Object next() {
+                    throw new NoSuchElementException();
+                }
+
+                public void remove() {
+                    throw new UnsupportedOperationException();
+                }
+            };
+        }
+
+        return new Iterator() {
+            // copy the proxies, so the client can iterate without concurrent modification
+            // this is necssary since the client has nothing to synchronize on
+            private final Iterator iterator = new ArrayList(proxies.values()).iterator();
+
+            public boolean hasNext() {
+                return iterator.hasNext();
+            }
+
+            public Object next() {
+                return iterator.next();
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+        };
+    }
+
+    public synchronized Object[] toArray() {
+        if (stopped) {
+            return new Object[0];
+        }
+        return proxies.values().toArray();
+    }
+
+    public synchronized Object[] toArray(Object a[]) {
+        if (stopped) {
+            if (a.length > 0) {
+                a[0] = null;
+            }
+            return a;
+        }
+        return proxies.values().toArray(a);
+    }
+
+    public synchronized boolean containsAll(Collection c) {
+        if (stopped) {
+            return c.isEmpty();
+        }
+        return proxies.values().containsAll(c);
+    }
+
+    public boolean add(Object o) {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean remove(Object o) {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean addAll(Collection c) {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean removeAll(Collection c) {
+        throw new UnsupportedOperationException();
+    }
+
+    public boolean retainAll(Collection c) {
+        throw new UnsupportedOperationException();
+    }
+
+    public void clear() {
+        throw new UnsupportedOperationException();
+    }
+}

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyFactory.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyMethodInterceptor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyMethodInterceptor.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawGetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawGetAttributeInvoker.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawOperationInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawOperationInvoker.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawSetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/RawSetAttributeInvoker.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/VMMethodInterceptor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/VMMethodInterceptor.java?view=auto&rev=106386
==============================================================================

Deleted: /geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/VMProxyFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/VMProxyFactory.java?view=auto&rev=106386
==============================================================================

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java&r1=106386&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/Kernel.java	Tue Nov 23 22:16:54 2004
@@ -53,6 +53,7 @@
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.config.NoSuchStoreException;
 import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
 
 
 /**
@@ -166,6 +167,12 @@
     private LifecycleMonitor lifecycleMonitor;
 
     /**
+     * This factory gbean proxies, and tracks all proxies in the system
+     * @deprecated don't use this yet... it may go away
+     */
+    private ProxyManager proxyManager;
+
+    /**
      * No-arg constructor allowing this class to be used as a GBean reference.
      */
     public Kernel() {
@@ -265,6 +272,14 @@
         return lifecycleMonitor;
     }
 
+    /**
+     * Gets the proxy manager.
+     * @deprecated don't use this yet... it may change or go away
+     */
+    public ProxyManager getProxyManager() {
+        return proxyManager;
+    }
+
     public Object getAttribute(ObjectName objectName, String attributeName) throws Exception {
         try {
             return mbServer.getAttribute(objectName, attributeName);
@@ -503,8 +518,8 @@
         mbServer = MBeanServerFactory.createMBeanServer(domainName);
         mbServer.registerMBean(this, KERNEL);
         dependencyManager = new DependencyManager(mbServer);
-
         lifecycleMonitor = new LifecycleMonitor(mbServer);
+        proxyManager = new ProxyManager(this);
 
         configurationManagerGBean = new GBeanMBean(ConfigurationManagerImpl.GBEAN_INFO);
         configurationManagerGBean.setReferencePatterns("Stores", Collections.singleton(CONFIGURATION_STORE_PATTERN));

Copied: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGetAttributeInvoker.java (from r106284, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGetAttributeInvoker.java)
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGetAttributeInvoker.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGetAttributeInvoker.java&r1=106284&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGetAttributeInvoker.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGetAttributeInvoker.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXGetAttributeInvoker.java	Tue Nov 23 22:16:54 2004
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.gbean.jmx;
+package org.apache.geronimo.kernel.jmx;
 
 import java.lang.reflect.Method;
 import javax.management.MBeanException;
@@ -29,7 +29,7 @@
 /**
  * @version $Rev$ $Date$
  */
-public final class JMXGetAttributeInvoker implements GBeanInvoker {
+public final class JMXGetAttributeInvoker implements JMXInvoker {
     private final MBeanServerConnection server;
     private final String name;
     private final Class[] declaredExceptions;

Copied: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvocationHandler.java (from r106284, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGBeanInvoker.java)
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvocationHandler.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGBeanInvoker.java&r1=106284&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvocationHandler.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXGBeanInvoker.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvocationHandler.java	Tue Nov 23 22:16:54 2004
@@ -1,6 +1,6 @@
 /**
  *
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2004 The Apache Software Foundation
  *
  *  Licensed under the Apache License, Version 2.0 (the "License");
  *  you may not use this file except in compliance with the License.
@@ -14,93 +14,168 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
+package org.apache.geronimo.kernel.jmx;
 
-package org.apache.geronimo.gbean.jmx;
-
+import java.beans.Introspector;
+import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
-import javax.management.Attribute;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.RuntimeErrorException;
-import javax.management.RuntimeMBeanException;
-import javax.management.RuntimeOperationsException;
+
+import org.apache.geronimo.gbean.GOperationSignature;
 
 /**
  * @version $Rev$ $Date$
  */
-public final class JMXGBeanInvoker implements GBeanInvoker {
-    private final MBeanServer server;
-    private final int methodType;
-    private final String name;
-    private final String[] argumentTypes;
-    private final Class[] declaredExceptions;
-
-    public JMXGBeanInvoker(MBeanServer server, Method method, int methodType) {
-        this.server = server;
-        this.methodType = methodType;
+public class JMXInvocationHandler implements InvocationHandler {
+    private final Class proxyType;
+    private final ObjectName objectName;
+    private final Map gbeanInvokers;
+
+    public JMXInvocationHandler(Class type, MBeanServerConnection server, ObjectName objectName) {
+        assert type != null;
+        assert server != null;
+        assert objectName != null;
+        this.proxyType = type;
+        this.objectName = objectName;
+        gbeanInvokers = createGBeanInvokers(server, objectName);
+    }
 
-        if (methodType == GBeanInvoker.OPERATION) {
-            name = method.getName();
-        } else {
-            // strip off the is, get, or set from the method name
-            if (method.getName().startsWith("is")) {
-                name = method.getName().substring(2);
-            } else {
-                name = method.getName().substring(3);
-            }
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+        JMXInvoker jmxInvoker = (JMXInvoker) gbeanInvokers.get(method);
+        if (jmxInvoker == null) {
+            throw new UnsupportedOperationException("No implementation method: objectName=" + objectName + ", method=" + method);
         }
 
-        // convert the parameters to a MBeanServer friendly string array
-        Class[] parameters = method.getParameterTypes();
-        argumentTypes = new String[parameters.length];
-        for (int i = 0; i < parameters.length; i++) {
-            argumentTypes[i] = parameters[i].getName();
+        return jmxInvoker.invoke(objectName, args);
+    }
+
+    public ObjectName getObjectName() {
+        return objectName;
+    }
+
+    private Map createGBeanInvokers(MBeanServerConnection server, ObjectName objectName) {
+        Map invokers = createJMXGBeanInvokers(server, objectName, proxyType);
+
+        // handle equals, hashCode and toString directly here
+        try {
+            invokers.put(Object.class.getMethod("equals", new Class[]{Object.class}), new EqualsInvoke());
+            invokers.put(Object.class.getMethod("hashCode", null), new HashCodeInvoke());
+            invokers.put(Object.class.getMethod("toString", null), new ToStringInvoke(proxyType.getName()));
+        } catch (Exception e) {
+            // this can not happen... all classes must implement equals, hashCode and toString
+            throw new AssertionError(e);
         }
 
-        declaredExceptions = method.getExceptionTypes();
+        return invokers;
     }
 
-    public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+    private Map createJMXGBeanInvokers(MBeanServerConnection server, ObjectName objectName, Class proxyType) {
+        MBeanInfo info;
         try {
-            switch (methodType) {
-                case GBeanInvoker.OPERATION:
-                    return server.invoke(objectName, name, arguments, argumentTypes);
-                case GBeanInvoker.GETTER:
-                    return server.getAttribute(objectName, name);
-                case GBeanInvoker.SETTER:
-                    server.setAttribute(objectName, new Attribute(name, arguments[0]));
-                    return null;
-                default:
-                    throw new AssertionError();
-            }
-        } catch (Throwable t) {
-            Throwable throwable = t;
-            while (true) {
-                for (int i = 0; i < declaredExceptions.length; i++) {
-                    Class declaredException = declaredExceptions[i];
-                    if (declaredException.isInstance(throwable)) {
-                        throw throwable;
-                    }
-                }
+            info = server.getMBeanInfo(objectName);
+        } catch (Exception e) {
+            throw new IllegalArgumentException("Could not get MBeanInfo for target object: " + objectName);
+        }
+
+        // build attributeName->attributeInfo map
+        MBeanAttributeInfo[] attributeInfos = info.getAttributes();
+        Map attributes = new HashMap(attributeInfos.length);
+        for (int i = 0; i < attributeInfos.length; i++) {
+            MBeanAttributeInfo attributeInfo = attributeInfos[i];
+            attributes.put(attributeInfo.getName(), attributeInfo);
+        }
+
+        // build operationName->operationInfo map
+        MBeanOperationInfo[] operationInfos = info.getOperations();
+        Map operations = new HashMap(operationInfos.length);
+        for (int i = 0; i < operationInfos.length; i++) {
+            MBeanOperationInfo operationInfo = operationInfos[i];
+            operations.put(new GOperationSignature(operationInfo), operationInfo);
+        }
+
+        // build the method lookup table
+        Method[] methods = proxyType.getMethods();
+        Map invokers = new HashMap(methods.length);
+        for (int i = 0; i < methods.length; i++) {
+            Method method = methods[i];
+            invokers.put(method, createJMXGBeanInvoker(server, method, operations, attributes));
+        }
+
+        return invokers;
+    }
+
+    private JMXInvoker createJMXGBeanInvoker(MBeanServerConnection server, Method method, Map operations, Map attributes) {
+        if (operations.containsKey(new GOperationSignature(method))) {
+            return new JMXOperationInvoker(server, method);
+        }
+
+        String name = method.getName();
+        if (name.startsWith("get")) {
+            String attrName = method.getName().substring(3);
+            if (attributes.containsKey(attrName)) {
+                return new JMXGetAttributeInvoker(server, method, attrName);
+            }
+            attrName = Introspector.decapitalize(attrName);
+            if (attributes.containsKey(attrName)) {
+                return new JMXGetAttributeInvoker(server, method, attrName);
+            }
+        } else if (name.startsWith("is")) {
+            String attrName = method.getName().substring(2);
+            if (attributes.containsKey(attrName)) {
+                return new JMXGetAttributeInvoker(server, method, attrName);
+            }
+            attrName = Introspector.decapitalize(attrName);
+            if (attributes.containsKey(attrName)) {
+                return new JMXGetAttributeInvoker(server, method, attrName);
+            }
+        } else if (name.startsWith("set")) {
+            String attrName = method.getName().substring(3);
+            if (attributes.containsKey(attrName)) {
+                return new JMXSetAttributeInvoker(server, method, attrName);
+            }
+            attrName = Introspector.decapitalize(attrName);
+            if (attributes.containsKey(attrName)) {
+                return new JMXSetAttributeInvoker(server, method, attrName);
+            }
+        }
+        return null;
+    }
+    private static final class HashCodeInvoke implements JMXInvoker {
+        public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+            return new Integer(objectName.hashCode());
+        }
+    }
 
-                // Unwrap the exceptions we understand
-                if (throwable instanceof MBeanException) {
-                    throwable = (((MBeanException) throwable).getTargetException());
-                } else if (throwable instanceof ReflectionException) {
-                    throwable = (((ReflectionException) throwable).getTargetException());
-                } else if (throwable instanceof RuntimeOperationsException) {
-                    throwable = (((RuntimeOperationsException) throwable).getTargetException());
-                } else if (throwable instanceof RuntimeMBeanException) {
-                    throwable = (((RuntimeMBeanException) throwable).getTargetException());
-                } else if (throwable instanceof RuntimeErrorException) {
-                    throwable = (((RuntimeErrorException) throwable).getTargetError());
-                } else {
-                    // don't know how to unwrap this, just throw it
-                    throw throwable;
+    private static final class EqualsInvoke implements JMXInvoker {
+        public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+            try {
+                InvocationHandler handler = Proxy.getInvocationHandler(arguments[0]);
+                if (handler instanceof JMXInvocationHandler) {
+                    ObjectName otherObjectName = ((JMXInvocationHandler) handler).getObjectName();
+                    return Boolean.valueOf(objectName.equals(otherObjectName));
                 }
+            } catch (IllegalArgumentException e) {
             }
+            return Boolean.FALSE;
+        }
+    }
+
+    private static final class ToStringInvoke implements JMXInvoker {
+        private final String interfaceName;
+
+        public ToStringInvoke(String interfaceName) {
+            this.interfaceName = "[" + interfaceName + ": ";
+        }
+
+        public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+            return interfaceName + objectName + "]";
         }
     }
 }

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvoker.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXInvoker.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.jmx;
+
+import javax.management.ObjectName;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public interface JMXInvoker {
+    Object invoke(ObjectName objectName, Object[] arguments) throws Throwable;
+}

Copied: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXOperationInvoker.java (from r106284, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXOperationInvoker.java)
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXOperationInvoker.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXOperationInvoker.java&r1=106284&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXOperationInvoker.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXOperationInvoker.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXOperationInvoker.java	Tue Nov 23 22:16:54 2004
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.gbean.jmx;
+package org.apache.geronimo.kernel.jmx;
 
 import java.lang.reflect.Method;
 import javax.management.MBeanException;
@@ -29,7 +29,7 @@
 /**
  * @version $Rev$ $Date$
  */
-public final class JMXOperationInvoker implements GBeanInvoker {
+public final class JMXOperationInvoker implements JMXInvoker {
     private final MBeanServerConnection server;
     private final String name;
     private final String[] argumentTypes;

Copied: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXSetAttributeInvoker.java (from r106284, geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXSetAttributeInvoker.java)
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXSetAttributeInvoker.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXSetAttributeInvoker.java&r1=106284&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXSetAttributeInvoker.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/JMXSetAttributeInvoker.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/JMXSetAttributeInvoker.java	Tue Nov 23 22:16:54 2004
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.gbean.jmx;
+package org.apache.geronimo.kernel.jmx;
 
 import java.lang.reflect.Method;
 import javax.management.Attribute;
@@ -30,7 +30,7 @@
 /**
  * @version $Rev$ $Date$
  */
-public final class JMXSetAttributeInvoker implements GBeanInvoker {
+public final class JMXSetAttributeInvoker implements JMXInvoker {
     private final MBeanServerConnection server;
     private final String name;
     private final Class[] declaredExceptions;

Modified: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java&r1=106386&p2=geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java	(original)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java	Tue Nov 23 22:16:54 2004
@@ -17,13 +17,10 @@
 
 package org.apache.geronimo.kernel.jmx;
 
-import java.util.Set;
+import java.lang.reflect.Proxy;
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
 
-import org.apache.geronimo.gbean.jmx.ProxyFactory;
-import org.apache.geronimo.gbean.jmx.ProxyMethodInterceptor;
-
 /**
  * MBeanProxyFactory creates a dynamic proxy to an MBean by ObjectName.
  * The interface type and object existance are enforced during construction.
@@ -31,7 +28,6 @@
  * @version $Rev$ $Date$
  */
 public final class MBeanProxyFactory {
-
     /**
      * Creates an MBean proxy using the specified interface to the objectName.
      *
@@ -39,6 +35,7 @@
      * @param server the MBeanServer in which the object is registered
      * @param objectName the objectName of the MBean to proxy
      * @return the new MBean proxy, which implemnts the specified interface
+     *
      */
     public static Object getProxy(Class type, MBeanServerConnection server, ObjectName objectName) {
         assert type != null;
@@ -46,18 +43,9 @@
 
         if (objectName.isPattern()) {
             throw new UnsupportedOperationException();
-/*
-            Set names = server.queryNames(objectName, null);
-            if (names.isEmpty()) {
-                throw new IllegalArgumentException("No names mbeans registered that match object name pattern: " + objectName);
-            }
-            objectName = (ObjectName) names.iterator().next();
-*/
         }
 
-        ProxyFactory factory = ProxyFactory.newProxyFactory(type);
-        ProxyMethodInterceptor methodInterceptor = factory.getMethodInterceptor();
-        methodInterceptor.connect(server, objectName);
-        return factory.create(methodInterceptor);
+        JMXInvocationHandler interceptor = new JMXInvocationHandler(type, server, objectName);
+        return Proxy.newProxyInstance(type.getClassLoader(), new Class[]{type}, interceptor);
     }
 }

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/DeadProxyException.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/DeadProxyException.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/DeadProxyException.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.proxy;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DeadProxyException extends IllegalStateException {
+    public DeadProxyException(String s) {
+        super(s);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelGetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelGetAttributeInvoker.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelGetAttributeInvoker.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.proxy;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class KernelGetAttributeInvoker implements ProxyInvoker {
+    private final Kernel kernel;
+    private final String name;
+
+    public KernelGetAttributeInvoker(Kernel kernel, String name) {
+        this.kernel = kernel;
+        this.name = name;
+    }
+
+    public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+        return kernel.getAttribute(objectName, name);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelOperationInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelOperationInvoker.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelOperationInvoker.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.proxy;
+
+import java.lang.reflect.Method;
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class KernelOperationInvoker implements ProxyInvoker {
+    private final Kernel kernel;
+    private final String name;
+    private final String[] argumentTypes;
+
+    public KernelOperationInvoker(Kernel kernel, Method method) {
+        this.kernel = kernel;
+        name = method.getName();
+
+        // convert the parameters to a MBeanServer friendly string array
+        Class[] parameters = method.getParameterTypes();
+        argumentTypes = new String[parameters.length];
+        for (int i = 0; i < parameters.length; i++) {
+            argumentTypes[i] = parameters[i].getName();
+        }
+    }
+
+    public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+        return kernel.invoke(objectName, name, arguments, argumentTypes);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelSetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelSetAttributeInvoker.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/KernelSetAttributeInvoker.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.proxy;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class KernelSetAttributeInvoker implements ProxyInvoker {
+    private final Kernel kernel;
+    private final String name;
+
+    public KernelSetAttributeInvoker(Kernel kernel, String name) {
+        this.kernel = kernel;
+        this.name = name;
+    }
+
+    public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+        kernel.setAttribute(objectName, name, arguments[0]);
+        return null;
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyFactory.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyFactory.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyFactory.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.kernel.proxy;
+
+import javax.management.ObjectName;
+
+
+/**
+ * @version $Rev: 71492 $ $Date: 2004-11-14 21:31:50 -0800 (Sun, 14 Nov 2004) $
+ */
+public interface ProxyFactory {
+    Object createProxy(ObjectName target);
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyInvoker.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyInvoker.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,26 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.proxy;
+
+import javax.management.ObjectName;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public interface ProxyInvoker {
+    Object invoke(ObjectName objectName, Object[] arguments) throws Throwable;
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyManager.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,103 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.proxy;
+
+import java.util.IdentityHashMap;
+import javax.management.ObjectName;
+
+import net.sf.cglib.proxy.Callback;
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.MethodInterceptor;
+import org.apache.geronimo.kernel.Kernel;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ProxyManager {
+    private final Kernel kernel;
+
+    // todo use weak keys for this
+    private final IdentityHashMap interceptors = new IdentityHashMap();
+
+    /**
+     * @deprecated don't use this yet... it may change or go away
+     */
+    public ProxyManager(Kernel kernel) {
+        this.kernel = kernel;
+    }
+
+    public synchronized ProxyFactory createProxyFactory(Class type) {
+        assert type != null: "type is null";
+        return new ManagedProxyFactory(type);
+    }
+
+    public synchronized Object createProxy(ObjectName target, Class type) {
+        assert type != null: "type is null";
+        assert target != null: "target is null";
+
+        return createProxyFactory(type).createProxy(target);
+    }
+
+    public synchronized void destroyProxy(Object proxy) {
+        if (proxy == null) {
+            return;
+        }
+
+        ProxyMethodInterceptor methodInterceptor = (ProxyMethodInterceptor) interceptors.remove(proxy);
+        if (methodInterceptor != null) {
+            methodInterceptor.destroy();
+        }
+    }
+
+    public boolean isProxy(Object proxy) {
+        return interceptors.containsKey(proxy);
+    }
+
+    public synchronized ObjectName getProxyTarget(Object proxy) {
+        ProxyMethodInterceptor methodInterceptor = (ProxyMethodInterceptor) interceptors.remove(proxy);
+        if (methodInterceptor == null) {
+            return null;
+        }
+        return methodInterceptor.getObjectName();
+    }
+
+    private class ManagedProxyFactory implements ProxyFactory {
+        private final Class type;
+        private final Enhancer enhancer;
+
+        public ManagedProxyFactory(Class type) {
+            enhancer = new Enhancer();
+            enhancer.setSuperclass(type);
+            enhancer.setCallbackType(MethodInterceptor.class);
+            enhancer.setUseFactory(false);
+            this.type = enhancer.createClass();
+        }
+
+        public synchronized Object createProxy(ObjectName target) {
+            assert target != null: "target is null";
+
+            ProxyMethodInterceptor interceptor = new ProxyMethodInterceptor(type, kernel, target);
+
+            // @todo trap CodeGenerationException indicating missing no-arg ctr
+            enhancer.setCallbacks(new Callback[]{interceptor});
+            Object proxy = enhancer.create();
+
+            interceptors.put(proxy, interceptor);
+            return proxy;
+        }
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyMethodInterceptor.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyMethodInterceptor.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/ProxyMethodInterceptor.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,306 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.proxy;
+
+import java.beans.Introspector;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.ObjectName;
+
+import net.sf.cglib.core.Signature;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+import net.sf.cglib.reflect.FastClass;
+import org.apache.geronimo.gbean.GOperationSignature;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.gbean.jmx.RawInvoker;
+import org.apache.geronimo.kernel.Kernel;
+import org.objectweb.asm.Type;
+
+/**
+ * @version $Rev: 106345 $ $Date: 2004-11-23 12:37:03 -0800 (Tue, 23 Nov 2004) $
+ */
+public class ProxyMethodInterceptor implements MethodInterceptor {
+    /**
+     * Type of the proxy interface
+     */
+    private final Class proxyType;
+
+    /**
+     * The object name to which we are connected.
+     */
+    private final ObjectName objectName;
+
+    /**
+     * GBeanInvokers keyed on the proxy interface method index
+     */
+    private ProxyInvoker[] gbeanInvokers;
+
+    public ProxyMethodInterceptor(Class proxyType, Kernel kernel, ObjectName objectName) {
+        assert proxyType != null;
+        assert kernel != null;
+        assert objectName != null;
+
+        this.proxyType = proxyType;
+        this.objectName = objectName;
+        gbeanInvokers = createGBeanInvokers(kernel, objectName);
+    }
+
+    public synchronized void destroy() {
+        gbeanInvokers = null;
+    }
+
+    public ObjectName getObjectName() {
+        return objectName;
+    }
+
+    public final Object intercept(final Object object, final Method method, final Object[] args, final MethodProxy proxy) throws Throwable {
+        ProxyInvoker gbeanInvoker;
+
+        int interfaceIndex = proxy.getSuperIndex();
+        synchronized (this) {
+            if (gbeanInvokers == null) {
+                throw new DeadProxyException("Proxy is no longer valid");
+            }
+            gbeanInvoker = gbeanInvokers[interfaceIndex];
+        }
+
+        if (gbeanInvoker == null) {
+            throw new UnsupportedOperationException("No implementation method: objectName=" + objectName + ", method=" + method);
+        }
+
+        return gbeanInvoker.invoke(objectName, args);
+    }
+
+    private ProxyInvoker[] createGBeanInvokers(Kernel kernel, ObjectName objectName) {
+        ProxyInvoker[] invokers;
+        try {
+            RawInvoker rawInvoker = (RawInvoker) kernel.getAttribute(objectName, GBeanMBean.RAW_INVOKER);
+            invokers = createRawGBeanInvokers(rawInvoker, proxyType);
+        } catch (Exception e) {
+            invokers = createKernelGBeanInvokers(kernel, objectName, proxyType);
+        }
+
+        // handle equals, hashCode and toString directly here
+        try {
+            invokers[getSuperIndex(proxyType, proxyType.getMethod("equals", new Class[]{Object.class}))] = new EqualsInvoke(kernel.getProxyManager());
+            invokers[getSuperIndex(proxyType, proxyType.getMethod("hashCode", null))] = new HashCodeInvoke();
+            invokers[getSuperIndex(proxyType, proxyType.getMethod("toString", null))] = new ToStringInvoke(proxyType.getName());
+        } catch (Exception e) {
+            // this can not happen... all classes must implement equals, hashCode and toString
+            throw new AssertionError(e);
+        }
+
+        return invokers;
+    }
+
+    private ProxyInvoker[] createRawGBeanInvokers(RawInvoker rawInvoker, Class proxyType) {
+        Map operations = rawInvoker.getOperationIndex();
+        Map attributes = rawInvoker.getAttributeIndex();
+
+        // build the method lookup table
+        FastClass fastClass = FastClass.create(proxyType);
+        ProxyInvoker[] invokers = new ProxyInvoker[fastClass.getMaxIndex() + 1];
+        Method[] methods = proxyType.getMethods();
+        for (int i = 0; i < methods.length; i++) {
+            Method method = methods[i];
+            int interfaceIndex = getSuperIndex(proxyType, method);
+            if (interfaceIndex >= 0) {
+                invokers[interfaceIndex] = createRawGBeanInvoker(rawInvoker, method, operations, attributes);
+            }
+        }
+
+        return invokers;
+    }
+
+    private ProxyInvoker createRawGBeanInvoker(RawInvoker rawInvoker, Method method, Map operations, Map attributes) {
+        if (operations.containsKey(new GOperationSignature(method))) {
+            int methodIndex = ((Integer) operations.get(new GOperationSignature(method))).intValue();
+            return new RawOperationInvoker(rawInvoker, methodIndex);
+        }
+
+        if (method.getName().startsWith("get")) {
+            String attributeName = method.getName().substring(3);
+            Integer methodIndex = ((Integer) attributes.get(attributeName));
+            if (methodIndex != null) {
+                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+            methodIndex = getMethodIndex(attributes, attributeName);
+            if (methodIndex != null) {
+                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+        }
+
+        if (method.getName().startsWith("is")) {
+            String attributeName = method.getName().substring(2);
+            Integer methodIndex = ((Integer) attributes.get(attributeName));
+            if (methodIndex != null) {
+                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+            methodIndex = getMethodIndex(attributes, attributeName);
+            if (methodIndex != null) {
+                return new RawGetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+        }
+
+        if (method.getName().startsWith("set")) {
+            String attributeName = method.getName().substring(3);
+            Integer methodIndex = ((Integer) attributes.get(attributeName));
+            if (methodIndex != null) {
+                return new RawSetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+            methodIndex = getMethodIndex(attributes, attributeName);
+            if (methodIndex != null) {
+                return new RawSetAttributeInvoker(rawInvoker, methodIndex.intValue());
+            }
+        }
+        return null;
+    }
+
+    private ProxyInvoker[] createKernelGBeanInvokers(Kernel kernel, ObjectName objectName, Class proxyType) {
+        MBeanInfo info;
+        try {
+            // todo convert this over to gbean info
+            info = kernel.getMBeanServer().getMBeanInfo(objectName);
+        } catch (Exception e) {
+            throw new IllegalArgumentException("Could not get MBeanInfo for target object: " + objectName);
+        }
+
+        // build attributeName->attributeInfo map
+        MBeanAttributeInfo[] attributeInfos = info.getAttributes();
+        Map attributes = new HashMap(attributeInfos.length);
+        for (int i = 0; i < attributeInfos.length; i++) {
+            MBeanAttributeInfo attributeInfo = attributeInfos[i];
+            attributes.put(attributeInfo.getName(), attributeInfo);
+        }
+
+        // build operationName->operationInfo map
+        MBeanOperationInfo[] operationInfos = info.getOperations();
+        Map operations = new HashMap(operationInfos.length);
+        for (int i = 0; i < operationInfos.length; i++) {
+            MBeanOperationInfo operationInfo = operationInfos[i];
+            operations.put(new GOperationSignature(operationInfo), operationInfo);
+        }
+
+        // build the method lookup table
+        FastClass fastClass = FastClass.create(proxyType);
+        ProxyInvoker[] invokers = new ProxyInvoker[fastClass.getMaxIndex() + 1];
+        Method[] methods = proxyType.getMethods();
+        for (int i = 0; i < methods.length; i++) {
+            Method method = methods[i];
+            int interfaceIndex = getSuperIndex(proxyType, method);
+            if (interfaceIndex >= 0) {
+                invokers[interfaceIndex] = createJMXGBeanInvoker(kernel, method, operations, attributes);
+            }
+        }
+
+        return invokers;
+    }
+
+    private ProxyInvoker createJMXGBeanInvoker(Kernel kernel, Method method, Map operations, Map attributes) {
+        if (operations.containsKey(new GOperationSignature(method))) {
+            return new KernelOperationInvoker(kernel, method);
+        }
+
+        String name = method.getName();
+        if (name.startsWith("get")) {
+            String attrName = method.getName().substring(3);
+            if (attributes.containsKey(attrName)) {
+                return new KernelGetAttributeInvoker(kernel, attrName);
+            }
+            attrName = Introspector.decapitalize(attrName);
+            if (attributes.containsKey(attrName)) {
+                return new KernelGetAttributeInvoker(kernel, attrName);
+            }
+        } else if (name.startsWith("is")) {
+            String attrName = method.getName().substring(2);
+            if (attributes.containsKey(attrName)) {
+                return new KernelGetAttributeInvoker(kernel, attrName);
+            }
+            attrName = Introspector.decapitalize(attrName);
+            if (attributes.containsKey(attrName)) {
+                return new KernelGetAttributeInvoker(kernel, attrName);
+            }
+        } else if (name.startsWith("set")) {
+            String attrName = method.getName().substring(3);
+            if (attributes.containsKey(attrName)) {
+                return new KernelSetAttributeInvoker(kernel, attrName);
+            }
+            attrName = Introspector.decapitalize(attrName);
+            if (attributes.containsKey(attrName)) {
+                return new KernelSetAttributeInvoker(kernel, attrName);
+            }
+        }
+        return null;
+    }
+
+    private static int getSuperIndex(Class proxyType, Method method) {
+        Signature signature = new Signature(method.getName(), Type.getReturnType(method), Type.getArgumentTypes(method));
+        MethodProxy methodProxy = MethodProxy.find(proxyType, signature);
+        if (methodProxy != null) {
+            return methodProxy.getSuperIndex();
+        }
+        return -1;
+    }
+
+    private static Integer getMethodIndex(Map attributes, String attributeName) {
+        Iterator iter = attributes.keySet().iterator();
+        while (iter.hasNext()) {
+            String key = (String) iter.next();
+            if (key.equalsIgnoreCase(attributeName)) {
+                return (Integer) attributes.get(key);
+            }
+        }
+        return null;
+    }
+
+    static final class HashCodeInvoke implements ProxyInvoker {
+        public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+            return new Integer(objectName.hashCode());
+        }
+    }
+
+    static final class EqualsInvoke implements ProxyInvoker {
+        private final ProxyManager proxyManager;
+
+        public EqualsInvoke(ProxyManager proxyManager) {
+            this.proxyManager = proxyManager;
+        }
+
+        public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+            ObjectName proxyTarget = proxyManager.getProxyTarget(arguments[0]);
+            return Boolean.valueOf(objectName.equals(proxyTarget));
+        }
+    }
+
+    static final class ToStringInvoke implements ProxyInvoker {
+        private final String interfaceName;
+
+        public ToStringInvoke(String interfaceName) {
+            this.interfaceName = "[" + interfaceName + ": ";
+        }
+
+        public Object invoke(ObjectName objectName, Object[] arguments) throws Throwable {
+            return interfaceName + objectName + "]";
+        }
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawGetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawGetAttributeInvoker.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawGetAttributeInvoker.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.proxy;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.jmx.RawInvoker;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class RawGetAttributeInvoker implements ProxyInvoker {
+    private final RawInvoker rawInvoker;
+    private final int methodIndex;
+
+    public RawGetAttributeInvoker(RawInvoker rawInvoker, int methodIndex) {
+        this.rawInvoker = rawInvoker;
+        this.methodIndex = methodIndex;
+    }
+
+    public Object invoke(final ObjectName objectName, final Object[] arguments) throws Throwable {
+        return rawInvoker.getAttribute(methodIndex);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawOperationInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawOperationInvoker.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawOperationInvoker.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.proxy;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.jmx.RawInvoker;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class RawOperationInvoker implements ProxyInvoker {
+    private final RawInvoker rawInvoker;
+    private final int methodIndex;
+
+    public RawOperationInvoker(RawInvoker rawInvoker, int methodIndex) {
+        this.rawInvoker = rawInvoker;
+        this.methodIndex = methodIndex;
+    }
+
+    public Object invoke(final ObjectName objectName, final Object[] arguments) throws Throwable {
+        return rawInvoker.invoke(methodIndex, arguments);
+    }
+}

Added: geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawSetAttributeInvoker.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawSetAttributeInvoker.java?view=auto&rev=106387
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/kernel/src/java/org/apache/geronimo/kernel/proxy/RawSetAttributeInvoker.java	Tue Nov 23 22:16:54 2004
@@ -0,0 +1,39 @@
+/**
+ *
+ * Copyright 2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.kernel.proxy;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.jmx.RawInvoker;
+
+/**
+ * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
+ */
+public final class RawSetAttributeInvoker implements ProxyInvoker {
+    private final RawInvoker rawInvoker;
+    private final int methodIndex;
+
+    public RawSetAttributeInvoker(RawInvoker rawInvoker, int methodIndex) {
+        this.rawInvoker = rawInvoker;
+        this.methodIndex = methodIndex;
+    }
+
+    public Object invoke(final ObjectName objectName, final Object[] arguments) throws Throwable {
+        rawInvoker.setAttribute(methodIndex, arguments[0]);
+        return null;
+    }
+}

Modified: geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java?view=diff&rev=106387&p1=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java&r1=106386&p2=geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java	(original)
+++ geronimo/trunk/modules/kernel/src/test/org/apache/geronimo/gbean/Speed.java	Tue Nov 23 22:16:54 2004
@@ -20,20 +20,13 @@
  * @version $Rev$ $Date$
  */
 import java.lang.reflect.Method;
-
 import javax.management.ObjectName;
 
 import net.sf.cglib.reflect.FastClass;
-import net.sf.cglib.proxy.MethodProxy;
-import org.apache.geronimo.gbean.jmx.CGLibProxyFactory;
-import org.apache.geronimo.gbean.jmx.ProxyFactory;
-import org.apache.geronimo.gbean.jmx.ProxyMethodInterceptor;
-import org.apache.geronimo.gbean.jmx.VMProxyFactory;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
-import org.apache.geronimo.gbean.jmx.CGLibMethodInterceptor;
-import org.apache.geronimo.gbean.jmx.RawInvoker;
-import org.apache.geronimo.kernel.MockGBean;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.MockGBean;
+import org.apache.geronimo.gbean.jmx.RawInvoker;
 
 /**
  * @version $Rev$ $Date$
@@ -112,27 +105,27 @@
         kernel.startGBean(objectName);
 
         // reflect proxy
-        ProxyFactory vmProxyFactory = new VMProxyFactory(MyInterface.class);
-        ProxyMethodInterceptor vmMethodInterceptor = vmProxyFactory.getMethodInterceptor();
-        MyInterface vmProxy = (MyInterface) vmProxyFactory.create(vmMethodInterceptor);
-        vmMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
-        iterations = 50000;
-        for (int i = 0; i < iterations; i++) {
-            vmProxy.doNothing();
-        }
-        start = System.currentTimeMillis();
-        for (int i = 0; i < iterations; i++) {
-            vmProxy.doNothing();
-        }
-        end = System.currentTimeMillis();
-        printResults("ReflectionProxy", end, start, iterations);
+//        ProxyFactory vmProxyFactory = new VMProxyFactory(MyInterface.class);
+//        ProxyMethodInterceptor vmMethodInterceptor = vmProxyFactory.getMethodInterceptor();
+//        MyInterface vmProxy = (MyInterface) vmProxyFactory.create(vmMethodInterceptor);
+//        vmMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
+//        iterations = 50000;
+//        for (int i = 0; i < iterations; i++) {
+//            vmProxy.doNothing();
+//        }
+//        start = System.currentTimeMillis();
+//        for (int i = 0; i < iterations; i++) {
+//            vmProxy.doNothing();
+//        }
+//        end = System.currentTimeMillis();
+//        printResults("ReflectionProxy", end, start, iterations);
 
         // cglib proxy (front half)
 /*
         ProxyFactory frontCGLibProxyFactory = new CGLibProxyFactory(MyInterface.class);
-        ProxyMethodInterceptor frontCGLibMethodInterceptor = new CGLibMethodInterceptor(MyInterface.class);
+        ProxyMethodInterceptor frontCGLibMethodInterceptor = new ProxyMethodInterceptor(MyInterface.class);
         Class enhancedType = frontCGLibProxyFactory.create(frontCGLibMethodInterceptor).getClass();
-        frontCGLibMethodInterceptor = new CGLibMethodInterceptor(enhancedType) {
+        frontCGLibMethodInterceptor = new ProxyMethodInterceptor(enhancedType) {
             public Object intercept(Object object, Method method, Object[] args, MethodProxy proxy) throws Throwable {
                 return null;
             }
@@ -165,21 +158,21 @@
         end = System.currentTimeMillis();
         printResults("Raw Invoker", end, start, iterations);
 
-        // cglib proxy
-        ProxyFactory cgLibProxyFactory = new CGLibProxyFactory(MyInterface.class);
-        ProxyMethodInterceptor cgLibMethodInterceptor = cgLibProxyFactory.getMethodInterceptor();
-        MyInterface cgLibProxy = (MyInterface) cgLibProxyFactory.create(cgLibMethodInterceptor);
-        cgLibMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
-        iterations = 1000000;
-        for (int i = 0; i < iterations; i++) {
-            cgLibProxy.doNothing();
-        }
-        start = System.currentTimeMillis();
-        for (int i = 0; i < iterations; i++) {
-            cgLibProxy.doNothing();
-        }
-        end = System.currentTimeMillis();
-        printResults("CGLibProxy", end, start, iterations);
+//        // cglib proxy
+//        ProxyFactory cgLibProxyFactory = new CGLibProxyFactory(MyInterface.class);
+//        ProxyMethodInterceptor cgLibMethodInterceptor = cgLibProxyFactory.getMethodInterceptor();
+//        MyInterface cgLibProxy = (MyInterface) cgLibProxyFactory.create(cgLibMethodInterceptor);
+//        cgLibMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
+//        iterations = 1000000;
+//        for (int i = 0; i < iterations; i++) {
+//            cgLibProxy.doNothing();
+//        }
+//        start = System.currentTimeMillis();
+//        for (int i = 0; i < iterations; i++) {
+//            cgLibProxy.doNothing();
+//        }
+//        end = System.currentTimeMillis();
+//        printResults("CGLibProxy", end, start, iterations);
     }
 
 
@@ -242,36 +235,36 @@
         kernel.startGBean(objectName);
 
         // reflect proxy
-        ProxyFactory vmProxyFactory = new VMProxyFactory(MyInterface.class);
-        ProxyMethodInterceptor vmMethodInterceptor = vmProxyFactory.getMethodInterceptor();
-        MyInterface vmProxy = (MyInterface) vmProxyFactory.create(vmMethodInterceptor);
-        vmMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
-        iterations = 50000;
-        for (int i = 0; i < iterations; i++) {
-            result = vmProxy.echo(msg);
-        }
-        start = System.currentTimeMillis();
-        for (int i = 0; i < iterations; i++) {
-            result = vmProxy.echo(msg);
-        }
-        end = System.currentTimeMillis();
-        printResults("ReflectionProxy", end, start, iterations);
-
-        // cglib proxy
-        ProxyFactory cgLibProxyFactory = new CGLibProxyFactory(MyInterface.class);
-        ProxyMethodInterceptor cgLibMethodInterceptor = cgLibProxyFactory.getMethodInterceptor();
-        MyInterface cgLibProxy = (MyInterface) cgLibProxyFactory.create(cgLibMethodInterceptor);
-        cgLibMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
-        iterations = 1000000;
-        for (int i = 0; i < iterations; i++) {
-            result = cgLibProxy.echo(msg);
-        }
-        start = System.currentTimeMillis();
-        for (int i = 0; i < iterations; i++) {
-            result = cgLibProxy.echo(msg);
-        }
-        end = System.currentTimeMillis();
-        printResults("CGLibProxy", end, start, iterations);
+//        ProxyFactory vmProxyFactory = new VMProxyFactory(MyInterface.class);
+//        ProxyMethodInterceptor vmMethodInterceptor = vmProxyFactory.getMethodInterceptor();
+//        MyInterface vmProxy = (MyInterface) vmProxyFactory.create(vmMethodInterceptor);
+//        vmMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
+//        iterations = 50000;
+//        for (int i = 0; i < iterations; i++) {
+//            result = vmProxy.echo(msg);
+//        }
+//        start = System.currentTimeMillis();
+//        for (int i = 0; i < iterations; i++) {
+//            result = vmProxy.echo(msg);
+//        }
+//        end = System.currentTimeMillis();
+//        printResults("ReflectionProxy", end, start, iterations);
+
+//        // cglib proxy
+//        ProxyFactory cgLibProxyFactory = new CGLibProxyFactory(MyInterface.class);
+//        ProxyMethodInterceptor cgLibMethodInterceptor = cgLibProxyFactory.getMethodInterceptor();
+//        MyInterface cgLibProxy = (MyInterface) cgLibProxyFactory.create(cgLibMethodInterceptor);
+//        cgLibMethodInterceptor.connect(kernel.getMBeanServer(), objectName);
+//        iterations = 1000000;
+//        for (int i = 0; i < iterations; i++) {
+//            result = cgLibProxy.echo(msg);
+//        }
+//        start = System.currentTimeMillis();
+//        for (int i = 0; i < iterations; i++) {
+//            result = cgLibProxy.echo(msg);
+//        }
+//        end = System.currentTimeMillis();
+//        printResults("CGLibProxy", end, start, iterations);
     }
 
     private static void printResults(String invocationType, long end, long start, int iterations) {

Modified: geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java?view=diff&rev=106387&p1=geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java&r1=106386&p2=geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java	(original)
+++ geronimo/trunk/modules/remoting/src/test/org/apache/geronimo/remoting/JMXRemotingTest.java	Tue Nov 23 22:16:54 2004
@@ -17,18 +17,15 @@
 
 package org.apache.geronimo.remoting;
 
-import javax.management.ObjectName;
-import javax.management.MBeanServer;
 import java.net.URI;
 import java.util.Collections;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
 
 import junit.framework.TestCase;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
-import org.apache.geronimo.remoting.MarshalledObject;
 import org.apache.geronimo.remoting.jmx.RemoteMBeanServerFactory;
-import org.apache.geronimo.remoting.transport.TransportLoader;
 import org.apache.geronimo.remoting.transport.BytesMarshalledObject;
 
 
@@ -78,8 +75,7 @@
         kernel.startGBean(jmxRouter);
         kernel.startGBean(serverStub);
 
-        TransportLoader bean = (TransportLoader) MBeanProxyFactory.getProxy(TransportLoader.class, kernel.getMBeanServer(), asyncTransport);
-        connectURI = bean.getClientConnectURI();
+        connectURI = (URI) kernel.getAttribute(asyncTransport, "clientConnectURI"); 
 
         // simulate remote copy of handle
         MarshalledObject mo = new BytesMarshalledObject(RemoteMBeanServerFactory.create(connectURI.getHost(), connectURI.getPort()));

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java?view=diff&rev=106387&p1=geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java&r1=106386&p2=geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java	(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/jaas/JaasLoginCoordinator.java	Tue Nov 23 22:16:54 2004
@@ -16,17 +16,23 @@
  */
 package org.apache.geronimo.security.jaas;
 
-import org.apache.geronimo.security.remoting.jmx.JaasLoginServiceRemotingClient;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
-
-import javax.security.auth.spi.LoginModule;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import javax.security.auth.Subject;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.Callback;
-import java.util.*;
-import java.security.Principal;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
+import org.apache.geronimo.security.remoting.jmx.JaasLoginServiceRemotingClient;
 
 /**
  * A LoginModule implementation which connects to a Geronimo server under

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java?view=diff&rev=106387&p1=geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java&r1=106386&p2=geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java	(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/GenericSecurityRealm.java	Tue Nov 23 22:16:54 2004
@@ -16,26 +16,25 @@
  */
 package org.apache.geronimo.security.realm;
 
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
-import java.util.Collections;
-import java.util.Iterator;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.security.auth.spi.LoginModule;
+
 import org.apache.geronimo.common.GeronimoSecurityException;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
 import org.apache.geronimo.security.deploy.Principal;
 import org.apache.geronimo.security.jaas.ConfigurationEntryFactory;
 import org.apache.geronimo.security.jaas.JaasLoginCoordinator;
@@ -221,6 +220,7 @@
         Set domains = new HashSet();
         List list = new ArrayList();
         LoginModuleControlFlagEditor editor = new LoginModuleControlFlagEditor();
+        ProxyManager proxyManager = kernel.getProxyManager();
         while (true) {
             boolean found = false;
             String prefix = "LoginModule." + i + ".";
@@ -230,31 +230,36 @@
                     String flagName = key.substring(prefix.length()).toUpperCase();
                     editor.setAsText(flagName);
                     LoginModuleControlFlag flag = (LoginModuleControlFlag) editor.getValue();
-                    LoginModuleGBean module = (LoginModuleGBean) MBeanProxyFactory.getProxy(LoginModuleGBean.class, kernel.getMBeanServer(), new ObjectName(props.getProperty(key)));
-                    Map options = module.getOptions();
-                    if (options != null) {
-                        options = new HashMap(options);
-                    } else {
-                        options = new HashMap();
-                    }
-                    if (kernel != null && !options.containsKey(KERNEL_LM_OPTION)) {
-                        options.put(KERNEL_LM_OPTION, kernel.getKernelName());
-                    }
-                    if (serverInfo != null && !options.containsKey(SERVERINFO_LM_OPTION)) {
-                        options.put(SERVERINFO_LM_OPTION, serverInfo);
-                    }
-                    if (classLoader != null && !options.containsKey(CLASSLOADER_LM_OPTION)) {
-                        options.put(CLASSLOADER_LM_OPTION, classLoader);
-                    }
-                    if(module.getLoginDomainName() != null) {
-                        if(domains.contains(module.getLoginDomainName())) {
-                            throw new IllegalStateException("Error in "+realmName+": one security realm cannot contain multiple login modules for the same login domain");
+                    LoginModuleGBean module = null;
+                    try {
+                        module = (LoginModuleGBean) proxyManager.createProxy(new ObjectName(props.getProperty(key)), LoginModuleGBean.class);
+                        Map options = module.getOptions();
+                        if (options != null) {
+                            options = new HashMap(options);
                         } else {
-                            domains.add(module.getLoginDomainName());
+                            options = new HashMap();
+                        }
+                        if (kernel != null && !options.containsKey(KERNEL_LM_OPTION)) {
+                            options.put(KERNEL_LM_OPTION, kernel.getKernelName());
+                        }
+                        if (serverInfo != null && !options.containsKey(SERVERINFO_LM_OPTION)) {
+                            options.put(SERVERINFO_LM_OPTION, serverInfo);
+                        }
+                        if (classLoader != null && !options.containsKey(CLASSLOADER_LM_OPTION)) {
+                            options.put(CLASSLOADER_LM_OPTION, classLoader);
+                        }
+                        if(module.getLoginDomainName() != null) {
+                            if(domains.contains(module.getLoginDomainName())) {
+                                throw new IllegalStateException("Error in "+realmName+": one security realm cannot contain multiple login modules for the same login domain");
+                            } else {
+                                domains.add(module.getLoginDomainName());
+                            }
                         }
+                        JaasLoginModuleConfiguration config = new JaasLoginModuleConfiguration(module.getLoginModuleClass(), flag, options, module.isServerSide(), module.getLoginDomainName());
+                        list.add(config);
+                    } finally {
+                        proxyManager.destroyProxy(module);
                     }
-                    JaasLoginModuleConfiguration config = new JaasLoginModuleConfiguration(module.getLoginModuleClass(), flag, options, module.isServerSide(), module.getLoginDomainName());
-                    list.add(config);
                     ++i;
                     found = true;
                     break;

Modified: geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java?view=diff&rev=106387&p1=geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java&r1=106386&p2=geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java&r2=106387
==============================================================================
--- geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java	(original)
+++ geronimo/trunk/modules/security/src/test/org/apache/geronimo/security/remoting/jmx/RemoteLoginTest.java	Tue Nov 23 22:16:54 2004
@@ -34,8 +34,6 @@
 import junit.framework.TestCase;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.jmx.MBeanProxyFactory;
-import org.apache.geronimo.remoting.transport.TransportLoader;
 import org.apache.geronimo.security.IdentificationPrincipal;
 import org.apache.geronimo.security.RealmPrincipal;
 import org.apache.geronimo.security.jaas.JaasLoginServiceMBean;
@@ -182,16 +180,13 @@
         kernel.startGBean(secureJmxRouter);
         kernel.startGBean(serverStub);
 
-        TransportLoader bean = (TransportLoader) MBeanProxyFactory.getProxy(TransportLoader.class, kernel.getMBeanServer(), asyncTransport);
-        URI connectURI = bean.getClientConnectURI();
+        URI connectURI = (URI) kernel.getAttribute(asyncTransport, "clientConnectURI");
         asyncRemoteProxy = JaasLoginServiceRemotingClient.create(connectURI.getHost(), connectURI.getPort());
 
-        bean = (TransportLoader) MBeanProxyFactory.getProxy(TransportLoader.class, kernel.getMBeanServer(), saslTransport);
-        connectURI = bean.getClientConnectURI();
+        connectURI = (URI) kernel.getAttribute(saslTransport, "clientConnectURI");
         saslRemoteProxy = JaasLoginServiceRemotingClient.create(connectURI.getHost(), connectURI.getPort());
 
-        bean = (TransportLoader) MBeanProxyFactory.getProxy(TransportLoader.class, kernel.getMBeanServer(), gssapiTransport);
-        connectURI = bean.getClientConnectURI();
+        connectURI = (URI) kernel.getAttribute(gssapiTransport, "clientConnectURI");
         gssapiRemoteProxy = JaasLoginServiceRemotingClient.create(connectURI.getHost(), connectURI.getPort());
     }
 

Mime
View raw message