[jboss-cvs] JBossAS SVN: r72010 - in branches/InjectionPrototype: server/src/main/org/jboss/deployment and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 11 05:37:05 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-04-11 05:37:04 -0400 (Fri, 11 Apr 2008)
New Revision: 72010

Added:
   branches/InjectionPrototype/server/src/main/org/jboss/deployment/plugin/
   branches/InjectionPrototype/server/src/main/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java
   branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/
   branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/DeploymentEndpointResolver.java
   branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/EndpointInfo.java
   branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/EndpointType.java
   branches/InjectionPrototype/testsuite/src/main/org/jboss/test/refs/test/MappedResolverUnitTestCase.java
Modified:
   branches/InjectionPrototype/server/src/etc/deployers/metadata-beans.xml
   branches/InjectionPrototype/server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
   branches/InjectionPrototype/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java
   branches/InjectionPrototype/testsuite/src/resources/refs/ejblink/two/ejb-jar.xml
   branches/InjectionPrototype/testsuite/src/resources/refs/ejblink/two/jboss.xml
Log:
Latest mapped resolver changes

Modified: branches/InjectionPrototype/server/src/etc/deployers/metadata-beans.xml
===================================================================
--- branches/InjectionPrototype/server/src/etc/deployers/metadata-beans.xml	2008-04-11 09:25:05 UTC (rev 72009)
+++ branches/InjectionPrototype/server/src/etc/deployers/metadata-beans.xml	2008-04-11 09:37:04 UTC (rev 72010)
@@ -9,7 +9,7 @@
 	<!-- The reference metdata resolving deployer
 	-->
    <bean name="ReferenceMetaDataResolverDeployer"
-      class="org.jboss.deployment.ReferenceMetaDataResolverDeployer">
+      class="org.jboss.deployment.MappedReferenceMetaDataResolverDeployer">
    </bean>
    <bean name="AnnotationMetaDataDeployer"
       class="org.jboss.deployment.AnnotationMetaDataDeployer">

Modified: branches/InjectionPrototype/server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java
===================================================================
--- branches/InjectionPrototype/server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java	2008-04-11 09:25:05 UTC (rev 72009)
+++ branches/InjectionPrototype/server/src/main/org/jboss/deployment/MappedReferenceMetaDataResolverDeployer.java	2008-04-11 09:37:04 UTC (rev 72010)
@@ -35,11 +35,14 @@
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.deployment.dependency.ContainerDependencyMetaData;
 import org.jboss.deployment.dependency.JndiDependencyMetaData;
+import org.jboss.deployment.plugin.MappedDeploymentEndpointResolver;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.client.jboss.JBossClientMetaData;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
 import org.jboss.metadata.ejb.jboss.JBossEntityBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossGenericBeanMetaData;
 import org.jboss.metadata.ejb.jboss.JBossMetaData;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
@@ -71,6 +74,8 @@
    public static final String ENDPOINT_MAP_KEY = "MappedReferenceMetaDataResolverDeployer.endpointMap";
    /** Key for Set<ContainerDependencyMetaData> attachment */
    public static final String DEPENDS_SET_KEY = "MappedReferenceMetaDataResolverDeployer.dependsSet";
+   /** Key for Map<String, String> of alternate endpoint resolution to the endpointMap key */
+   public static final String ALTERNATE_MAP_KEY = "MappedReferenceMetaDataResolverDeployer.endpointAlternateMape";
    private static Logger log = Logger.getLogger(MappedReferenceMetaDataResolverDeployer.class);
    /** */
    private boolean failOnUnresolvedRefs;
@@ -83,6 +88,7 @@
       inputs.add(JBossMetaData.class.getName());
       inputs.add(JBossWebMetaData.class.getName());
       super.setInputs(inputs);
