[jboss-cvs] JBossAS SVN: r109095 - in branches/switchboard-integration: ejb3/src/main/java/org/jboss/as/ejb3 and 8 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 3 13:47:46 EDT 2010


Author: jaikiran
Date: 2010-11-03 13:47:45 -0400 (Wed, 03 Nov 2010)
New Revision: 109095

Added:
   branches/switchboard-integration/ejb3/src/main/java/org/jboss/as/ejb3/switchboard/
   branches/switchboard-integration/ejb3/src/main/java/org/jboss/as/ejb3/switchboard/resource/
   branches/switchboard-integration/ejb3/src/main/java/org/jboss/as/ejb3/switchboard/resource/provider/
   branches/switchboard-integration/ejb3/src/main/java/org/jboss/as/ejb3/switchboard/resource/provider/MessageDestinationReferenceResourceProvider.java
   branches/switchboard-integration/testsuite/src/resources/web/META-INF/hornetq-jms.xml
Modified:
   branches/switchboard-integration/component-matrix/pom.xml
   branches/switchboard-integration/ejb3/src/resources/META-INF/ejb3-as-deployers-jboss-beans.xml
   branches/switchboard-integration/server/src/etc/deployers/switchboard-clustered-jboss-beans.xml
   branches/switchboard-integration/server/src/etc/deployers/switchboard-jboss-beans.xml
   branches/switchboard-integration/testsuite/imports/sections/web.xml
   branches/switchboard-integration/tomcat/src/main/java/org/jboss/web/tomcat/service/injection/WebResourceHandler.java
Log:
JBAS-8603 JBAS-8548 Implemented message-destination-ref resource provider

Modified: branches/switchboard-integration/component-matrix/pom.xml
===================================================================
--- branches/switchboard-integration/component-matrix/pom.xml	2010-11-03 16:50:36 UTC (rev 109094)
+++ branches/switchboard-integration/component-matrix/pom.xml	2010-11-03 17:47:45 UTC (rev 109095)
@@ -132,7 +132,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-4</version.org.jboss.switchboard.depchain>
+    <version.org.jboss.switchboard.depchain>1.0.0-alpha-5</version.org.jboss.switchboard.depchain>
     <version.org.jboss.threads>2.0.0.CR4</version.org.jboss.threads>
     <version.org.jboss.vfs>3.0.0.CR5</version.org.jboss.vfs>
     <version.org.jboss.weld>1.1.0.Beta1</version.org.jboss.weld>

