[jboss-cvs] JBossAS SVN: r58281 - in projects/microcontainer/trunk/deployers/src: main/org/jboss/deployers/plugins/deployer main/org/jboss/deployers/plugins/structure main/org/jboss/deployers/spi/deployer main/org/jboss/deployers/spi/structure tests/org/jboss/test/deployers/structure/ear/test

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Nov 12 15:36:51 EST 2006


Author: scott.stark at jboss.org
Date: 2006-11-12 15:36:44 -0500 (Sun, 12 Nov 2006)
New Revision: 58281

Modified:
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ComponentDeploymentContext.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java
   projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
   projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java
Log:
Add simpleName and relativePathName accessors to the deployment unit/context

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java	2006-11-12 17:07:36 UTC (rev 58280)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/deployer/AbstractDeploymentUnit.java	2006-11-12 20:36:44 UTC (rev 58281)
@@ -73,6 +73,22 @@
       return deploymentContext.getName();
    }
    
+   public String getSimpleName()
+   {
+      return deploymentContext.getSimpleName();
+   }
+
+   /**
+    * Get the path of this deployment relative to the top of the
+    * deployment based on the vfs paths.
+    * 
+    * @return the top-level deployment relative path
+    */
+   public String getRelativePath()
+   {
+      return deploymentContext.getRelativePath();
+   }
+
    public ClassLoader getClassLoader()
    {
       ClassLoader cl = deploymentContext.getClassLoader();

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java	2006-11-12 17:07:36 UTC (rev 58280)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/AbstractDeploymentContext.java	2006-11-12 20:36:44 UTC (rev 58281)
@@ -229,6 +229,45 @@
       return name;
    }
 
+   /**
+    * Get the simple vfs name of the deployment unit. This is the simple
+    * name of the virtual file .
+    * 
+    * vfs path ------------------- relative path
+    * deploy/some.ear              "some.ear"
+    * deploy/some.ear/x.ejb        "x.ejb"
+    * deploy/some.ear/y.sar        "y.sar"
+    * deploy/some.ear/y.sar/z.rar  "z.rar"
+    * @return the deployment unit simple path
+    */
+   public String getSimpleName()
+   {
+      VirtualFile unitVF = getRoot();
+      return unitVF.getName();
+   }
+
+   /**
+    * Get the path of this deployment relative to the top of the
+    * deployment based on the vfs paths.
+    * 
+    * @return the top-level deployment relative path
+    */
+   public String getRelativePath()
+   {
+      VirtualFile unitVF = getRoot();
+      VirtualFile topVF = unitVF;
+      DeploymentContext ctx = getParent();
+      while( ctx != null )
+      {
+         topVF = ctx.getRoot();
+         ctx = ctx.getParent();
+      }
+      String unitPath = unitVF.getPathName();
+      String topPath = topVF.getPathName();
+      String relativePath = unitPath.substring(topPath.length());
+      return relativePath;
+   }
+
    public StructureDetermined getStructureDetermined()
    {
       return structureDetermined;

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ComponentDeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ComponentDeploymentContext.java	2006-11-12 17:07:36 UTC (rev 58280)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/plugins/structure/ComponentDeploymentContext.java	2006-11-12 20:36:44 UTC (rev 58281)
@@ -93,6 +93,15 @@
       return name;
    }
 
