[jboss-cvs] JBossAS SVN: r109979 - in trunk: connector/src/main/java/org/jboss/resource/deployers and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Dec 17 03:33:43 EST 2010


Author: jaikiran
Date: 2010-12-17 03:33:42 -0500 (Fri, 17 Dec 2010)
New Revision: 109979

Added:
   trunk/connector/src/main/java/org/jboss/resource/deployers/DataSourceReferenceResourceProvider.java
Modified:
   trunk/component-matrix/pom.xml
   trunk/connector/src/main/java/org/jboss/resource/deployers/DataSourceDeployerHelper.java
   trunk/connector/src/resources/deployers/jca-deployers-jboss-beans.xml
   trunk/server/src/etc/deployers/switchboard-jboss-beans.xml
Log:
JBAS-8548 Add switchboard support for processing <data-source>/@DataSourceDefinition references

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2010-12-17 05:34:56 UTC (rev 109978)
+++ trunk/component-matrix/pom.xml	2010-12-17 08:33:42 UTC (rev 109979)
@@ -135,7 +135,7 @@
     <version.org.jboss.shrinkwrap>1.0.0-alpha-11</version.org.jboss.shrinkwrap>
     <version.org.jboss.slf4j>1.0.2.GA</version.org.jboss.slf4j>
     <version.org.jboss.stdio>1.0.0.CR3</version.org.jboss.stdio>
-    <version.org.jboss.switchboard.depchain>1.0.0-alpha-14</version.org.jboss.switchboard.depchain>
+    <version.org.jboss.switchboard.depchain>1.0.0-alpha-15</version.org.jboss.switchboard.depchain>
     <version.org.jboss.threads>2.0.0.CR7</version.org.jboss.threads>
     <version.org.jboss.threads-metadata>2.0.0.CR4</version.org.jboss.threads-metadata>
     <version.org.jboss.vfs>3.0.0.CR5</version.org.jboss.vfs>

Modified: trunk/connector/src/main/java/org/jboss/resource/deployers/DataSourceDeployerHelper.java
===================================================================
--- trunk/connector/src/main/java/org/jboss/resource/deployers/DataSourceDeployerHelper.java	2010-12-17 05:34:56 UTC (rev 109978)
+++ trunk/connector/src/main/java/org/jboss/resource/deployers/DataSourceDeployerHelper.java	2010-12-17 08:33:42 UTC (rev 109979)
@@ -54,30 +54,35 @@
 	
 	public static String normalizeJndiName(DataSourceMetaData dsmd, DeploymentUnit unit, JavaEEComponentInformer informer)
 	{
-		String jndiName = normalizeJndiName(dsmd.getName());
-		StringBuffer results = new StringBuffer();
-		String dsName = null;
-		
-		if(jndiName.indexOf("/") != -1 && scopes.contains(jndiName.substring(0, jndiName.indexOf("/"))))
-		{						
-			dsName = jndiName.substring(jndiName.indexOf("/") + 1, jndiName.length());
-			
-			results.append("internal/" + informer.getApplicationName(unit) + "/" + informer.getModuleName(unit) + "/");
-			
-			if(informer.isJavaEEComponent(unit))
-			{
-				results.append(informer.getComponentName(unit) + "/");
-			}
-						
-			return results.append(dsName).toString();
-		
-		}
-		
-		
-		return jndiName;
+		return normalizeJndiName(dsmd.getName(), unit, informer);
 	}
 	
+	public static String normalizeJndiName(String dsJndiName, DeploymentUnit unit, JavaEEComponentInformer informer)
+    {
+        String jndiName = normalizeJndiName(dsJndiName);
+        StringBuffer results = new StringBuffer();
+        String dsName = null;
+        
+        if(jndiName.indexOf("/") != -1 && scopes.contains(jndiName.substring(0, jndiName.indexOf("/"))))
+        {                       
+            dsName = jndiName.substring(jndiName.indexOf("/") + 1, jndiName.length());
+            
+            results.append("internal/" + informer.getApplicationName(unit) + "/" + informer.getModuleName(unit) + "/");
+            
+            if(informer.isJavaEEComponent(unit))
+            {
+                results.append(informer.getComponentName(unit) + "/");
+            }
+                        
+            return results.append(dsName).toString();
+        
+        }
+        
+        
+        return jndiName;
+    }
 	