+      super.setOutput(DeploymentEndpointResolver.class);
    }
 
    /**
@@ -119,11 +125,17 @@
       // Create a map of the reference endpoints if it does not exist in the top unit
       DeploymentUnit top = unit.getTopLevel();
       Map<String, ContainerDependencyMetaData> endpointMap = top.getAttachment(ENDPOINT_MAP_KEY, Map.class);
+      Map<String, String> endpointAlternateMap = top.getAttachment(ALTERNATE_MAP_KEY, Map.class);
       if(endpointMap == null)
       {
          endpointMap = new ConcurrentHashMap<String, ContainerDependencyMetaData>();
-         mapEndpoints(top, endpointMap);
+         endpointAlternateMap = new ConcurrentHashMap<String, String>();
+         mapEndpoints(top, endpointMap, endpointAlternateMap);
          top.addAttachment(ENDPOINT_MAP_KEY, endpointMap, Map.class);
+         top.addAttachment(ALTERNATE_MAP_KEY, endpointAlternateMap);
+         DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver(
+               endpointMap, endpointAlternateMap, unit.getRelativePath());
+         top.addAttachment(DeploymentEndpointResolver.class, resolver);
       }
 
       dump(unit);
@@ -158,6 +170,9 @@
          depends.add(cdmd);
       }
       top.addAttachment(DEPENDS_SET_KEY, depends, Set.class);
+      DeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver(
+            endpointMap, endpointAlternateMap, unit.getRelativePath());
+      unit.addAttachment(DeploymentEndpointResolver.class, resolver);
    }
 
    /**
@@ -166,11 +181,12 @@
     * @param unit - the deployment top level unit to start the mapping from
     * @param endpointMap - the endpoint
     */
-   protected void mapEndpoints(DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap)
+   protected void mapEndpoints(DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap,
+         Map<String, String> endpointAlternateMap)
    {
       boolean trace = log.isTraceEnabled();
       // First map the ejbs
-      mapEjbs(unit, endpointMap, trace);
+      mapEjbs(unit, endpointMap, endpointAlternateMap, trace);
       // Map all sources of message-destinations
       mapMessageDestinations(unit, endpointMap, trace);
       // Display the endpoint map for debugging
@@ -217,8 +233,8 @@
             log.debug("Message-destination: "+destName+" has no mappedName");
             continue;
          }
-         String destPath = prefix + "/" + destName;
-         ContainerDependencyMetaData destMD = new ContainerDependencyMetaData(mappedName);
+         String destPath = prefix + "#" + destName;
+         ContainerDependencyMetaData destMD = new ContainerDependencyMetaData(destName, vfsPath);
          JndiDependencyMetaData jdmd = new JndiDependencyMetaData(mappedName, loader);
          destMD.addJndiDependency(jdmd);
          endpointMap.put(destPath, destMD);
@@ -235,7 +251,8 @@
     * @param unit
     * @param endpointMap
     */
