geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 56169 - in geronimo/trunk/modules: connector/src/java/org/apache/geronimo/connector/deployment naming/src/java/org/apache/geronimo/naming/jmx naming/src/java/org/apache/geronimo/naming/reference
Date Mon, 01 Nov 2004 00:05:29 GMT
Author: djencks
Date: Sun Oct 31 16:05:29 2004
New Revision: 56169

Added:
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/GBeanGetResourceRefAddr.java
      - copied, changed from rev 56121, geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXRefAddr.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/GBeanRefAddr.java
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/RefAddrContentObjectFactory.java
      - copied, changed from rev 56121, geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXObjectFactory.java
Removed:
   geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/
Modified:
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Log:
improve names and introduce a helper interface

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
Sun Oct 31 16:05:29 2004
@@ -66,8 +66,8 @@
 import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContext;
 import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.J2eeContextImpl;
 import org.apache.geronimo.j2ee.deployment.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.naming.jmx.JMXObjectFactory;
-import org.apache.geronimo.naming.jmx.JMXRefAddr;
+import org.apache.geronimo.naming.reference.RefAddrContentObjectFactory;
+import org.apache.geronimo.naming.reference.GBeanGetResourceRefAddr;
 import org.apache.geronimo.schema.SchemaConversionUtils;
 import org.apache.geronimo.xbeans.geronimo.GerAdminobjectInstanceType;
 import org.apache.geronimo.xbeans.geronimo.GerAdminobjectType;
@@ -659,9 +659,12 @@
             throw new DeploymentException("Unexpected transaction support element");
         }
         PoolingSupport pooling = null;
+        //TODO configure this
+//        int idleTimeoutMinutes = 15;
         if (connectionManager.getSinglePool() != null) {
             pooling = new SinglePool(connectionManager.getSinglePool().getMaxSize(),
                     connectionManager.getSinglePool().getBlockingTimeoutMilliseconds(),
+//                    idleTimeoutMinutes,
                     connectionManager.getSinglePool().getMatchOne() != null,
                     connectionManager.getSinglePool().getMatchAll() != null,
                     connectionManager.getSinglePool().getSelectOneAssumeMatch() != null);
@@ -670,6 +673,7 @@
                     connectionManager.getPartitionedPool().getPartitionBySubject() != null,
                     connectionManager.getPartitionedPool().getMaxSize(),
                     connectionManager.getPartitionedPool().getBlockingTimeoutMilliseconds(),
+//                    idleTimeoutMinutes,
                     connectionManager.getPartitionedPool().getMatchOne() != null,
                     connectionManager.getPartitionedPool().getMatchAll() != null,
                     connectionManager.getPartitionedPool().getSelectOneAssumeMatch() != null);
@@ -770,14 +774,14 @@
 
     //ResourceReferenceBuilder implementation
     public Reference createResourceRef(String containerId, Class iface) throws DeploymentException
{
-        Reference ref = new Reference(null, JMXObjectFactory.class.getName(), null);
-        ref.add(new JMXRefAddr(null, containerId, iface));
+        Reference ref = new Reference(null, RefAddrContentObjectFactory.class.getName(),
null);
+        ref.add(new GBeanGetResourceRefAddr(null, containerId, iface));
         return ref;
     }
 
     public Reference createAdminObjectRef(String containerId, Class iface) throws DeploymentException
{
-        Reference ref = new Reference(null, JMXObjectFactory.class.getName(), null);
-        ref.add(new JMXRefAddr(null, containerId, iface));
+        Reference ref = new Reference(null, RefAddrContentObjectFactory.class.getName(),
null);
+        ref.add(new GBeanGetResourceRefAddr(null, containerId, iface));
         return ref;
     }
 

