geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 54745 - in geronimo/trunk/modules/connector/src: java/org/apache/geronimo/connector test/org/apache/geronimo/connector
Date Wed, 13 Oct 2004 18:01:47 GMT
Author: djencks
Date: Wed Oct 13 11:01:46 2004
New Revision: 54745

Modified:
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/AdminObjectWrapperTest.java
Log:
fix AdminObjectWrapper gbean and tests

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
Wed Oct 13 11:01:46 2004
@@ -17,18 +17,10 @@
 
 package org.apache.geronimo.connector;
 
-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.gbean.DynamicGBean;
 import org.apache.geronimo.gbean.DynamicGBeanDelegate;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.gbean.WaitingException;
-import org.apache.geronimo.kernel.Kernel;
 
 /**
  * Wrapper around AdminObject that exposes its config-properties as GBeanAttributes and
@@ -36,18 +28,13 @@
  *
  * @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.
@@ -57,8 +44,6 @@
         adminObjectClass = null;
         adminObject = null;
         delegate = null;
-        kernel = null;
-        objectName = null;
     }
 
     /**
@@ -66,22 +51,20 @@
      *
      * @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
{
+                              final Class adminObjectClass) throws IllegalAccessException,
InstantiationException {
         this.adminObjectInterface = adminObjectInterface;
         this.adminObjectClass = adminObjectClass;
         adminObject = adminObjectClass.newInstance();
         delegate = new DynamicGBeanDelegate();
         delegate.addAll(adminObject);
-        this.kernel = kernel;
-        this.objectName = objectName;
+    }
+
+    public Class getAdminObjectInterface() {
+        return adminObjectInterface;
     }
 
     /**
@@ -97,53 +80,9 @@
      * @return proxy implementing adminObjectInterface.
      */
     public Object getProxy() {
-        return proxy;
-    }
-
-    /**
-     * 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(adminObjectClass);
-            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);
+        return 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
 
@@ -186,18 +125,13 @@
         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"});
+        });
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

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
Wed Oct 13 11:01:46 2004
@@ -50,14 +50,14 @@
         assertTrue(proxy instanceof MockAdminObject);
         MockAdminObject mockAdminObject = ((MockAdminObject) proxy).getSomething();
         assertNotNull(mockAdminObject);
-        kernel.stopGBean(selfName);
-        try {
-            ((MockAdminObject) proxy).getSomething();
-            fail();
-        } catch (IllegalStateException ise) {
-        }
-        kernel.startGBean(selfName);
-        ((MockAdminObject) proxy).getSomething();
+//        kernel.stopGBean(selfName);
+//        try {
+//            ((MockAdminObject) proxy).getSomething();
+//            fail();
+//        } catch (IllegalStateException ise) {
+//        }
+//        kernel.startGBean(selfName);
+//        ((MockAdminObject) proxy).getSomething();
     }
 
     public void testSerialization() throws Exception {
@@ -77,11 +77,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();
 

Mime
View raw message