[jboss-cvs] JBossAS SVN: r77780 - projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 2 08:21:16 EDT 2008


Author: wolfc
Date: 2008-09-02 08:21:16 -0400 (Tue, 02 Sep 2008)
New Revision: 77780

Added:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/MessageDestinationResolver.java
Log:
EJBTHREE-1481: backwards compatible

Copied: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/MessageDestinationResolver.java (from rev 77750, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/MessageDestinationResolver.java)
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/MessageDestinationResolver.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/enc/MessageDestinationResolver.java	2008-09-02 12:21:16 UTC (rev 77780)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejb3.enc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.MessageDestinationMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationsMetaData;
+
+/**
+ * Find a message destination link within any module of
+ * this JavaEE application deployment.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ * @deprecated use org.jboss.ejb3.resolvers.MessageDestinationReferenceResolver
+ */
+ at Deprecated
+public class MessageDestinationResolver
+{
+   private static final Logger log = Logger.getLogger(MessageDestinationResolver.class);
+   
+   private DeploymentScope deploymentScope;
+   private Map<String, MessageDestinationMetaData> messageDestinations = new HashMap<String, MessageDestinationMetaData>();
+   
+   public MessageDestinationResolver(DeploymentScope deploymentScope, MessageDestinationsMetaData mergedMessageDestinations)
+   {
+      this.deploymentScope = deploymentScope;
+      if (mergedMessageDestinations != null)
+      {
+         for (MessageDestinationMetaData dest : mergedMessageDestinations)
+         {
+            messageDestinations.put(dest.getMessageDestinationName(), dest);
+         }
+      }
+      // TODO Auto-generated constructor stub
+   }
+
+   private String getMessageDestinationJNDIName(String name)
+   {
+      MessageDestinationMetaData dest = messageDestinations.get(name);
+      if(dest != null)
+         return dest.getJndiName();
+      return null;
+   }
+   
+   /**
+    * Resolve the message destination link name and return the
+    * matching jndi name.
+    * 
+    * @param link   name of the message destination
+    * @return       jndi name
+    */
+   public String resolveMessageDestination(String link)
+   {
+      int hashIndex = link.indexOf('#');
+      if (hashIndex != -1)
+      {
+         if (deploymentScope == null)
+         {
+            log.warn("Message destination link '" + link + "' is relative, but no deployment scope found");
+            return null;
+         }
+         String relativePath = link.substring(0, hashIndex);
+         Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
+         if (dep == null)
+         {
+            log.warn("Can't find a deployment for path '" + relativePath + "' of message destination link '" + link + "'");
+            return null;
+         }
+         String name = link.substring(hashIndex + 1);
+         return dep.resolveMessageDestination(name);
+      }
+      String jndiName = getMessageDestinationJNDIName(link);
+      if(jndiName != null)
+         return jndiName;
+      for(Ejb3Deployment dep : deploymentScope.getEjbDeployments())
+      {
+         jndiName = dep.resolveMessageDestination(link);
+         if(jndiName != null)
+            return jndiName;
+      }
+      log.warn("Can't find a message destination for link '" + link + "' anywhere");
+      return null;
+   }
+}




More information about the jboss-cvs-commits mailing list