+	
 	public static DataSourceDeploymentMetaData createTxnDeployment(final DataSourceMetaData dsmd)
 	{
 		XADataSourceDeploymentMetaData depMd = new XADataSourceDeploymentMetaData();

Added: trunk/connector/src/main/java/org/jboss/resource/deployers/DataSourceReferenceResourceProvider.java
===================================================================
--- trunk/connector/src/main/java/org/jboss/resource/deployers/DataSourceReferenceResourceProvider.java	                        (rev 0)
+++ trunk/connector/src/main/java/org/jboss/resource/deployers/DataSourceReferenceResourceProvider.java	2010-12-17 08:33:42 UTC (rev 109979)
@@ -0,0 +1,152 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.resource.deployers;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import javax.naming.LinkRef;
+
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.reloaded.naming.deployers.javaee.JavaEEComponentInformer;
+import org.jboss.switchboard.javaee.environment.DataSourceType;
+import org.jboss.switchboard.mc.spi.MCBasedResourceProvider;
+import org.jboss.switchboard.spi.Resource;
+
+/**
+ * {@link MCBasedResourceProvider Resource provider} for processing &lt;data-source&gt;/@DataSourceDefinition
+ * references in a Java EE component
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class DataSourceReferenceResourceProvider implements MCBasedResourceProvider<DataSourceType>
+{
+
+   /**
+    * JavaEE component informer
+    */
+   private JavaEEComponentInformer informer;
+
+   @Inject
+   public void setJavaEEComponentInformer(JavaEEComponentInformer informer)
+   {
+      this.informer = informer;
+   }
+   
+   @Override
+   public Class<DataSourceType> getEnvironmentEntryType()
+   {
+      return DataSourceType.class;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public Resource provide(DeploymentUnit unit, DataSourceType dataSource)
+   {
+      // get the jndi name of the datasource. 
+      String dsJndiName = dataSource.getName();
+      // convert it to internal JBoss specific jndi name
+      // Note that the normalize method return a jndi name without an prefix but the DSDeployer binds to
+      // java: prefix by default. So we prefix the java: to this returned normalized jndi name
+      String internalJndiNameWithoutNamespace = DataSourceDeployerHelper.normalizeJndiName(dsJndiName, unit.isComponent() ? unit.getParent() : unit, informer);
+      String targetJndiName = "java:/" + internalJndiNameWithoutNamespace;
+      
+      // the binder which binds to the internal JBoss specific jndi name
+      String binderName = "jboss.jca:name=" + internalJndiNameWithoutNamespace + ",service=DataSourceBinding";
+      
+      // create and return the resource
+      return new DataSourceResource(targetJndiName, binderName);
+   }
+   
+   /**
+    * {@link Resource} for a data-source/@DataSourceDefinition reference
+    *
+    * @author Jaikiran Pai
+    * @version $Revision: $
+    */
+   private class DataSourceResource implements Resource
+   {
+
+      /**
+       * The LinkRef to internal JBoss specific jndi name of the datasource
+       */
+      private LinkRef target;
+      
+      /**
+       * The JBoss internal datasource binder which binds the datasource to an internal
+       * jndi name 
+       */
+      private String dataSourceBinderName;
+      
+      /**
+       * 
+       * @param internalJndiName JBoss specific internal jndi name for the datasource
+       * @param datasourceBinderName The binder which binds the datasource to the JBoss specific internal jndi name
+       */
+      DataSourceResource(String internalJndiName, String datasourceBinderName)
+      {
+         this.target = new LinkRef(internalJndiName);
+         this.dataSourceBinderName = datasourceBinderName;
+      }
+      
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public Object getDependency()
+      {
+         // a LinkRef doesn't need to depend on anything *during bind time*
+         return null;
+      }
+
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public Collection<?> getInvocationDependencies()
+      {
+         if (this.dataSourceBinderName == null || this.dataSourceBinderName.trim().isEmpty())
+         {
+            return null;
+         }
+         // this DataSourceResource, for lookup/invocation, depends on the binder which binds the datasource to internal
+         // JNDI name
+         return Collections.singleton(this.dataSourceBinderName);
+      }
+
+      /**
+       * {@inheritDoc}
+       */
+      @Override
+      public Object getTarget()
+      {
+         // return the LinkRef to internal JBoss specific jndi name of the datasource
+         return this.target;
+      }
+      
+   }
+
+}

Modified: trunk/connector/src/resources/deployers/jca-deployers-jboss-beans.xml
===================================================================
--- trunk/connector/src/resources/deployers/jca-deployers-jboss-beans.xml	2010-12-17 05:34:56 UTC (rev 109978)
+++ trunk/connector/src/resources/deployers/jca-deployers-jboss-beans.xml	2010-12-17 08:33:42 UTC (rev 109979)
@@ -185,9 +185,10 @@
 	
 	<!--  Deployer responsible for managing EE5.17 data source definitions -->
    <bean name="DataSourceDeployer" class="org.jboss.resource.deployers.DataSourceDeployer">      
-   		<property name="EJBSupported">false</property>
    		<property name="CARSupported">false</property>   		
    </bean>	
-	
-	
+
+    <!--  ResourceProvider for @DataSourceDefinition/<data-source> (Java EE 6 Spec, section EE.5.17) -->
+    <bean name="org.jboss.switchboard.DataSourceReferenceResourceProvider" class="org.jboss.resource.deployers.DataSourceReferenceResourceProvider"/>
+    
 </deployment>

Modified: trunk/server/src/etc/deployers/switchboard-jboss-beans.xml
===================================================================
--- trunk/server/src/etc/deployers/switchboard-jboss-beans.xml	2010-12-17 05:34:56 UTC (rev 109978)
+++ trunk/server/src/etc/deployers/switchboard-jboss-beans.xml	2010-12-17 08:33:42 UTC (rev 109979)
@@ -103,7 +103,7 @@
                             </constructor>    
                         </bean>
                     </value>
-                </entry>                    
+                </entry>
             </map>           
         </property>
         <property name="fallbackResourceRefResourceProviders">
@@ -150,7 +150,7 @@
                 <inject bean="org.jboss.switchboard.EJBLocalRefResourceProvider"/>
                 <inject bean="org.jboss.switchboard.EJBRefResourceProvider"/>
                 <inject bean="org.jboss.switchboard.AnnotatedEJBRefResourceProvider"/>
-
+                <inject bean="org.jboss.switchboard.DataSourceReferenceResourceProvider"/>
                 <inject bean="org.jboss.switchboard.BeanManagerResourceProvider"/>
                 <inject bean="org.jboss.switchboard.ORBRefResourceProvider"/>                
                 <inject bean="org.jboss.switchboard.UserTransactionRefResourceProvider"/>



More information about the jboss-cvs-commits mailing list