Added: branches/switchboard-integration/ejb3/src/main/java/org/jboss/as/ejb3/switchboard/resource/provider/MessageDestinationReferenceResourceProvider.java
===================================================================
--- branches/switchboard-integration/ejb3/src/main/java/org/jboss/as/ejb3/switchboard/resource/provider/MessageDestinationReferenceResourceProvider.java	                        (rev 0)
+++ branches/switchboard-integration/ejb3/src/main/java/org/jboss/as/ejb3/switchboard/resource/provider/MessageDestinationReferenceResourceProvider.java	2010-11-03 17:47:45 UTC (rev 109095)
@@ -0,0 +1,111 @@
+/**
+ * 
+ */
+package org.jboss.as.ejb3.switchboard.resource.provider;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.resolvers.MessageDestinationReferenceResolver;
+import org.jboss.logging.Logger;
+import org.jboss.switchboard.impl.resource.LinkRefResource;
+import org.jboss.switchboard.javaee.jboss.environment.JBossMessageDestinationRefType;
+import org.jboss.switchboard.mc.spi.MCBasedResourceProvider;
+import org.jboss.switchboard.spi.Resource;
+
+/**
+ * A {@link MCBasedResourceProvider} for processing message-destination-ref
+ * references
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class MessageDestinationReferenceResourceProvider implements MCBasedResourceProvider<JBossMessageDestinationRefType>
+{
+
+   /**
+    * Logger
+    */
+   private static Logger logger = Logger.getLogger(MessageDestinationReferenceResourceProvider.class);
+   
+   /**
+    * A {@link MessageDestinationReferenceResolver} will be used to resolve a jndi-name out of 
+    * the message-destination link, used in message-destination-ref 
+    */
+   private MessageDestinationReferenceResolver messageDestinationResolver;
+   
+   /**
+    * {@inheritDoc}
+    */
+   public Class<JBossMessageDestinationRefType> getEnvironmentEntryType()
+   {
+      return JBossMessageDestinationRefType.class;
+   }
+
+   /**
+    * Processes a message-destination-ref and returns a {@link Resource} corresponding to that
+    * reference.
+    * If a {@link Resource} cannot be created out of the message-destination-ref, then this
+    * method throws a {@link RuntimeException}
+    */
+   public Resource provide(DeploymentUnit unit, JBossMessageDestinationRefType messageDestRef)
+   {
+      // first check lookup name
+      String lookupName = messageDestRef.getLookupName();
+      if (lookupName != null && !lookupName.trim().isEmpty())
+      {
+         return new LinkRefResource(lookupName);
+      }
+
+      // now check mapped name
+      String mappedName = messageDestRef.getMappedName();
+      if (mappedName != null && !mappedName.trim().isEmpty())
+      {
+         return new LinkRefResource(mappedName);
+      }
+      
+      // now check (JBoss specific) jndi name!
+      String jndiName = messageDestRef.getJNDIName();
+      if (jndiName != null && !jndiName.trim().isEmpty())
+      {
+         return new LinkRefResource(jndiName);
+      }
+      
+      // Now check if a message-destination link is specified.
+      // The "link" itself is a logical name to the destination, so we'll
+      // use a resolver to resolve a jndi name out of it.
+      // Note that a message-destination can *only* be specified in a ejb-jar deployment
+      // (see Java EE6 spec, EE.5.9.2), so the message-destination link resolver 
+      // needs to be provided by some JBoss EJB3 container component
+      String messageDestLink = messageDestRef.getMessageDestinationLink();
+      if (messageDestLink != null && !messageDestLink.trim().isEmpty())
+      {
+         if (this.messageDestinationResolver == null)
+         {
+            logger.warn("Cannot resolve message-destination link: " + messageDestLink
+                  + " for message-destination-ref: " + messageDestRef.getName() + " due to absence of a "
+                  + MessageDestinationReferenceResolver.class.getName());
+         }
+         else
+         {
+            String resolvedJNDIName = this.messageDestinationResolver.resolveMessageDestinationJndiName(unit, messageDestLink);
+            logger.debug("Resolved jndi-name: " + resolvedJNDIName + " for message-destination link: "
+                  + messageDestLink + " in message-destination-ref: " + messageDestRef.getName());
+            if (resolvedJNDIName != null && !resolvedJNDIName.trim().isEmpty())
+            {
+               return new LinkRefResource(resolvedJNDIName);
+            }
+            
+         }
+      }
+      throw new RuntimeException("Cannot provide a resource for message-destination-ref: " + messageDestRef.getName() + " in unit: " + unit);
+   }
+
+   /**
+    * Sets the {@link MessageDestinationReferenceResolver}, which will be used to resolve the jndi-name
+    * out of a message-destination link, used in the message-destination-ref
+    * @param resolver
+    */
+   public void setMessageDestinationLinkResolver(MessageDestinationReferenceResolver resolver)
+   {
+      this.messageDestinationResolver = resolver;
+   }
+}

Modified: branches/switchboard-integration/ejb3/src/resources/META-INF/ejb3-as-deployers-jboss-beans.xml
===================================================================
--- branches/switchboard-integration/ejb3/src/resources/META-INF/ejb3-as-deployers-jboss-beans.xml	2010-11-03 16:50:36 UTC (rev 109094)
+++ branches/switchboard-integration/ejb3/src/resources/META-INF/ejb3-as-deployers-jboss-beans.xml	2010-11-03 17:47:45 UTC (rev 109095)
@@ -310,6 +310,11 @@
         TODO: Remove this once the dependents move to the new ejbref-resolver SPI  -->
     <bean name="org.jboss.ejb3.EjbReferenceResolver" class="org.jboss.ejb3.core.resolvers.ScopedEJBReferenceResolver"/>
   
