[jboss-cvs] JBossAS SVN: r101850 - in projects/jboss-jca/trunk: common/src/main/java/org/jboss/jca/common/util and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 4 10:43:08 EST 2010


Author: smarlow at redhat.com
Date: 2010-03-04 10:43:07 -0500 (Thu, 04 Mar 2010)
New Revision: 101850

Added:
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/ConnectionFactoryJndiNameBuilder.java
   projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ContainerConnectionFactoryJndiNameBuilder.java
Modified:
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
Log:
JBJCA-296 add connection factory jndi name builder

Added: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/ConnectionFactoryJndiNameBuilder.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/ConnectionFactoryJndiNameBuilder.java	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/api/ConnectionFactoryJndiNameBuilder.java	2010-03-04 15:43:07 UTC (rev 101850)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.common.api;
+
+/**
+ * Used for building JNDI bind names.
+ *
+ * @author <a href="mailto:smarlow at redhat.com">Scott Marlow</a>
+ */
+public interface ConnectionFactoryJndiNameBuilder
+{
+
+   /**
+    * Returns the JNDI name.
+    * @return JNDI name
+    */
+   String build();
+
+   /**
+    * specify the deployment name.
+    * @param name of the deployment
+    * @return this for convenience
+    */
+   ConnectionFactoryJndiNameBuilder setDeploymentName(String name);
+
+   /**
+    * Specify the ConnectionFactory.
+    * @param className is the connection factory class name
+    * @return this for convenience
+    */
+   ConnectionFactoryJndiNameBuilder setConnectionFactory(String className);
+
+}

Added: projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ContainerConnectionFactoryJndiNameBuilder.java
===================================================================
--- projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ContainerConnectionFactoryJndiNameBuilder.java	                        (rev 0)
+++ projects/jboss-jca/trunk/common/src/main/java/org/jboss/jca/common/util/ContainerConnectionFactoryJndiNameBuilder.java	2010-03-04 15:43:07 UTC (rev 101850)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.common.util;
+
+import org.jboss.jca.common.api.ConnectionFactoryJndiNameBuilder;
+
+/**
+ * Used for building JNDI bind names.
+ *
+ * @author <a href="mailto:smarlow at redhat.com">Scott Marlow</a>
+ */
+public class ContainerConnectionFactoryJndiNameBuilder implements ConnectionFactoryJndiNameBuilder
+{
+   String deploymentName;
+
+   /** JNDI prefix */
+   private static final String JNDI_PREFIX = "java:/eis/";
+
+   /**
+    * {@inheritDoc}
+    */
+   public String build()
+   {
+      return JNDI_PREFIX + deploymentName;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public ConnectionFactoryJndiNameBuilder setDeploymentName(String deploymentName)
+   {
+      if (deploymentName == null || deploymentName.trim().equals(""))
+         throw new IllegalArgumentException("deploymentFile is null");
+      this.deploymentName =  deploymentName;
+      return this;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   public ConnectionFactoryJndiNameBuilder setConnectionFactory(String className)
+   {
+      return this;
+   }
+
+}

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java	2010-03-04 15:42:52 UTC (rev 101849)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java	2010-03-04 15:43:07 UTC (rev 101850)
@@ -25,6 +25,8 @@
 import org.jboss.jca.common.Annotations;
 import org.jboss.jca.common.Metadata;
 import org.jboss.jca.common.api.ConnectionFactoryBuilder;
+import org.jboss.jca.common.api.ConnectionFactoryJndiNameBuilder;
+import org.jboss.jca.common.util.ContainerConnectionFactoryJndiNameBuilder;
 import org.jboss.jca.common.util.LocalConnectionFactoryBuilder;
 import org.jboss.jca.core.api.CloneableBootstrapContext;
 import org.jboss.jca.core.connectionmanager.notx.NoTxConnectionManager;
@@ -102,9 +104,6 @@
 
    private static boolean trace = log.isTraceEnabled();
 
-   /** JNDI prefix */
-   private static final String JNDI_PREFIX = "java:/eis/";
-   
    /** Preform bean validation */
    private static AtomicBoolean beanValidation = new AtomicBoolean(true);
 
@@ -426,10 +425,14 @@
                               if (jndiNames == null)
                                  jndiNames = new ArrayList<String>(1);
 
-                              String jndiName = f.getName().substring(0, f.getName().indexOf(".rar"));
+                              ConnectionFactoryJndiNameBuilder jndiNameBuilder = getJndiNameBuilder();
+                              String deploymentName =  f.getName().substring(0,  f.getName().indexOf(".rar"));
+                              jndiNameBuilder.setConnectionFactory(cf.getClass().getName());
+                              jndiNameBuilder.setDeploymentName(deploymentName);
+                              String jndiName = jndiNameBuilder.build();
 
                               bindConnectionFactory(jndiName, (Serializable)cf, mcf);
-                              jndiNames.add(JNDI_PREFIX + jndiName);
+                              jndiNames.add(jndiName);
                            }
                            else
                            {
@@ -713,6 +716,12 @@
       return new LocalConnectionFactoryBuilder();
    }
 
+   private ConnectionFactoryJndiNameBuilder getJndiNameBuilder()
+   {
+      return new ContainerConnectionFactoryJndiNameBuilder();
+   }
+
+
    /**
     * Start the resource adapter
     * @param resourceAdapter The resource adapter
@@ -867,7 +876,7 @@
          Referenceable referenceable = (Referenceable)cf;
          referenceable.setReference(cfb.build());
 
-         Util.bind(context, JNDI_PREFIX + name, cf);
+         Util.bind(context, name, cf);
 
       }
       finally




More information about the jboss-cvs-commits mailing list