Package org.jboss.deployers.vfs.spi.structure

Examples of org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit


      // The infrastructure will only check leafs anyway so no need to check here
      if (name == null && isIncludeDeploymentFile())
         name = unit.getName();

      // Try to find the metadata
      VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;

      // let's check altDD first
      VirtualFile file = getMetadataFile(vfsDeploymentUnit, getOutput(), name, false);
      if (file != null)
         return parseAndInit(vfsDeploymentUnit, file, root, true);

      // try all name+suffix matches
      List<VirtualFile> files = vfsDeploymentUnit.getMetaDataFiles(name, suffix);
      switch (files.size())
      {
         case 0 :
            return null;
         case 1 :
View Full Code Here


   protected T parse(DeploymentUnit unit, Set<String> names, String suffix, T root) throws Exception
   {
      if (names == null || names.isEmpty())
         throw new IllegalArgumentException("Null or empty names.");

      VFSDeploymentUnit  vfsDeploymentUnit = (VFSDeploymentUnit)unit;

      List<VirtualFile> files = new ArrayList<VirtualFile>();
      Set<String> missingFiles = new HashSet<String>();
      Set<String> ignoredFiles = new HashSet<String>();

      for (String name : names)
      {
         if (ignoreName(unit, name))
         {
            ignoredFiles.add(name);
         }
         else
         {
            // try finding altDD file
            VirtualFile file = getMetadataFile(vfsDeploymentUnit, matchFileToClass(unit, name), name, false);
            if (file == null)
            {
               List<VirtualFile> matched = vfsDeploymentUnit.getMetaDataFiles(name, suffix);
               if (matched != null && matched.isEmpty() == false)
                  files.addAll(matched);
               else
                  missingFiles.add(name);
            }
View Full Code Here

   }

   public void testSimpleUsage() throws Exception
   {
      VirtualFile ear = createBasicEar();
      VFSDeploymentUnit topUnit = assertDeploy(ear);
      try
      {
         WebBeanDiscovery wbDiscovery = topUnit.getAttachment(WebBeanDiscovery.class);
         assertNotNull(wbDiscovery);

         Set<String> expected = new HashSet<String>();
         addExpectedResouorce(expected, "ejbs.jar");
         addExpectedResouorce(expected, "ext.jar");
View Full Code Here

      addOutput(WebBeanDiscovery.class);
   }

   public void deploy(VFSDeploymentUnit unit, JBossWebBeansMetaData deployment) throws DeploymentException
   {
      VFSDeploymentUnit topUnit = unit.getTopLevel();
      WebBeanDiscoveryImpl wbdi = topUnit.getAttachment(WebBeanDiscovery.class.getName(), WebBeanDiscoveryImpl.class);
      if (wbdi == null)
      {
         wbdi = new WebBeanDiscoveryImpl();
         topUnit.addAttachment(WebBeanDiscovery.class.getName(), wbdi);
      }

      List<URL> urls = new ArrayList<URL>();

      try
      {
         if (deployment != null)
         {
            // do some custom stuff
         }

         Iterable<VirtualFile> classpaths = getClassPaths(unit);
         for (VirtualFile cp : classpaths)
         {
            VirtualFile wbXml = cp.getChild("META-INF/web-beans.xml");
            if (wbXml != null)
            {
               // add url
               wbdi.addWebBeansXmlURL(wbXml.toURL());
               // add classes
               urls.add(cp.toURL());
            }
         }

         // handle war slightly different
         VirtualFile warWbXml = unit.getFile("WEB-INF/web-beans.xml");
         if (warWbXml != null)
         {
            wbdi.addWebBeansXmlURL(warWbXml.toURL());

            VirtualFile classes = unit.getFile("WEB-INF/classes");
            if (classes != null)
               urls.add(classes.toURL());
         }
      }
      catch (Exception e)
      {
         throw DeploymentException.rethrowAsDeploymentException("Cannot deploy WBD.", e);
      }

      if (urls.isEmpty() == false)
      {
         Module module = unit.getAttachment(Module.class);
         if (module == null)
         {
            VFSDeploymentUnit parent = unit.getParent();
            while (parent != null && module == null)
            {
               module = parent.getAttachment(Module.class);
               parent = parent.getParent();
            }
            if (module == null)
               throw new DeploymentException("No module in deployment unit's hierarchy: " + unit.getName());
         }
View Full Code Here

      {
         BeanMetaData dirStructureBMD = new AbstractBeanMetaData("DirStructure", DirectoryStructure.class.getName());
         KernelControllerContext dirContext = deploy(dirStructureBMD);
         try
         {
            VFSDeploymentUnit unit = assertDeploy("/structure/dir", file);
            try
            {
               assertNotNull(getBean("test:service=TestMessage"));
            }
            finally
View Full Code Here

   }

   public void testWAR() throws Exception
   {
      VirtualFile originalRoot = createDeploymentRoot("/synch/war", "simple.war");
      VFSDeploymentUnit deploymentUnit = assertDeploy(originalRoot);
      try
      {
         VirtualFile tempRoot = deploymentUnit.getRoot();
         StructureModificationChecker checker = createStructureModificationChecker();
         assertFalse(checker.hasStructureBeenModified(originalRoot));

         // add new file
         URI rootURI = VFSUtils.getRealURL(originalRoot).toURI();
View Full Code Here

      }
   }

   public void testEAR() throws Exception
   {
      VFSDeploymentUnit deploymentUnit = assertDeploy("/synch/ear", "simple.ear");
      try
      {
         VirtualFile root = deploymentUnit.getRoot();
         StructureModificationChecker checker = createStructureModificationChecker();
         assertFalse(checker.hasStructureBeenModified(root));
      }
      finally
      {
View Full Code Here

      super(name);
   }

   public void testNoSubDeploymentClassLoader() throws Exception
   {
      VFSDeploymentUnit top = assertDeploy("/classloader", "top-sub-no-classloader");
      try
      {
         ClassLoader clTop = getClassLoader(top);
         assertGetResource("test-resource-top-no-classloader", clTop);
         assertGetResource("test-resource-sub-no-classloader", clTop);
View Full Code Here

      }
   }

   public void testSubDeploymentClassLoader() throws Exception
   {
      VFSDeploymentUnit top = assertDeploy("/classloader", "top-sub-classloader");
      try
      {
         ClassLoader clTop = getClassLoader(top);
         assertGetResource("test-resource-top-classloader", clTop);
         assertNoResource("test-resource-sub-classloader", clTop);
View Full Code Here

      Deployment ad = createDeployment("A");
      ClassLoadingMetaData clmd = addClassLoadingMetaData(ad, v1, true, A.class);
      clmd.setBlackListable(false);
      assertDeploy(mainDeployer, ad);

      VFSDeploymentUnit unit = (VFSDeploymentUnit) main.getDeploymentUnit("A");
      VirtualFile file = unit.getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_KEY, VirtualFile.class);
      assertNotNull(file);
      assertTrue("dynamic classes should be in the classpath", unit.getClassPath().contains(file));

      URL root = unit.getAttachment(InMemoryClassesDeployer.DYNAMIC_CLASS_URL_KEY, URL.class);
      assertNotNull(root);
     
      String aPackage = A.class.getPackage().getName();
      aPackage = aPackage.replace(".", "/");
      String resourceName = aPackage + "/TestInMemory";
      URL testResource = new URL(root, resourceName);
      ClassLoader cl = unit.getClassLoader();
      assertNull(cl.getResource(resourceName));
     
      byte[] bytes = new byte[0];
      MemoryFileFactory.putFile(testResource, bytes);
      URL resource = cl.getResource(resourceName);
      assertNotNull(resource);
      // dunno why direct URL equals fails?
      assertEquals(testResource.toExternalForm(), resource.toExternalForm());
     
      mainDeployer.undeploy(ad);
      mainDeployer.checkComplete();
      assertFalse("dynamic classes should NOT be in the classpath", unit.getClassPath().contains(file));
   }
View Full Code Here

TOP

Related Classes of org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.