geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r541105 - in /geronimo/server/trunk: applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/databasemanager/wizard/ modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ modules/g...
Date Wed, 23 May 2007 22:27:57 GMT
Author: djencks
Date: Wed May 23 15:27:56 2007
New Revision: 541105

URL: http://svn.apache.org/viewvc?view=rev&rev=541105
Log:
GERONIMO-3175 make connection managers serializable, move some references around.

Added:
    geronimo/server/trunk/modules/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBeanSerializationTest.java
  (with props)
Modified:
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
    geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
    geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java
    geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBean.java
    geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java?view=diff&rev=541105&r1=541104&r2=541105
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/databasemanager/wizard/DatabasePoolPortlet.java
Wed May 23 15:27:56 2007
@@ -49,13 +49,10 @@
 import java.util.SortedSet;
 import javax.enterprise.deploy.model.DDBean;
 import javax.enterprise.deploy.model.DDBeanRoot;
-import javax.enterprise.deploy.shared.StateType;
 import javax.enterprise.deploy.spi.DeploymentConfiguration;
 import javax.enterprise.deploy.spi.DeploymentManager;
 import javax.enterprise.deploy.spi.Target;
 import javax.enterprise.deploy.spi.TargetModuleID;
-import javax.enterprise.deploy.spi.status.ProgressEvent;
-import javax.enterprise.deploy.spi.status.ProgressListener;
 import javax.enterprise.deploy.spi.status.ProgressObject;
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
@@ -636,7 +633,7 @@
             log.error("Unable to look up connection property", e);
         }
         //todo: push the lookup into ManagementHelper
-        PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManager();
+        PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManagerContainer();
         data.minSize = Integer.toString(pool.getPartitionMinSize());
         data.maxSize = Integer.toString(pool.getPartitionMaxSize());
         data.blockingTimeout = Integer.toString(pool.getBlockingTimeoutMilliseconds());
@@ -1020,7 +1017,7 @@
                     }
                 }
                 //todo: push the lookup into ManagementHelper
-                PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManager();
+                PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManagerContainer();
                 pool.setPartitionMinSize(data.minSize == null || data.minSize.equals("")
? 0 : Integer.parseInt(data.minSize));
                 pool.setPartitionMaxSize(data.maxSize == null || data.maxSize.equals("")
? 10 : Integer.parseInt(data.maxSize));
                 pool.setBlockingTimeoutMilliseconds(data.blockingTimeout == null || data.blockingTimeout.equals("")
? 5000 : Integer.parseInt(data.blockingTimeout));

Modified: geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java?view=diff&rev=541105&r1=541104&r2=541105
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
(original)
+++ geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
Wed May 23 15:27:56 2007
@@ -45,7 +45,7 @@
         return mcf.createConnectionFactory(this);
     }
 