-   protected void mapEjbs(DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap, boolean trace)
+   protected void mapEjbs(DeploymentUnit unit, Map<String, ContainerDependencyMetaData> endpointMap,
+         Map<String, String> endpointAlternateMap, boolean trace)
    {
       JBossMetaData ejbMetaData = unit.getAttachment(JBossMetaData.class);
       JBossEnterpriseBeansMetaData beans = null;
@@ -248,19 +265,24 @@
          for(JBossEnterpriseBeanMetaData bean : beans)
          {
             // The unique id for this ejb in the deployment
-            String ejbCompID = prefix + "/" + bean.getEjbName();
-            ContainerDependencyMetaData cdmd = new ContainerDependencyMetaData(ejbCompID);
+            String ejbCompID = prefix + "#" + bean.getEjbName();
+            ContainerDependencyMetaData cdmd = new ContainerDependencyMetaData(bean.getEjbName(), vfsPath);
             endpointMap.put(ejbCompID, cdmd);
+            // debug info for the mappings each ejb has
             ArrayList<String> mappings = new ArrayList<String>();
             // Alternate mappings
             String ejbNameKey = "ejb/" + bean.getEjbName();
-            if(endpointMap.containsKey(ejbNameKey) == false)
+            if(endpointAlternateMap.containsKey(ejbNameKey) == false)
             {
-               endpointMap.put(ejbNameKey, cdmd);
+               endpointAlternateMap.put(ejbNameKey, ejbCompID);
                mappings.add(ejbNameKey);
                if(trace)
-                  log.trace("mapEjbs, root ejb-name"+ejbNameKey);
+                  log.trace("mapEjbs, added alternate root ejb-name: "+ejbNameKey);
             }
+            else
+            {
+               log.debug("Duplicate root ejb-name: "+ejbNameKey+" from: "+ejbCompID);
+            }
             // Create mappings based on the bean business interfaces
             if(bean instanceof JBossSessionBeanMetaData)
             {
@@ -273,11 +295,11 @@
                   {
                      // Add ejb/vfsPath/iface
                      String ifacePath = prefix + "/" + local;
-                     if(endpointMap.containsKey(ifacePath))
-                        log.debug(ejbName+" duplicates business local: "+local+", existing: "+endpointMap.get(ifacePath));
+                     if(endpointAlternateMap.containsKey(ifacePath))
+                        log.debug(ejbName+" duplicates business local: "+local+", existing: "+endpointAlternateMap.get(ifacePath));
                      else
                      {
-                        endpointMap.put(ifacePath, cdmd);
+                        endpointAlternateMap.put(ifacePath, ejbCompID);
                         mappings.add(ifacePath);
                         if(trace)
                            log.trace("mapEjbs, business-local: "+ifacePath+", ejbName: "+ejbName);
@@ -285,10 +307,13 @@
                      // Add ejb/iface
                      ifacePath = "ejb/" + local;
                      if(endpointMap.containsKey(ifacePath))
-                        log.debug(ejbName+" duplicates business local: "+local+", existing: "+endpointMap.get(ifacePath));
+                     {
+                        // TODO: may need to track the duplicates to create an error
+                        log.debug(ejbName+" duplicates business-local: "+local+", existing: "+endpointMap.get(ifacePath));
+                     }
                      else
                      {
-                        endpointMap.put(ifacePath, cdmd);
+                        endpointAlternateMap.put(ifacePath, ejbCompID);
                         mappings.add(ifacePath);
                         if(trace)
                            log.trace("mapEjbs, business-local: "+ifacePath+", ejbName: "+ejbName);
@@ -302,22 +327,22 @@
                   {
                      // Add ejb/vfsPath/iface
                      String ifacePath = prefix + "/" + remote;
-                     if(endpointMap.containsKey(ifacePath))
-                        log.debug(ejbName+" duplicates business remote: "+remote+", existing: "+endpointMap.get(ifacePath));
+                     if(endpointAlternateMap.containsKey(ifacePath))
+                        log.debug(ejbName+" duplicates business remote: "+remote+", existing: "+endpointAlternateMap.get(ifacePath));
                      else
                      {
-                        endpointMap.put(ifacePath, cdmd);
+                        endpointAlternateMap.put(ifacePath, ejbCompID);
                         mappings.add(ifacePath);
                         if(trace)
                            log.trace("mapEjbs, business-remote: "+ifacePath+", ejbName: "+ejbName);
                      }
                      // Add ejb/iface
                      ifacePath = "ejb/" + remote;
-                     if(endpointMap.containsKey(ifacePath))
-                        log.debug(ejbName+" duplicates business remote: "+remote+", existing: "+endpointMap.get(ifacePath));
+                     if(endpointAlternateMap.containsKey(ifacePath))
+                        log.debug(ejbName+" duplicates business-remote: "+remote+", existing: "+endpointAlternateMap.get(ifacePath));
                      else
                      {
-                        endpointMap.put(ifacePath, cdmd);
+                        endpointAlternateMap.put(ifacePath, ejbCompID);
                         mappings.add(ifacePath);
                         if(trace)
                            log.trace("mapEjbs, business-remote: "+ifacePath+", ejbName: "+ejbName);
@@ -327,6 +352,10 @@
                if(trace)
                   log.trace("mapEjbs: "+ejbCompID+", mappings: "+mappings);
             }
+            else if(bean instanceof JBossGenericBeanMetaData)
+            {
+               log.warn("JBossGenericBeanMetaData seen for: "+bean.getEjbName());
+            }
          }
       }
 
@@ -335,7 +364,7 @@
       if(children != null)
       {
          for(DeploymentUnit child : children)
-            mapEjbs(child, endpointMap, trace);
+            mapEjbs(child, endpointMap, endpointAlternateMap, trace);
       }
    }
 

Modified: branches/InjectionPrototype/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java
===================================================================
--- branches/InjectionPrototype/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java	2008-04-11 09:25:05 UTC (rev 72009)
+++ branches/InjectionPrototype/server/src/main/org/jboss/deployment/dependency/ContainerDependencyMetaData.java	2008-04-11 09:37:04 UTC (rev 72010)
@@ -49,8 +49,10 @@
 
    /** The unique name of the deployment root */
    private String deploymentRootName;
+   /** The deployment relative path name */
+   private String deploymentPath;
    /** The id of the component in the deployment */
-   private String componentID;
+   private String componentName;
 
    private String encName;
 
@@ -73,22 +75,31 @@
     * @param componentID -
     *           the id of the component in the deployment
     */
-   public ContainerDependencyMetaData(String componentID)
+   public ContainerDependencyMetaData(String componentName, String deploymentPath)
    {
-      this(componentID, ControllerState.INSTALLED);
+      this(componentName, deploymentPath, ControllerState.INSTALLED);
    }
 
-   public ContainerDependencyMetaData(String componentID,
+   public ContainerDependencyMetaData(String componentName, String deploymentPath,
          ControllerState whenRequired)
    {
-      this.componentID = componentID;
+      this.componentName = componentName;
+      this.deploymentPath = deploymentPath;
       this.whenRequired = whenRequired;
    }
 
+   public String getComponentName()
+   {
+      return componentName;
+   }
    public String getComponentID()
    {
-      return componentID;
+      return deploymentPath + "#" + componentName;
    }
+   public String getDeploymentPath()
+   {
+      return deploymentPath;
+   }
    public String getDeploymentRootName()
    {
       return deploymentRootName;
@@ -101,7 +112,7 @@
 
    public String getContainerName()
    {
-      return deploymentRootName + componentID;
+      return deploymentRootName + getComponentID();
    }
 
    public Object getDependency()
@@ -127,7 +138,7 @@
    public void initialVisit(MetaDataVisitor visitor)
    {
       DependencyItem item = new ContainerDependencyItem(containerName,
-            componentID, whenRequired);
+            getComponentID(), whenRequired);
       visitor.addDependency(item);
       visitor.initialVisit(this);
    }
@@ -177,8 +188,10 @@
    protected String toStringImplementation()
    {
       StringBuilder tmp = new StringBuilder("ContainerDependencyMetaData(");
-      tmp.append("id=");
-      tmp.append(this.componentID);
+      tmp.append("deploymentPath=");
+      tmp.append(deploymentPath);
+      tmp.append(",componentName=");
+      tmp.append(this.componentName);
       tmp.append(",containerName=");
       tmp.append(this.containerName);
       tmp.append(",targets=");

Added: branches/InjectionPrototype/server/src/main/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java
===================================================================
--- branches/InjectionPrototype/server/src/main/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java	                        (rev 0)
+++ branches/InjectionPrototype/server/src/main/org/jboss/deployment/plugin/MappedDeploymentEndpointResolver.java	2008-04-11 09:37:04 UTC (rev 72010)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment.plugin;
+
+import java.util.Map;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployment.dependency.ContainerDependencyMetaData;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
+import org.jboss.deployment.spi.EndpointInfo;
+import org.jboss.deployment.spi.EndpointType;
+import org.jboss.logging.Logger;
+
+/**
+ * A DeploymentEndpointResolver implementation that relies on the endpoint
+ * map produced by the MappedReferenceMetaDataResolverDeployer
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MappedDeploymentEndpointResolver implements
+      DeploymentEndpointResolver
+{
+   private static Logger log = Logger.getLogger(MappedDeploymentEndpointResolver.class);
+   /** The deployment wide reference map */
+   private Map<String, ContainerDependencyMetaData> endpointMap;
+   private Map<String, String> endpointAlternateMap;
+
+   public MappedDeploymentEndpointResolver(Map<String, ContainerDependencyMetaData> endpointMap,
+         Map<String, String> endpointAlternateMap,
+         String unitPath)
+   {
+      this.endpointMap = endpointMap;
+      this.endpointAlternateMap = endpointAlternateMap;
+   }
+
+   /**
+    * @param businessIntf
+    * @param type - 
+    * @param vfsContext - The path of the unit this resolver is associated with. Used as the
+    * starting point for link resolution.
+    * 
+    */
+   public EndpointInfo getEndpointInfo(Class businessIntf, String type, String vfsContext)
+   {
+      // First look for a unit specific mapping
+      String altKey = "ejb/" + vfsContext + "@" + businessIntf.getName();
+      String key = this.endpointAlternateMap.get(altKey);
+      if(key == null)
+      {
+         // Look for a top level binding
+         altKey = "ejb/@"  + businessIntf;
+         key = this.endpointAlternateMap.get(altKey);
+      }
+      EndpointInfo info = null;
+      if(key != null)
+      {
+         ContainerDependencyMetaData cdmd = endpointMap.get(key);
+         info = new EndpointInfo(cdmd.getDeploymentPath(), cdmd.getComponentName(), type);
+      }
+      return info;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.deployment.spi.DeploymentEndpointResolver#getEndpointInfo(java.lang.String, org.jboss.deployment.spi.EndpointType)
+    */
+   public EndpointInfo getEndpointInfo(String ref, String type, String vfsContext)
+   {
+      String prefix = type;
+      // Parse the ref to obtain the path and endpoint name
+      String unitPath = vfsContext;
+      String endpointName = ref;
+      if (ref.indexOf('#') != -1)
+      {
+         // <ejb-link> is of the form relative-path/file.jar#Bean
+         String path = ref.substring(0, ref.indexOf('#'));
+         // resolve any ../* prefix
+         if(path.startsWith("../"))
+         {
+            String[] deploymentPaths = unitPath.split("/");
+            int count = 0;
+            while(path.startsWith("../"))
+            {
+               path = path.substring(3);
+               count ++;
+            }
+            // build the relative path from the root
+            String rootPath = "";
+            for(int n = 0; n < (deploymentPaths.length - count); n ++)
+               rootPath += deploymentPaths + "/";
+            unitPath = rootPath + path;
+         }
+         // 
+         // Get the endpoint name
+         endpointName = ref.substring(ref.indexOf('#') + 1);
+      }
+
+      EndpointInfo info = null;
+      String key = prefix + "/" + unitPath +"#" + endpointName;
+      ContainerDependencyMetaData cdmd = endpointMap.get(key);
+      if(cdmd != null)
+      {
+         info = new EndpointInfo(unitPath, endpointName, type);
+      }
+      else
+      {
+         log.debug("Failed to find mapping for ref: "+ref+" path: "+vfsContext);
+         if(log.isTraceEnabled())
+            log.trace("Available keys: "+endpointMap.keySet());
+      }
+      return info;
+   }
+
+}

Added: branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/DeploymentEndpointResolver.java
===================================================================
--- branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/DeploymentEndpointResolver.java	                        (rev 0)
+++ branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/DeploymentEndpointResolver.java	2008-04-11 09:37:04 UTC (rev 72010)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment.spi;
+
+/**
+ * An interface for resolving deployment endpoints by reference name or
+ * interface type.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface DeploymentEndpointResolver
+{
+   /**
+    * Find the deployment endpoint info for the given business interface and
+    * expected endpoint type.
+    * 
+    * @param businessIntf - the interface the endpoint should implement
+    * @param endpointType - the type of endpoint
+    * @return the matching endpoint info if found, null otherwise
+    */
+   EndpointInfo getEndpointInfo(Class businessIntf, String endpointType, String vfsContext);
+
+   /**
+    * Find the deployment endpoint for the given reference name. This may be
+    * relative name qualified by a path prefix, or just the endpoint name.
+    * 
+    * @param ref - relative or exact endpoint name
+    * @param endpointType the type of endpoint
+    * @return the matching endpoint info if found, null otherwise
+    * @see EndpointType
+    */
+   EndpointInfo getEndpointInfo(String ref, String endpointType, String vfsContext);
+   
+}

Added: branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/EndpointInfo.java
===================================================================
--- branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/EndpointInfo.java	                        (rev 0)
+++ branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/EndpointInfo.java	2008-04-11 09:37:04 UTC (rev 72010)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment.spi;
+
+import java.io.Serializable;
+
+/**
+ * Encapsulation of a deployment endpoint
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class EndpointInfo implements Serializable
+{
+   private static final long serialVersionUID = 1;
+   /** VFS relative path of the endpoints deployment */
+   private String pathName;
+   /** The deployment unique component name */
+   private String name;
+   /** The endpoint type */
+   private String type;
+   /**
+    * @param pathName
+    * @param name
+    * @param type
+    */
+   public EndpointInfo(String pathName, String name, String type)
+   {
+      super();
+      this.pathName = pathName;
+      this.name = name;
+      this.type = type;
+   }
+
+   public String getPathName()
+   {
+      return pathName;
+   }
+   public String getName()
+   {
+      return name;
+   }
+   public String getType()
+   {
+      return type;
+   }
+
+   @Override
+   public String toString()
+   {
+      StringBuilder tmp = new StringBuilder("EndpointInfo(pathName=");
+      tmp.append(pathName);
+      tmp.append(",name=");
+      tmp.append(name);
+      tmp.append(",type=");
+      tmp.append(type);
+      tmp.append(")");
+      return tmp.toString();
+   }
+}

Added: branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/EndpointType.java
===================================================================
--- branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/EndpointType.java	                        (rev 0)
+++ branches/InjectionPrototype/server/src/main/org/jboss/deployment/spi/EndpointType.java	2008-04-11 09:37:04 UTC (rev 72010)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.deployment.spi;
+
+/**
+ * Constants for the known endpoint types
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface EndpointType
+{
+   public static final String EJB = "ejb";
+   public static final String MCMBean = "mcbean";
+   public static final String MBean = "mbean";
+   public static final String MessageDestination = "message-destination";
+   public static final String PersistenceUnit = "persistence-unit";
+   public static final String Servlet = "servlet";
+   public static final String WebService = "web-service";
+}

Added: branches/InjectionPrototype/testsuite/src/main/org/jboss/test/refs/test/MappedResolverUnitTestCase.java
===================================================================
--- branches/InjectionPrototype/testsuite/src/main/org/jboss/test/refs/test/MappedResolverUnitTestCase.java	                        (rev 0)
+++ branches/InjectionPrototype/testsuite/src/main/org/jboss/test/refs/test/MappedResolverUnitTestCase.java	2008-04-11 09:37:04 UTC (rev 72010)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.test.refs.test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployment.dependency.ContainerDependencyMetaData;
+import org.jboss.deployment.plugin.MappedDeploymentEndpointResolver;
+import org.jboss.deployment.spi.EndpointInfo;
+import org.jboss.deployment.spi.EndpointType;
+import org.jboss.test.refs.common.EjbLinkIF;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests of the MappedDeploymentEndpointResolver
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MappedResolverUnitTestCase extends TestCase
+{
+   private Map<String, ContainerDependencyMetaData> endpointMap
+      = new HashMap<String, ContainerDependencyMetaData>();
+   private Map<String, String> endpointAlternateMap
+   = new HashMap<String, String>();
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+   }
+   
+   public void testEjbRefs()
+   {
+      String deploymentPath = "ejb1.jar";
+      MappedDeploymentEndpointResolver resolver = new MappedDeploymentEndpointResolver(
+            endpointMap, endpointAlternateMap, deploymentPath);
+      // Add ejb mappings to ejb1.jar
+      endpointMap.put("ejb/ejb1.jar#Ejb1InJar1", new ContainerDependencyMetaData("Ejb1InJar1", "ejb1.jar"));
+      endpointMap.put("ejb/ejb1.jar#Ejb2InJar1", new ContainerDependencyMetaData("Ejb2InJar1", "ejb1.jar"));
+      // A business-local mapping for Ejb1InJar1
+      endpointAlternateMap.put("ejb/ejb1.jar@"+EjbLinkIF.class.getName(), "ejb/ejb1.jar#Ejb1InJar1");
+      EndpointInfo info = resolver.getEndpointInfo("Ejb1InJar1", EndpointType.EJB, "ejb1.jar");
+      assertNotNull(info);
+      assertEquals("Ejb1InJar1", info.getName());
+      assertEquals("ejb1.jar", info.getPathName());
+
+      info = resolver.getEndpointInfo("../ejb1.jar#Ejb2InJar1", EndpointType.EJB, "ejb2.jar");
+      assertNotNull(info);
+      assertEquals("Ejb2InJar1", info.getName());
+      assertEquals("ejb1.jar", info.getPathName());
+
+      // 
+      info = resolver.getEndpointInfo(EjbLinkIF.class, EndpointType.EJB, "ejb1.jar");
+      assertNotNull(info);
+      assertEquals("Ejb1InJar1", info.getName());
+      assertEquals("ejb1.jar", info.getPathName());   }
+}

Modified: branches/InjectionPrototype/testsuite/src/resources/refs/ejblink/two/ejb-jar.xml
===================================================================
--- branches/InjectionPrototype/testsuite/src/resources/refs/ejblink/two/ejb-jar.xml	2008-04-11 09:25:05 UTC (rev 72009)
+++ branches/InjectionPrototype/testsuite/src/resources/refs/ejblink/two/ejb-jar.xml	2008-04-11 09:37:04 UTC (rev 72010)
@@ -12,7 +12,7 @@
                 <ejb-ref-name>ejb/EjbLink1Bean</ejb-ref-name>
                 <ejb-ref-type>Session</ejb-ref-type>
                 <remote>org.jboss.test.refs.common.EjbLinkIF</remote>
-                <ejb-link>refs-one-ejb#EjbLink1Bean</ejb-link>
+                <ejb-link>refs-one-ejb.jar#EjbLink1Bean</ejb-link>
             </ejb-ref>
             
             <ejb-local-ref>

Modified: branches/InjectionPrototype/testsuite/src/resources/refs/ejblink/two/jboss.xml
===================================================================
--- branches/InjectionPrototype/testsuite/src/resources/refs/ejblink/two/jboss.xml	2008-04-11 09:25:05 UTC (rev 72009)
+++ branches/InjectionPrototype/testsuite/src/resources/refs/ejblink/two/jboss.xml	2008-04-11 09:37:04 UTC (rev 72010)
@@ -9,6 +9,8 @@
             <jndi-name>ejb3_stateless_ejblink_one_EjbLink2Bean</jndi-name>
             <ejb-ref>
                 <ejb-ref-name>ejb/EjbLink1Bean</ejb-ref-name>
+                <!-- To avoid the circular reference -->
+                <ignore-dependency/>
             </ejb-ref>
             <ejb-ref>
                 <ejb-ref-name>ejb/EjbLink3Bean</ejb-ref-name>




More information about the jboss-cvs-commits mailing list