Copied: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/GBeanGetResourceRefAddr.java
(from rev 56121, geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXRefAddr.java)
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXRefAddr.java
(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/GBeanGetResourceRefAddr.java
Sun Oct 31 16:05:29 2004
@@ -15,28 +15,29 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.naming.jmx;
+package org.apache.geronimo.naming.reference;
 
-import java.net.URI;
-import java.net.URISyntaxException;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
 import javax.naming.RefAddr;
 
+import org.apache.geronimo.kernel.Kernel;
+
 /**
  *
  *
  * @version $Rev$ $Date$
  *
  * */
-public class JMXRefAddr extends RefAddr {
+public class GBeanGetResourceRefAddr extends RefAddr implements GBeanRefAddr {
 
     private final static String TYPE = "org.apache.geronimo.naming.jmx.RefType";
 
     private final String kernelName;
     private final String containerId;
-    private final static String SCHEME = "geronimo";
     private final Class iface;
 
-    public JMXRefAddr(String kernelName, String containerId, Class iface) {
+    public GBeanGetResourceRefAddr(String kernelName, String containerId, Class iface) {
         super(TYPE);
         this.kernelName = kernelName;
         this.containerId = containerId;
@@ -57,10 +58,33 @@
     }
 
     public Object getContent() {
+        Kernel kernel;
+        if (getKernelName() == null) {
+            kernel = Kernel.getSingleKernel();
+        } else {
+            kernel = Kernel.getKernel(getKernelName());
+        }
+
+        ObjectName target = null;
         try {
-            return new URI(SCHEME, kernelName, containerId, null);
-        } catch (URISyntaxException e) {
-            throw (IllegalStateException)new IllegalStateException("invalid jmx ref addr").initCause(e);
+            target = ObjectName.getInstance(getContainerId());
+        } catch (MalformedObjectNameException e) {
+            throw (IllegalArgumentException) new IllegalArgumentException("Invalid object
name in jmxRefAddr: " + getContainerId()).initCause(e);
         }
+
+        Object proxy = null;
+        try {
+            proxy = kernel.invoke(target, "$getResource");
+        } catch (Exception e) {
+            throw (IllegalStateException)new IllegalStateException("Could not get proxy").initCause(e);
+        }
+        if (proxy == null) {
+            throw new IllegalStateException("Proxy not returned. Target " + getContainerId()
+ " not started");
+        }
+        if (!getInterface().isAssignableFrom(proxy.getClass())) {
+            throw new ClassCastException("Proxy does not implement expected interface " +
getInterface());
+        }
+        return proxy;
+
     }
 }

Added: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/GBeanRefAddr.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/GBeanRefAddr.java
Sun Oct 31 16:05:29 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.naming.reference;
+
+/**
+ * @version $Rev:  $ $Date:  $
+ */
+public interface GBeanRefAddr {
+
+    String getContainerId();
+
+    String getKernelName();
+    
+}

Copied: geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/RefAddrContentObjectFactory.java
(from rev 56121, geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXObjectFactory.java)
==============================================================================
--- geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/jmx/JMXObjectFactory.java
(original)
+++ geronimo/trunk/modules/naming/src/java/org/apache/geronimo/naming/reference/RefAddrContentObjectFactory.java
Sun Oct 31 16:05:29 2004
@@ -15,56 +15,26 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.naming.jmx;
+package org.apache.geronimo.naming.reference;
 
 import java.util.Hashtable;
-
 import javax.naming.Context;
 import javax.naming.Name;
 import javax.naming.RefAddr;
 import javax.naming.Reference;
 import javax.naming.spi.ObjectFactory;
-import javax.management.ObjectName;
-import javax.management.MalformedObjectNameException;
-
-import org.apache.geronimo.kernel.Kernel;
 
 /**
  * @version $Rev$ $Date$
  */
-public class JMXObjectFactory implements ObjectFactory {
+public class RefAddrContentObjectFactory implements ObjectFactory {
 
     public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                                     Hashtable environment) throws Exception {
         if (obj instanceof Reference) {
             Reference ref = (Reference) obj;
             RefAddr refAddr = ref.get(0);
-            if (!(refAddr instanceof JMXRefAddr)) {
-                throw new IllegalStateException("Invalid ref addr in a Connectionfactory
ref: " + refAddr);
-            }
-            JMXRefAddr jmxRefAddr = (JMXRefAddr) refAddr;
-            Kernel kernel;
-            if (jmxRefAddr.getKernelName() == null) {
-                kernel = Kernel.getSingleKernel();
-            } else {
-                kernel = Kernel.getKernel(jmxRefAddr.getKernelName());
-            }
-
-            ObjectName target = null;
-            try {
-                target = ObjectName.getInstance(jmxRefAddr.getContainerId());
-            } catch (MalformedObjectNameException e) {
-                throw (IllegalArgumentException) new IllegalArgumentException("Invalid object
name in jmxRefAddr: " + jmxRefAddr.getContainerId()).initCause(e);
-            }
-            
-            Object proxy = kernel.invoke(target, "$getResource");
-            if (proxy == null) {
-                throw new IllegalStateException("Proxy not returned. Target " + jmxRefAddr.getContainerId()
+ " not started");
-            }
-            if (!jmxRefAddr.getInterface().isAssignableFrom(proxy.getClass())) {
-                throw new ClassCastException("Proxy does not implement expected interface
" + jmxRefAddr.getInterface());
-            }
-            return proxy;
+            return refAddr.getContent();
         }
         return null;
     }

Mime
View raw message