+    <!--  ResourceProvider for message-destination-ref  (EE.5.9 of Java EE6 spec) -->
+    <bean name="org.jboss.switchboard.MessageDestinationRefResourceProvider" class="org.jboss.as.ejb3.switchboard.resource.provider.MessageDestinationReferenceResourceProvider">
+        <property name="messageDestinationLinkResolver"><inject/></property>
+    </bean>  
+    
    
 
 </deployment>

Modified: branches/switchboard-integration/server/src/etc/deployers/switchboard-clustered-jboss-beans.xml
===================================================================
--- branches/switchboard-integration/server/src/etc/deployers/switchboard-clustered-jboss-beans.xml	2010-11-03 16:50:36 UTC (rev 109094)
+++ branches/switchboard-integration/server/src/etc/deployers/switchboard-clustered-jboss-beans.xml	2010-11-03 17:47:45 UTC (rev 109095)
@@ -36,10 +36,10 @@
     <!--  ResourceProvider for java:comp/UserTransaction (EE.5.10 of Java EE 6 spec) -->
     <bean name="org.jboss.switchboard.UserTransactionRefResourceProvider" class="org.jboss.as.switchboard.resource.provider.UserTransactionRefResourceProvider"/>
     
+    <!--  ResourceProvider for java:comp/TransactionSynchronizationRegistry (EE.5.11 of Java EE 6 spec) -->
     <bean name="org.jboss.switchboard.TransactionSyncRegistryRefResourceProvider" class="org.jboss.as.switchboard.resource.provider.TransactionSynchronizationRefResourceProvider"/>
 
     
-    
     <!-- Resource provider registry -->
     <bean name="org.jboss.switchboard.ResourceProviderRegistry" class="org.jboss.switchboard.mc.resource.provider.ResourceProviderRegistry">
         <property name="resourceProviders">
@@ -47,6 +47,7 @@
                 <inject bean="org.jboss.switchboard.EnvEntryResourceProvider"/>
                 <inject bean="org.jboss.switchboard.ResourceEnvRefResourceProvider"/>
                 <inject bean="org.jboss.switchboard.ResourceRefResourceProvider"/>
+                <inject bean="org.jboss.switchboard.MessageDestinationRefResourceProvider"/>
                 <!-- Disabled till container themselves stop binding into java:comp 
                     <inject bean="org.jboss.switchboard.ORBRefResourceProvider"/>
                     <inject bean="org.jboss.switchboard.UserTransactionRefResourceProvider"/>

Modified: branches/switchboard-integration/server/src/etc/deployers/switchboard-jboss-beans.xml
===================================================================
--- branches/switchboard-integration/server/src/etc/deployers/switchboard-jboss-beans.xml	2010-11-03 16:50:36 UTC (rev 109094)
+++ branches/switchboard-integration/server/src/etc/deployers/switchboard-jboss-beans.xml	2010-11-03 17:47:45 UTC (rev 109095)
@@ -33,10 +33,9 @@
     <!--  ResourceProvider for java:comp/UserTransaction (EE.5.10 of Java EE 6 spec) -->
     <bean name="org.jboss.switchboard.UserTransactionRefResourceProvider" class="org.jboss.as.switchboard.resource.provider.UserTransactionRefResourceProvider"/>
     
+    <!--  ResourceProvider for java:comp/TransactionSynchronizationRegistry (EE.5.11 of Java EE 6 spec) -->
     <bean name="org.jboss.switchboard.TransactionSyncRegistryRefResourceProvider" class="org.jboss.as.switchboard.resource.provider.TransactionSynchronizationRefResourceProvider"/>
 
-    
-    
     <!-- Resource provider registry -->
     <bean name="org.jboss.switchboard.ResourceProviderRegistry" class="org.jboss.switchboard.mc.resource.provider.ResourceProviderRegistry">
         <property name="resourceProviders">
@@ -44,6 +43,7 @@
                 <inject bean="org.jboss.switchboard.EnvEntryResourceProvider"/>
                 <inject bean="org.jboss.switchboard.ResourceEnvRefResourceProvider"/>
                 <inject bean="org.jboss.switchboard.ResourceRefResourceProvider"/>