-    public ConnectionManager getConnectionManager() {
+    protected ConnectionManager getConnectionManager() {
         return this;
     }
     

Modified: geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java?view=diff&rev=541105&r1=541104&r2=541105
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionManagerContainer.java
Wed May 23 15:27:56 2007
@@ -37,8 +37,6 @@
 
     ReturnableXAResource getRecoveryXAResource(ManagedConnectionFactory managedConnectionFactory)
throws ResourceException;
 
-    ConnectionManager getConnectionManager();
-
     public class ReturnableXAResource implements NamedXAResource {
         private final ConnectionInterceptor stack;
         private final ConnectionInfo connectionInfo;

Modified: geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBean.java?view=diff&rev=541105&r1=541104&r2=541105
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBean.java
Wed May 23 15:27:56 2007
@@ -16,40 +16,57 @@
  */
 package org.apache.geronimo.connector.outbound;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
 import javax.resource.spi.ConnectionManager;
 import javax.transaction.TransactionManager;
 
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.KernelRegistry;
 import org.apache.geronimo.kernel.proxy.ProxyManager;
 
 /**
  * @version $Revision$
  */
-public class GenericConnectionManagerGBean extends GenericConnectionManager implements GBeanLifecycle
{
-    private final Kernel kernel;
+public class GenericConnectionManagerGBean extends GenericConnectionManager implements GBeanLifecycle,
Serializable, Externalizable {
+    private Kernel kernel;
+    private AbstractName abstractName;
+    //externalizable format version
+    private static final int VERSION = 1;
 
     public GenericConnectionManagerGBean() {
         super();
         kernel = null;
+        abstractName = null;
     }
 
     public GenericConnectionManagerGBean(TransactionSupport transactionSupport,
-                                         PoolingSupport pooling,
-                                         boolean containerManagedSecurity,
-                                         ConnectionTracker connectionTracker,
-                                         TransactionManager transactionManager,
-                                         String objectName,
-                                         ClassLoader classLoader,
-                                         Kernel kernel) {
+            PoolingSupport pooling,
+            boolean containerManagedSecurity,
+            ConnectionTracker connectionTracker,
+            TransactionManager transactionManager,
+            String objectName,
+            AbstractName abstractName,
+            ClassLoader classLoader,
+            Kernel kernel) {
         super(transactionSupport, pooling, containerManagedSecurity, connectionTracker, transactionManager,
objectName, classLoader);
         this.kernel = kernel;
+        this.abstractName = abstractName;
     }
 
     public ConnectionManager getConnectionManager() {
@@ -62,6 +79,36 @@
         }
     }
 
+    private Object readResolve() throws ObjectStreamException {
+        try {
+            return kernel.getGBean(abstractName);
+        } catch (GBeanNotFoundException e) {
+            throw (ObjectStreamException)new InvalidObjectException("Could not locate connection
manager gbean").initCause(e);
+        }
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(VERSION);
+        out.writeObject(kernel.getKernelName());
+        out.writeObject(abstractName);
+    }
+
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        int version = in.readInt();
+        if (version != VERSION) {
+            throw new IOException("Wrong version, expected " + VERSION + ", got: " + version);
+        }
+        String kernelName = (String) in.readObject();
+        kernel = KernelRegistry.getKernel(kernelName);
+        if (kernel == null) {
+            kernel = KernelRegistry.getSingleKernel();
+        }
+        if (kernel == null) {
+            throw new IOException("No kernel named: '" + kernelName + "' found");
+        }
+        abstractName = (AbstractName) in.readObject();
+    }
+
     public static final GBeanInfo GBEAN_INFO;
 
     static {
@@ -72,6 +119,7 @@
         infoBuilder.addAttribute("containerManagedSecurity", Boolean.TYPE, true);
 
         infoBuilder.addAttribute("objectName", String.class, false);
+        infoBuilder.addAttribute("abstractName", AbstractName.class, false);
         infoBuilder.addAttribute("classLoader", ClassLoader.class, false);
         infoBuilder.addAttribute("kernel", Kernel.class, false);
 
@@ -86,6 +134,7 @@
             "ConnectionTracker",
             "TransactionManager",
             "objectName",
+            "abstractName",
             "classLoader",
             "kernel"
         });

Modified: geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java?view=diff&rev=541105&r1=541104&r2=541105
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
(original)
+++ geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
Wed May 23 15:27:56 2007
@@ -22,7 +22,6 @@
 import java.util.Map;
 import java.util.LinkedHashSet;
 
-import javax.management.ObjectName;
 import javax.resource.ResourceException;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.resource.spi.ResourceAdapterAssociation;
@@ -174,14 +173,10 @@
         return resourceAdapterWrapper;
     }
 
-    public ConnectionManagerContainer getConnectionManagerFactory() {
+    public Object getConnectionManagerContainer() {
         return connectionManagerContainer;
     }
 
-    public Object getConnectionManager() {
-        return connectionManagerContainer.getConnectionManager();
-    }
-
     public void doStart() throws Exception {
         //register with resource adapter if not yet done
         if (!registered && (managedConnectionFactory instanceof ResourceAdapterAssociation))
{
@@ -255,11 +250,11 @@
     }
 
     public Object getConnectionFactory() throws ResourceException {
-        return $getResource();
+        return $getConnectionFactory();
     }
 
     public Object $getResource() throws ResourceException {
-        return connectionManagerContainer.createConnectionFactory(managedConnectionFactory);
+        return $getConnectionFactory();
     }
 
     public Object $getConnectionFactory() throws ResourceException {

Added: geronimo/server/trunk/modules/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBeanSerializationTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBeanSerializationTest.java?view=auto&rev=541105
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBeanSerializationTest.java
(added)
+++ geronimo/server/trunk/modules/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBeanSerializationTest.java
Wed May 23 15:27:56 2007
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.connector.outbound;
+
+import java.net.URI;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.basic.BasicKernel;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.SinglePool;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class GenericConnectionManagerGBeanSerializationTest extends TestCase {
+
+    public void testSerialization() throws Exception {
+        Kernel kernel = new BasicKernel("test");
+        kernel.boot();
+        AbstractName abstractName = new AbstractName(URI.create("foo/bar/1/car?name=ConnectionManager"));
+        GBeanData data = new GBeanData(abstractName, GenericConnectionManagerGBean.GBEAN_INFO);
+        data.setAttribute("transactionSupport", NoTransactions.INSTANCE);
+        data.setAttribute("pooling", new SinglePool(10, 0, 5000, 5, false, false, true));
+        kernel.loadGBean(data, this.getClass().getClassLoader());
+        kernel.startGBean(abstractName);
+        Object cm = kernel.getGBean(abstractName);
+        assertTrue(cm instanceof GenericConnectionManagerGBean);
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream out = new ObjectOutputStream(baos);
+        out.writeObject(cm);
+        out.flush();
+        byte[] bytes = baos.toByteArray();
+        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+        ObjectInputStream in = new ObjectInputStream(bais);
+        Object cm2 = in.readObject();
+        assertSame(cm, cm2);
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBeanSerializationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBeanSerializationTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/GenericConnectionManagerGBeanSerializationTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java?view=diff&rev=541105&r1=541104&r2=541105
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java
(original)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java
Wed May 23 15:27:56 2007
@@ -50,7 +50,7 @@
      * javax.resource.spi.ConnectionManager and
      * org.apache.geronimo.connector.outbound.PoolingAttributes
      */
-    public Object getConnectionManager();
+    public Object getConnectionManagerContainer();
     
     public Object getConnectionFactory() throws Exception;
 }



Mime
View raw message