Package org.jboss.vfs

Examples of org.jboss.vfs.VirtualFile


      }
   }
  
   public void testExternalMcBeanInjectedIntoWeldInitiallyUndeployedThenDeployed() throws Exception
   {
      VirtualFile mcEar = VFS.getChild("mc.ear");
      createAssembledDirectory(mcEar)
         .addPath("/weld/mcandweld/ear/mconly");
      createMcLib(mcEar, "/weld/mcandweld/mc/simple", SimpleBean.class);
      Deployment mc = deploy(mcEar);
     
      undeploy(mc);
     
      VirtualFile weldEar = VFS.getChild("weld.ear");
      createAssembledDirectory(weldEar)
         .addPath("/weld/mcandweld/ear/weldonly");
      createWeldLib(weldEar, "/weld/mcandweld/weld", WeldBeanWithInjectedMcBean.class);
     
      try
View Full Code Here


   }
  
   public void testUninstallOfIntermediateBeanIfBeanManagerWasNotInstalled() throws Throwable
   {
      DeployerClient mainDeployer = getDeployerClient();
      VirtualFile ear = VFS.getChild("top-level.ear");
      createAssembledDirectory(ear)
         .addPath("/weld/mcandweld/ear/weldandmc");
      createMcLib(ear, "/weld/mcandweld/mc/nobootstrap", SimpleBeanWithSimpleWebBean.class);
      createWeldLib(ear, "/weld/mcandweld/weld", SimpleWebBean.class);
     
View Full Code Here

      if (deploymentName == null)
      {
         try
         {
            //
            VirtualFile file = VFS.getChild(url);
            if (file == null || file.exists() == false) {
               // copy to temp location and deploy from there.
               final File temp = File.createTempFile("tmp", getShortName(url.getPath()), getTempDir());
               temp.deleteOnExit();
               copy(url, temp);
               file = VFS.getChild(temp.toURI());
               deploymentName = url.toExternalForm();
            } else {
               deploymentName = file.asFileURI().toString();              
            }
           
            final VFSDeployment deployment = deploymentFactory.createVFSDeployment(deploymentName, file);
            delegate.addDeployment(deployment);
            delegate.process();
View Full Code Here

         {
            String moduleName = child.getSimpleName();
            ModuleMetaData module = modules.get(moduleName);
            if(module != null && module.getAlternativeDD() != null)
            {
               VirtualFile altDDFile = unit.getRoot().getChild(module.getAlternativeDD());
               if(altDDFile == null)
                  throw new IllegalStateException("Failed to locate alternative DD '" + module.getAlternativeDD() + "' in " + unit.getRoot().getPathName());
              
               String attachmentName;
               if(module.getType() == ModuleMetaData.ModuleType.Ejb)
View Full Code Here

   public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException
   {
      ContextInfo context;
      boolean valid;
      boolean trace = log.isTraceEnabled();
      VirtualFile file = structureContext.getFile();
      try
      {
         if (hasValidName(file) == false)
            return false;

         context = createContext(structureContext, "META-INF");
         context.setComparatorClassName(comparatorClassName);

         VirtualFile applicationXml = getMetaDataFile(file, "META-INF/application.xml");
         VirtualFile jbossAppXml = getMetaDataFile(file, "META-INF/jboss-app.xml");
         VirtualFile lib;

         boolean scan = true;

         Unmarshaller unmarshaller = unmarshallerFactory.newUnmarshaller();
         unmarshaller.setValidation(useValidation);
         EarMetaData specMetaData = null;
         JBossAppMetaData appMetaData = null;
         if (applicationXml != null)
         {
            InputStream in = applicationXml.openStream();
            try
            {
               specMetaData = (EarMetaData) unmarshaller.unmarshal(in, resolver);
            }
            finally
            {
               in.close();
            }
            scan = false;
         }
         if (jbossAppXml != null)
         {
            InputStream in = jbossAppXml.openStream();
            try
            {
               appMetaData = (JBossAppMetaData) unmarshaller.unmarshal(in, resolver);
            }
            finally
            {
               in.close();
            }
         }
         // Need a metadata instance and there will not be one if there are no descriptors
         if (appMetaData == null)
         {
            appMetaData = new JBossAppMetaData();
         }
         // Create the merged view
         appMetaData.merge(appMetaData, specMetaData);

         String libDir = appMetaData.getLibraryDirectory();
         if (libDir == null || libDir.length() > 0)
         {
            if (libDir == null)
               libDir = "lib";

            // Add the ear lib contents to the classpath
            if(trace)
               log.trace("Checking for ear lib directory: "+libDir);
            try
            {
               lib = file.getChild(libDir);
               if (lib.exists())
               {
                  if(trace)
                     log.trace("Found ear lib directory: "+lib);
                  List<VirtualFile> archives = lib.getChildren(earLibFilter);
                  for (VirtualFile archive : archives)
                  {
                     Automounter.mount(file, archive);
                     addClassPath(structureContext, archive, true, true, context);
                     // add any jars with persistence.xml as a deployment
                     if (archive.getChild("META-INF/persistence.xml").exists())
                     {
                        log.trace(archive.getName() + " in ear lib directory has persistence units");
                        if (structureContext.determineChildStructure(archive) == false)
                        {
                           throw new RuntimeException(archive.getName()
                                 + " in lib directory has persistence.xml but is not a recognized deployment, .ear: "
                                 + file.getName());
                        }
                     }
                     else if (trace)
                        log.trace(archive.getPathName() + " does not contain META-INF/persistence.xml");
                  }
               }
               else if (trace)
                  log.trace("No lib directory in ear archive.");
            }
            catch (IOException e)
            {
               // TODO - should we throw this fwd?
               log.warn("Exception while searching for lib dir: " + e);
            }
         }
         else if (trace)
         {
            log.trace("Ignoring library directory, got empty library-directory element.");
         }

         // Add the ear manifest locations?
         addClassPath(structureContext, file, includeEarRootInClasspath, true, context);

         // TODO: need to scan for annotationss
         if( scan )
         {
            scanEar(file, appMetaData);
         }

         // Create subdeployments for the ear modules
         ModulesMetaData modules = appMetaData.getModules();
         if(modules != null)
         {
            for (ModuleMetaData mod : modules)
            {
               String fileName = mod.getFileName();
               if (fileName != null && (fileName = fileName.trim()).length() > 0)
               {
                  if (log.isTraceEnabled())
                     log.trace("Checking application.xml module: " + fileName);

                  VirtualFile module = file.getChild(fileName);
                  if (module.exists() == false)
                  {
                     throw new RuntimeException(fileName + " module listed in application.xml does not exist within .ear " + file.toURI());


                  }
View Full Code Here

      else if( path.endsWith(".sar") )
         type = J2eeModuleMetaData.SERVICE;
      else if( path.endsWith(".jar") )
      {
         // Look for a META-INF/application-client.xml
         VirtualFile mfFile = getMetaDataFile(archive, "META-INF/MANIFEST.MF");
         VirtualFile clientXml = getMetaDataFile(archive, "META-INF/application-client.xml");
         VirtualFile ejbXml = getMetaDataFile(archive, "META-INF/ejb-jar.xml");
         VirtualFile jbossXml = getMetaDataFile(archive, "META-INF/jboss.xml");

         if( clientXml != null )
         {
            type = J2eeModuleMetaData.CLIENT;
         }
View Full Code Here

      return tmp.toString();
   }

   private VirtualFile getMetaDataFile(VirtualFile file, String path)
   {
      VirtualFile metaFile = null;
      metaFile = file.getChild(path);
      return metaFile.exists() ? metaFile : null;
   }
View Full Code Here

   }

   public boolean doDetermineStructure(StructureContext structureContext) throws DeploymentException
   {
      ContextInfo context = null;
      VirtualFile file = structureContext.getFile();
      try
      {
         boolean trace = log.isTraceEnabled();

         // the WEB-INF
         VirtualFile webinf;
        
         // We require either a WEB-INF or the name ends in .war
         if (hasValidSuffix(file.getName()) == false)
         {
           webinf = file.getChild("WEB-INF");
           if (webinf.exists())
           {
              if (trace)
                 log.trace("... ok - directory has a WEB-INF subdirectory");
           }
           else
           {
              if (trace)
                 log.trace("... no - doesn't look like a war and no WEB-INF subdirectory.");
              return false;
           }
         }
         else if (trace)
         {
            log.trace("... ok - name ends in .war.");
         }

         // Check for a META-INF for metadata
         // FIXME: This is not spec legal, descriptors could be loaded from this location
         String[] metaDataLocations = new String[]{"WEB-INF", "WEB-INF/classes/META-INF"};
         // Create a context for this war file and all its metadata locations
         context = createContext(structureContext, metaDataLocations);

         // Add all children as locations for TLDs (except classes and lib), recursively
         webinf = file.getChild("WEB-INF");
         if (webinf.exists())
         {
            List<VirtualFile> children = webinf.getChildren();
            for (VirtualFile child : children)
            {
               if (!isLeaf(child) && (!"lib".equals(child.getName())) && (!"classes".equals(child.getName())))
               {
                  addMetaDataPath(structureContext, context, "WEB-INF/" + child.getName(), MetaDataType.ALTERNATIVE);
                  addPathsRecursively(structureContext, context, child, "WEB-INF/" + child.getName());
               }
            }
         }

         // Check for jars in WEB-INF/lib
         List<VirtualFile> archives = null;
         try
         {
            VirtualFile webinfLib = file.getChild("WEB-INF/lib");
            if (webinfLib.exists())
            {
               archives = webinfLib.getChildren(webInfLibFilter);
               // Add the jars' META-INF for metadata
               for (VirtualFile jar : archives)
               {
                  Automounter.mount(file, jar);
                  // either same as plain lib filter, null or accepts the jar
                  if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
                  {
                     VirtualFile metaInf = jar.getChild("META-INF");
                     if (metaInf.exists() && !isLeaf(metaInf))
                     {
                        addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF", MetaDataType.ALTERNATIVE);
                        List<VirtualFile> children = metaInf.getChildren();
                        for (VirtualFile child : children)
                        {
                           if (!isLeaf(child) && (!"resources".equals(child.getName())))
                           {
                              addMetaDataPath(structureContext, context, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName(), MetaDataType.ALTERNATIVE);
                              addPathsRecursively(structureContext, context, child, "WEB-INF/lib/" + jar.getName() + "/META-INF/" + child.getName());
                           }
                        }
                     }
                  }
               }
            }
         }
         catch (IOException e)
         {
            log.warn("Exception looking for WEB-INF/lib, " + file.getPathName() + ", " + e);
         }
        
         // Add the war manifest classpath entries
         addClassPath(structureContext, file, false, true, context);

         // Check for WEB-INF/classes
         VirtualFile classes = file.getChild("WEB-INF/classes");
         // Add WEB-INF/classes if present
         if (classes.exists())
            addClassPath(structureContext, classes, true, false, context);
         else if (trace)
            log.trace("No WEB-INF/classes for: " + file.getPathName());

         // and the top level jars in WEB-INF/lib
View Full Code Here

      if (!unit.getSimpleName().endsWith(".war"))
      {
         return;
      }

      VirtualFile root = unit.getRoot();
      if(root.isFile())
         return;

      List<VirtualFile> classpath = unit.getClassPath();
      if(classpath == null || classpath.isEmpty())
         return;
View Full Code Here

      LinkedList<String> order = new LinkedList<String>();
      List<WebOrdering> orderings = new ArrayList<WebOrdering>();
      HashSet<String> jarsSet = new HashSet<String>();
      Set<VirtualFile> overlays = new HashSet<VirtualFile>();
      Map<String, VirtualFile> scis = new HashMap<String, VirtualFile>();
      VirtualFile webInfLib = null;
      boolean fragmentFound = false;
      HashMap<String, WebFragmentMetaData> webFragments = new HashMap<String, WebFragmentMetaData>();
      if (unit instanceof VFSDeploymentUnit)
      {
         VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit) unit;
         webInfLib = vfsUnit.getFile("WEB-INF/lib");
         if (webInfLib != null)
         {
            List<VirtualFile> jars = webInfLib.getChildren();
            for (VirtualFile jar : jars)
            {
               jarsSet.add(jar.getName());
               // Find overlays
               VirtualFile overlay = jar.getChild("META-INF/resources");
               if (overlay.exists())
               {
                  overlays.add(overlay);
               }
               // Find ServletContainerInitializer services
               VirtualFile sci = jar.getChild("META-INF/services/javax.servlet.ServletContainerInitializer");
               if (sci.exists())
               {
                  scis.put(jar.getName(), sci);
               }
            }
         }
View Full Code Here

TOP

Related Classes of org.jboss.vfs.VirtualFile

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.