+                <inject bean="org.jboss.switchboard.MessageDestinationRefResourceProvider"/>
                 <!-- Disabled till container themselves stop binding into java:comp 
                     <inject bean="org.jboss.switchboard.UserTransactionRefResourceProvider"/>
                 -->

Modified: branches/switchboard-integration/testsuite/imports/sections/web.xml
===================================================================
--- branches/switchboard-integration/testsuite/imports/sections/web.xml	2010-11-03 16:50:36 UTC (rev 109094)
+++ branches/switchboard-integration/testsuite/imports/sections/web.xml	2010-11-03 17:47:45 UTC (rev 109095)
@@ -230,6 +230,7 @@
          <metainf dir="${build.resources}/web/META-INF">
             <include name="jboss-app.xml"/>
             <include name="jboss-structure.xml"/>
+			<include name="hornetq-jms.xml"/>
          </metainf>
          <fileset dir="${build.lib}">
             <include name="jbosstest-web-ejbs.jar"/>

Added: branches/switchboard-integration/testsuite/src/resources/web/META-INF/hornetq-jms.xml
===================================================================
--- branches/switchboard-integration/testsuite/src/resources/web/META-INF/hornetq-jms.xml	                        (rev 0)
+++ branches/switchboard-integration/testsuite/src/resources/web/META-INF/hornetq-jms.xml	2010-11-03 17:47:45 UTC (rev 109095)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration xmlns="urn:hornetq"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="urn:hornetq /schema/hornetq-jms.xsd">
+
+    <queue name="MockQueueA">
+        <entry name="MockQueueA" />
+    </queue>
+    
+    <queue name="MockQueueB">
+        <entry name="MockQueueB" />
+    </queue>
+
+    <topic name="MockTopicA">
+        <entry name="MockTopicA"/>
+    </topic>
+
+</configuration>

Modified: branches/switchboard-integration/tomcat/src/main/java/org/jboss/web/tomcat/service/injection/WebResourceHandler.java
===================================================================
--- branches/switchboard-integration/tomcat/src/main/java/org/jboss/web/tomcat/service/injection/WebResourceHandler.java	2010-11-03 16:50:36 UTC (rev 109094)
+++ branches/switchboard-integration/tomcat/src/main/java/org/jboss/web/tomcat/service/injection/WebResourceHandler.java	2010-11-03 17:47:45 UTC (rev 109095)
@@ -33,7 +33,6 @@
 import javax.annotation.Resources;
 import javax.ejb.EJBContext;
 import javax.ejb.EJBException;
-import javax.ejb.SessionContext;
 import javax.ejb.TimerService;
 import javax.transaction.UserTransaction;
 import javax.xml.ws.WebServiceContext;
@@ -300,18 +299,18 @@
       for (MessageDestinationReferenceMetaData envRef : refs)
       {
          String encName = "env/" + envRef.getMessageDestinationRefName();
-         if (container.getEncInjectors().containsKey(encName))
-            continue;
-         String jndiName = envRef.getMappedName();
-         if (jndiName == null || jndiName.equals(""))
-         {
-            jndiName = envRef.getResolvedJndiName();
-            if (jndiName == null || jndiName.equals(""))
-               throw new RuntimeException("mapped-name is required for " + envRef.getMessageDestinationRefName()
-                     + " of deployment " + container.getIdentifier());
-         }
-         container.getEncInjectors().put(encName,
-               new LinkRefEncInjector(encName, jndiName, "<message-destination-ref>"));
+//         if (container.getEncInjectors().containsKey(encName))
+//            continue;
+//         String jndiName = envRef.getMappedName();
+//         if (jndiName == null || jndiName.equals(""))
+//         {
+//            jndiName = envRef.getResolvedJndiName();
+//            if (jndiName == null || jndiName.equals(""))
+//               throw new RuntimeException("mapped-name is required for " + envRef.getMessageDestinationRefName()
+//                     + " of deployment " + container.getIdentifier());
+//         }
+//         container.getEncInjectors().put(encName,
+//               new LinkRefEncInjector(encName, jndiName, "<message-destination-ref>"));
          InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
       }
    }



More information about the jboss-cvs-commits mailing list