+   public String getSimpleName()
+   {
+      return parent.getSimpleName();
+   }
+   public String getRelativePath()
+   {
+      return parent.getRelativePath();
+   }
+
    public StructureDetermined getStructureDetermined()
    {
       return parent.getStructureDetermined();

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java	2006-11-12 17:07:36 UTC (rev 58280)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/deployer/DeploymentUnit.java	2006-11-12 20:36:44 UTC (rev 58281)
@@ -47,8 +47,35 @@
     *  @return the name;
     */
    String getName();
-   
+
    /**
+    * Get the simple vfs name of the deployment unit. This is the simple
+    * name of the virtual file .
+    * 
+    * vfs path ------------------- relative path
+    * deploy/some.ear              "some.ear"
+    * deploy/some.ear/x.ejb        "x.ejb"
+    * deploy/some.ear/y.sar        "y.sar"
+    * deploy/some.ear/y.sar/z.rar  "z.rar"
+    * @return the deployment unit simple path
+    */
+   public String getSimpleName();
+
+   /**
+    * Get the path of this deployment relative to the top of the
+    * deployment based on the vfs paths. For example, an ear:
+    * 
+    * vfs path ------------------- relative path
+    * deploy/some.ear              ""
+    * deploy/some.ear/x.ejb        "/x.ejb"
+    * deploy/some.ear/y.sar        "/y.sar"
+    * deploy/some.ear/y.sar/z.rar  "/y.sar/z.rar"
+    * 
+    * @return the top-level deployment relative path
+    */
+   public String getRelativePath();
+
+   /**
     * Gets a metadata file
     * 
     * @param name the name to exactly match

Modified: projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java	2006-11-12 17:07:36 UTC (rev 58280)
+++ projects/microcontainer/trunk/deployers/src/main/org/jboss/deployers/spi/structure/DeploymentContext.java	2006-11-12 20:36:44 UTC (rev 58281)
@@ -46,6 +46,33 @@
    String getName();
 
    /**
+    * Get the simple vfs name of the deployment unit. This is the simple
+    * name of the virtual file .
+    * 
+    * vfs path ------------------- relative path
+    * deploy/some.ear              "some.ear"
+    * deploy/some.ear/x.ejb        "x.ejb"
+    * deploy/some.ear/y.sar        "y.sar"
+    * deploy/some.ear/y.sar/z.rar  "z.rar"
+    * @return the deployment unit simple path
+    */
+   public String getSimpleName();
+
+   /**
+    * Get the path of this deployment relative to the top of the
+    * deployment based on the vfs paths. For example, an ear:
+    * 
+    * vfs path ------------------- relative path
+    * deploy/some.ear              ""
+    * deploy/some.ear/x.ejb        "/x.ejb"
+    * deploy/some.ear/y.sar        "/y.sar"
+    * deploy/some.ear/y.sar/z.rar  "/y.sar/z.rar"
+    * 
+    * @return the top-level deployment relative path
+    */
+   public String getRelativePath();
+
+   /**
     * Whether the structure is determined
     * 
     * @return true when the structure is determined

Modified: projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java
===================================================================
--- projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java	2006-11-12 17:07:36 UTC (rev 58280)
+++ projects/microcontainer/trunk/deployers/src/tests/org/jboss/test/deployers/structure/ear/test/EARStructureUnitTestCase.java	2006-11-12 20:36:44 UTC (rev 58281)
@@ -146,6 +146,37 @@
       Set<DeploymentContext> children = ear.getChildren();
       Set<String> childPaths = super.createDeploymentPathSet(children, rootURL);
       assertEquals("ear child count", expected, childPaths);
+
+      // Check the deployment relative path names
+      Map<String, DeploymentContext> ctxMap = createDeploymentPathMap(ear);
+      String earPath = ear.getRelativePath();
+      assertEquals("ear relative path is ''", "", earPath);
+      assertEquals("ear simple name is simplewithappxml.ear", "simplewithappxml.ear", ear.getSimpleName());
+      log.debug("ctxMap: "+ctxMap);
+      DeploymentContext ms = ctxMap.get("simplewithappxml.ear/module-service.xml");
+      assertEquals("module-service.xml", "/module-service.xml", ms.getRelativePath());
+      assertEquals("module-service.xml", "module-service.xml", ms.getSimpleName());
+      DeploymentContext ejb1 = ctxMap.get("simplewithappxml.ear/module-bean1ejb.jar");
+      assertEquals("module-bean1ejb.jar", "/module-bean1ejb.jar", ejb1.getRelativePath());
+      assertEquals("module-bean1ejb.jar", "module-bean1ejb.jar", ejb1.getSimpleName());
+      DeploymentContext ejb2 = ctxMap.get("simplewithappxml.ear/module-bean2.ejb3");
+      assertEquals("module-bean2.ejb3", "/module-bean2.ejb3", ejb2.getRelativePath());
+      assertEquals("module-bean2.ejb3", "module-bean2.ejb3", ejb2.getSimpleName());
+      DeploymentContext client1 = ctxMap.get("simplewithappxml.ear/module-client1.jar");
+      assertEquals("module-client1.jar", "/module-client1.jar", client1.getRelativePath());
+      assertEquals("module-client1.jar", "module-client1.jar", client1.getSimpleName());
+      DeploymentContext sar1 = ctxMap.get("simplewithappxml.ear/module-mbean1.sar");
+      assertEquals("module-mbean1.sar", "/module-mbean1.sar", sar1.getRelativePath());
+      assertEquals("module-mbean1.sar", "module-mbean1.sar", sar1.getSimpleName());
+      DeploymentContext mc1 = ctxMap.get("simplewithappxml.ear/module-mcf1-ds.xml");
+      assertEquals("module-mcf1-ds.xml", "/module-mcf1-ds.xml", mc1.getRelativePath());
+      assertEquals("module-mcf1-ds.xml", "module-mcf1-ds.xml", mc1.getSimpleName());
+      DeploymentContext rar1 = ctxMap.get("simplewithappxml.ear/module-mcf1.rar");
+      assertEquals("module-mcf1.rar", "/module-mcf1.rar", rar1.getRelativePath());
+      assertEquals("module-mcf1.rar", "module-mcf1.rar", rar1.getSimpleName());
+      DeploymentContext web1 = ctxMap.get("simplewithappxml.ear/module-web1.war");
+      assertEquals("module-web1.war", "/module-web1.war", web1.getRelativePath());
+      assertEquals("module-web1.war", "module-web1.war", web1.getSimpleName());
    }
 
    /**
@@ -181,9 +212,14 @@
       DeploymentContext extensionsAop = pathMap.get("complexwithappxml.ear/module-mbean1.sar/extensions.aop");
       assertNotNull("complexwithappxml.ear/module-mbean1.sar/extensions.aop/", extensionsAop);
       DeploymentContext submbean1 = pathMap.get("complexwithappxml.ear/module-mbean1.sar/submbean.sar");
+      assertEquals("submbean.sar", "/module-mbean1.sar/submbean.sar", submbean1.getRelativePath());
+      assertEquals("submbean.sar", "submbean.sar", submbean1.getSimpleName());
       assertNotNull("complexwithappxml.ear/submbean.sar", submbean1);
       DeploymentContext submbean2 = pathMap.get("complexwithappxml.ear/module-mbean1.sar/submbean2-service.xml");
       assertNotNull("complexwithappxml.ear/submbean2-service.xml", submbean2);
+      assertEquals("submbean2-service.xml", "/module-mbean1.sar/submbean2-service.xml", submbean2.getRelativePath());
+      assertEquals("submbean2-service.xml", "submbean2-service.xml", submbean2.getSimpleName());
+
    }
    
 }




More information about the jboss-cvs-commits mailing list