Package org.jboss.virtual

Examples of org.jboss.virtual.VirtualFile


   }

   public boolean determineStructure(StructureContext structureContext) throws DeploymentException
   {
      ContextInfo context = null;
      VirtualFile file = structureContext.getFile();
      try
      {
         boolean trace = log.isTraceEnabled();
         if (isLeaf(file) == true)
         {
            boolean isFile = false;
            if( trace )
               log.trace(file + " is a leaf");
            // See if this is a top-level by checking the parent
            if (structureContext.isTopLevel() == false)
            {
               if (isKnownFile(file.getName()) == false && checkFileMatchers(file) == false)
               {
                  if (trace)
                     log.trace("... no - it is not a top level file and not a known name");
               }
               else
               {
                  if (trace)
                     log.trace("... ok - not a top level file but it is a known name");
                  isFile = true;
               }
            }
            else
            {
               if (trace)
                  log.trace("... ok - it is a top level file");
               isFile = true;
            }

            // Create a context info for this file
            if (isFile)
               context = createContext(structureContext);
            // There are no subdeployments for files
            if (trace)
               log.trace(file + " isFile: " + isFile);
            return isFile;
         }
         else
         {
            if (trace)
               log.trace("... no - not a file.");
            return false;
         }
      }
      catch (Exception e)
      {
         if (context != null)
            structureContext.removeChild(context);

         throw DeploymentException.rethrowAsDeploymentException("Error determining structure: " + file.getName(), e);
      }
   }
View Full Code Here


   {
      if (deployment instanceof VFSDeployment == false)
         return;

      VFSDeployment vfsDeployment = VFSDeployment.class.cast(deployment);
      VirtualFile root = vfsDeployment.getRoot();
      checkForModification(root, structureMetaData);
   }
View Full Code Here

   {
      if (parentDeploymentContext instanceof VFSDeploymentContext == false || contextInfo == null)
         return;

      VFSDeploymentContext vfsParentDeploymentContext = VFSDeploymentContext.class.cast(parentDeploymentContext);
      VirtualFile root = vfsParentDeploymentContext.getFile(contextInfo.getPath());
      checkForModification(root, contextInfo);
   }
