geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 53819 - in geronimo/trunk/modules/connector/src: java/org/apache/geronimo/connector java/org/apache/geronimo/connector/deployment test/org/apache/geronimo/connector
Date Tue, 05 Oct 2004 19:57:15 GMT
Author: djencks
Date: Tue Oct  5 12:57:11 2004
New Revision: 53819

Modified:
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/AdminObjectWrapperTest.java
Log:
Return the actual AdminObject rather than a proxy.  cf GERONIMO-362. ConnectionFactories have
severe problems with serialization

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
Tue Oct  5 12:57:11 2004
@@ -36,52 +36,35 @@
  *
  * @version $Rev$ $Date$
  */
-public class AdminObjectWrapper implements GBeanLifecycle, DynamicGBean {
+public class AdminObjectWrapper implements DynamicGBean {
 
-    private final Class adminObjectInterface;
     private final Class adminObjectClass;
 
     private final DynamicGBeanDelegate delegate;
     private final Object adminObject;
-    private final Kernel kernel;
-    private final String objectName;
 
-    private ConnectorMethodInterceptor interceptor;
-    private Object proxy;
 
     /**
      * Default constructor required when a class is used as a GBean Endpoint.
      */
     public AdminObjectWrapper() {
-        adminObjectInterface = null;
         adminObjectClass = null;
         adminObject = null;
         delegate = null;
-        kernel = null;
-        objectName = null;
     }
 
     /**
      * Normal managed constructor.
      *
-     * @param adminObjectInterface Interface the proxy will implement.
      * @param adminObjectClass Class of admin object to be wrapped.
-     * @param kernel name is used so proxy can find correct kernel.
-     * @param objectName is used by proxy to find this gbean to reconnect to.
      * @throws IllegalAccessException
      * @throws InstantiationException
      */
-    public AdminObjectWrapper(final Class adminObjectInterface,
-                              final Class adminObjectClass,
-                              final Kernel kernel,
-                              final String objectName) throws IllegalAccessException, InstantiationException
{
-        this.adminObjectInterface = adminObjectInterface;
+    public AdminObjectWrapper(final Class adminObjectClass) throws IllegalAccessException,
InstantiationException {
         this.adminObjectClass = adminObjectClass;
         adminObject = adminObjectClass.newInstance();
         delegate = new DynamicGBeanDelegate();
         delegate.addAll(adminObject);
-        this.kernel = kernel;
-        this.objectName = objectName;
     }
 
     /**
@@ -97,53 +80,10 @@
      * @return proxy implementing adminObjectInterface.
      */
     public Object getProxy() {
-        return proxy;
+        return adminObject;
     }
 
-    /**
-     * Returns the MethodInterceptor the proxy communicates with when connected.
-     * @return MethodInterceptor the proxy calls.
-     */
-    public Object getMethodInterceptor() {
-        return interceptor;
-    }
-
-    /**
-     * GBean start method.
-     * @throws WaitingException
-     * @throws Exception
-     */
-    public void doStart() throws WaitingException, Exception {
-        if (proxy == null) {
-            //build proxy
-            Enhancer enhancer = new Enhancer();
-            enhancer.setSuperclass(adminObjectInterface);
-            enhancer.setCallbackType(MethodInterceptor.class);
-            //TODO is this correct?
-            enhancer.setUseFactory(false);
-            interceptor = new ConnectorMethodInterceptor(kernel.getKernelName(), ObjectName.getInstance(objectName));
-            enhancer.setCallbacks(new Callback[]{interceptor});
-            proxy = enhancer.create(new Class[0], new Object[0]);
-        }
-        //connect proxy
-        interceptor.setInternalProxy(adminObject);
-    }
 
-    /**
-     * GBean stop method.
-     * @throws WaitingException
-     * @throws Exception
-     */
-    public void doStop() throws WaitingException, Exception {
-        //disconnect proxy
-        interceptor.setInternalProxy(null);
-    }
-
-    /**
-     * GBean fail method.
-     */
-    public void doFail() {
-    }
 
     //DynamicGBean implementation
 
@@ -184,20 +124,12 @@
 
     static {
         GBeanInfoFactory infoFactory = new GBeanInfoFactory(AdminObjectWrapper.class);
-        infoFactory.addAttribute("adminObjectInterface", Class.class, true);
         infoFactory.addAttribute("adminObjectClass", Class.class, true);
-        infoFactory.addAttribute("kernel", Kernel.class, false);
-        infoFactory.addAttribute("objectName", String.class, false);
 
         infoFactory.addOperation("getProxy");
-        infoFactory.addOperation("getMethodInterceptor");
 
 
-        infoFactory.setConstructor(new String[]{
-            "adminObjectInterface",
-            "adminObjectClass",
-            "kernel",
-            "objectName"});
+        infoFactory.setConstructor(new String[]{"adminObjectClass"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Tue Oct  5 12:57:11 2004
@@ -421,7 +421,7 @@
 
                 // set the standard properties
                 try {
-                    adminObjectGBean.setAttribute("adminObjectInterface", cl.loadClass(adminObjectInterface));
+//                    adminObjectGBean.setAttribute("adminObjectInterface", cl.loadClass(adminObjectInterface));
                     adminObjectGBean.setAttribute("adminObjectClass", cl.loadClass(adminObject.getAdminobjectClass().getStringValue()));
                 } catch (Exception e) {
                     throw new DeploymentException("Could not initialize AdminObject", e);

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/AdminObjectWrapperTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/AdminObjectWrapperTest.java
(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/AdminObjectWrapperTest.java
Tue Oct  5 12:57:11 2004
@@ -51,13 +51,14 @@
         MockAdminObject mockAdminObject = ((MockAdminObject) proxy).getSomething();
         assertNotNull(mockAdminObject);
         kernel.stopGBean(selfName);
-        try {
-            ((MockAdminObject) proxy).getSomething();
-            fail();
-        } catch (IllegalStateException ise) {
-        }
-        kernel.startGBean(selfName);
-        ((MockAdminObject) proxy).getSomething();
+        //byebye nice properties:-)
+//        try {
+//            ((MockAdminObject) proxy).getSomething();
+//            fail();
+//        } catch (IllegalStateException ise) {
+//        }
+//        kernel.startGBean(selfName);
+//        ((MockAdminObject) proxy).getSomething();
     }
 
     public void testSerialization() throws Exception {
@@ -77,11 +78,11 @@
         kernel.stopGBean(selfName);
         ObjectInputStream ois2 = new ObjectInputStream(new ByteArrayInputStream(bytes));
         MockAdminObject proxy3 = (MockAdminObject) ois2.readObject();
-        try {
-            proxy3.getSomething();
-            fail();
-        } catch (IllegalStateException ise) {
-        }
+//        try {
+//            proxy3.getSomething();
+//            fail();
+//        } catch (IllegalStateException ise) {
+//        }
         kernel.startGBean(selfName);
         proxy3.getSomething();
 
@@ -109,7 +110,7 @@
         selfName = refFactory.createAdminObjectObjectName(TARGET_NAME);
 
         GBeanMBean aow = new GBeanMBean(AdminObjectWrapper.getGBeanInfo());
-        aow.setAttribute("adminObjectInterface", MockAdminObject.class);
+//        aow.setAttribute("adminObjectInterface", MockAdminObject.class);
         aow.setAttribute("adminObjectClass", MockAdminObjectImpl.class);
         kernel.loadGBean(selfName, aow);
 

Mime
View raw message