View Full Code Here

            List<VirtualFile> result = new ArrayList<VirtualFile>(metadataPaths.size());
            for (String metadataPath : metadataPaths)
            {
               try
               {
                  VirtualFile child = file.getChild(metadataPath);
                  if (child != null)
                     result.add(child);
               }
               catch (Exception ignored)
               {
View Full Code Here

               // Only process the child contexts
               if ("".equals(path) == false)
               {
                  try
                  {
                     VirtualFile file = root.getChild(path);
                     if (file != null && isModificationDetermined(file, child))
                     {
                        contextInfo.setModificationType(modificationType);
                        return true;
                     }
View Full Code Here

      setRelativeOrder(0);
   }

   public boolean determineStructure(StructureContext structureContext) throws DeploymentException
   {
      VirtualFile file = structureContext.getFile();
      try
      {
         boolean trace = log.isTraceEnabled();
         if (isLeaf(file) == false)
         {
            boolean isJBossStructure = false;
            if (trace)
               log.trace(file + " is not a leaf");
            try
            {
               VirtualFile jbossStructure = file.getChild("META-INF/jboss-structure.xml");
               if (jbossStructure != null)
               {
                  if (trace)
                     log.trace("... context has a META-INF/jboss-structure.xml");

                  URL url = jbossStructure.toURL();
                  UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
                  Unmarshaller unmarshaller = factory.newUnmarshaller();
                  StructureMetaDataObjectFactory ofactory = new StructureMetaDataObjectFactory();
                  unmarshaller.unmarshal(url.toString(), ofactory, structureContext.getMetaData());
                  isJBossStructure = true;
View Full Code Here

   }

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

         // the WEB-INF
         VirtualFile webinf = null;

         if (isLeaf(file) == false)
         {
            // We require either a WEB-INF or the name ends in .war
            if (file.getName().endsWith(".war") == false)
            {
               try
               {
                  webinf = file.getChild("WEB-INF");
                  if (webinf != null)
                  {
                     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;
                  }
               }
               catch (IOException e)
               {
                  log.warn("Exception while checking if file is a war: " + e);
                  return false;
               }
            }
            else if (trace)
            {
               log.trace("... ok - name ends in .war.");
            }

            List<String> metaDataLocations = new ArrayList<String>();
            metaDataLocations.add("WEB-INF");

            // Check for WEB-INF/classes
            VirtualFile classes = null;
            try
            {
               // The classpath contains WEB-INF/classes
               classes = file.getChild("WEB-INF/classes");

               // Check for a META-INF for metadata
               if (classes != null)
                  metaDataLocations.add("WEB-INF/classes/META-INF");
            }
            catch(IOException e)
            {
               log.warn("Exception while looking for classes, " + file.getPathName() + ", " + e);
            }

            // Check for jars in WEB-INF/lib
            List<VirtualFile> archives = null;
            try
            {
               VirtualFile webinfLib = file.getChild("WEB-INF/lib");
               if (webinfLib != null)
               {
                  archives = webinfLib.getChildren(webInfLibFilter);
                  // Add the jars' META-INF for metadata
                  for (VirtualFile jar : archives)
                  {
                     // either same as plain lib filter, null or accepts the jar
                     if (webInfLibMetaDataFilter == null || webInfLibMetaDataFilter == webInfLibFilter || webInfLibMetaDataFilter.accepts(jar))
View Full Code Here

   {
      log.trace("Root url: " + url);

      // try cache first, it should also have proper depth
      VFSRegistry registry = VFSRegistry.getInstance();
      VirtualFile vf = registry.getFile(url);
      int depth = parentDepth;
      while (vf != null && depth > 0)
      {
         vf = vf.getParent();
         depth--;
      }
      if (vf != null)
         return vf;

      String urlString = url.toExternalForm();
      int p = urlString.indexOf(":");
      String file = urlString.substring(p + 1);
      URL vfsurl = null;
      String relative;
      File fp = new File(file);

      log.trace("File: " + fp);

      if (fp.exists())
      {
         vfsurl = fp.getParentFile().toURL();
         relative = fp.getName();
      }
      else
      {
         File curr = fp;
         relative = fp.getName();
         while ((curr = curr.getParentFile()) != null)
         {
            if (curr.exists())
            {
               vfsurl = curr.toURL();
               break;
            }
            else
            {
               relative = curr.getName() + "/" + relative;
            }
         }
      }

      log.trace("URL: " + vfsurl + ", relative: " + relative);

      // no sense in checking cache, we already did that
      VirtualFile top = VFS.createNewRoot(vfsurl);
      top = top.getChild(relative);
      while (parentDepth > 0)
      {
         if (top == null)
            throw new IllegalArgumentException("Null parent: " + vfsurl + ", relative: " + relative);
         top = top.getParent();
         parentDepth--;
      }

      log.trace("Top: " + top);
View Full Code Here

         {
            Enumeration<URL> urlEnum = getDeploymentStrategy().getClassLoader().getResources(resourceName);
            while (urlEnum.hasMoreElements())
            {
               URL url = urlEnum.nextElement();
               VirtualFile root = getRoot(url, resourceName.lastIndexOf('/') > 0 ? 2 : 1);
               if (root != null)
                  handleRoot(root);
               else
                  log.trace("Null root: " + url);
            }
View Full Code Here

   protected VirtualFile getRoot(URL url, int parentDepth) throws IOException
   {
      log.trace("Root url: " + url);

      // get the cached file directly, as we expect it to already be there
      VirtualFile top = VFS.getRoot(url);
      while (parentDepth > 0)
      {
         if (top == null)
            throw new IllegalArgumentException("Null parent: " + url + ", there might be no matching VFSContext in VFSCache.");
         top = top.getParent();
         parentDepth--;
      }

      log.trace("Top: " + top);
View Full Code Here

TOP

Related Classes of org.jboss.virtual.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.