Package net.sourceforge.javautil.common.io

Examples of net.sourceforge.javautil.common.io.IVirtualDirectory


   * @param clazz The clazz
   * @return A resource wrapper for accessing the origin of the class
   */
  public static ClassLoaderResource getClassResource (Class clazz) {
    URL url = clazz.getResource("/" + ClassNameUtil.toRelativeClassPath(clazz.getName()));
    IVirtualDirectory archive = createFor(url, ClassNameUtil.toRelativeClassPath(clazz.getName()));
    return new ClassLoaderResource(clazz.getClassLoader(), new SimplePath(ClassNameUtil.toRelativeClassPath(clazz.getName())), archive);
  }
View Full Code Here


   * @return A resource wrapper for accessing the origin of the resource, or null if no resource could be found
   */
  public static ClassLoaderResource getResource (String name) {
    URL url = Thread.currentThread().getContextClassLoader().getResource(name);
    if (url == null) return null;
    IVirtualDirectory archive = createFor(url, name);
    return new ClassLoaderResource(Thread.currentThread().getContextClassLoader(), new SimplePath(name), archive);
  }
View Full Code Here

  protected <T extends IVirtualArtifact> T resolve (Class<T> type, Directory directory) {
    List<LinkedDirectory> roots = directory.getLinkedRoots();
    if (type == ILinkedArtifact.class && roots.size() > 0) {
      return (T) roots.get(0);
    } else if (ISystemArtifact.class.isAssignableFrom(type) && roots.size() > 0) {
      IVirtualDirectory search = null;
      for (LinkedDirectory root : roots) {
        search = root.getDelegate();
        while (true) {
          if (search instanceof Directory) {
            return this.resolve(type, (Directory) search);
          } else if (search instanceof LinkedDirectory) {
            search = ((LinkedDirectory)search).getDelegate();
          } else
            break;
        }
        if (type.isAssignableFrom(search.getClass())) return (T) search;
      }
    }
    return null;
  }
View Full Code Here

    return sd != null ? sd.getURL() : this.createURL();
  }
 
  protected SystemDirectory getFirst (Directory<?> directory) {
    for (LinkedDirectory root : directory.getLinkedRoots()) {
      IVirtualDirectory dir = root.unwrap(SystemDirectory.class);
      if (dir instanceof SystemDirectory) {
        return (SystemDirectory) dir;
      } else if (dir instanceof Directory) {
        SystemDirectory sys = this.getFirst((Directory)dir);
        if (sys != null) return sys;
View Full Code Here

    this.scan();
    for (String name : this.files) {
      this.getFile(name).copy(directory);
    }
    for (String subdir : this.directories) {
      IVirtualDirectory newdir = directory.getDirectory(subdir);
      if (newdir == null) newdir = directory.createDirectory(subdir);
      ((ZippedDirectoryAbstract)this.getDirectory(subdir)).decompress(newdir);
    }
  }
View Full Code Here

  /**
   * This will initialize the class loader.
   */
  protected void initialize () {
    IVirtualDirectory webInf = this.ctx.getApplication().getRoot().getDirectory("WEB-INF");
   
    if (webInf != null) {
      IVirtualDirectory classes = webInf.getDirectory("classes");
      if (classes != null) this.nonPackageResources.add( new VirtualDirectoryClassSource(classes) );
     
      IVirtualDirectory lib = webInf.getDirectory("lib");
      if (lib != null) this.nonPackageResources.add(new LibDirectoryClassSource(lib, false));
    }
  }
View Full Code Here

* @version $Id: WebApplicationDeploymentPatternWAR.java 2316 2010-06-21 04:44:57Z ponderator $
*/
public class WebApplicationDeploymentPatternWAR implements IVirtualArtifactDeploymentPattern<IVirtualDirectory,WebApplicationDeployment<IVirtualDirectory>,WebApplicationDeployer> {
 
  public WebApplicationDeployment<IVirtualDirectory> createDeployment(WebApplicationDeployer deployer, IVirtualArtifact artifact) {
    IVirtualDirectory war = null;
    if (artifact instanceof SystemFile && "war".equals( ((IVirtualFile)artifact).getExtension() )) {
      war = new ZippedDirectory( (SystemFile) artifact );
    } else if (artifact instanceof IVirtualDirectory && artifact.getName().endsWith(".war")) {
      war = (IVirtualDirectory) artifact;
    } else {
View Full Code Here

    this.server = server;
    this.add(new WebApplicationDeploymentPatternWAR());
  }

  public WebApplicationDeployment<IVirtualDirectory> deploy(IVirtualArtifactDeploymentContext<IVirtualDirectory, WebApplicationDeployment<IVirtualDirectory>> ctx) {
    IVirtualDirectory artifact = ctx.getDeployment();
    WebApplicationDeployment<IVirtualDirectory> depl = this.createDeployment(artifact);
   
    ClassLoader original = Thread.currentThread().getContextClassLoader();
    try {
      Thread.currentThread().setContextClassLoader(this.deploymentClassLoader);

      WebApplicationServerDescriptor wsd = WebApplicationServerDescriptor.get(depl.getDeploymentStructure());
     
      String path = wsd == null ? artifact.getName().split(".war")[0] : wsd.getContextPath();
      if (!path.startsWith("/")) path = "/" + path;
     
      WebApplicationStandard application = new WebApplicationStandard(artifact.getName(), path, depl.getDeploymentStructure());
      application.setReloadable( !depl.getDeploymentStructure().isReadOnly() );
      if (wsd != null) application.addAuxilaryDescriptor(wsd);
     
      application.addAuxilaryDescriptor(artifact);
      application.addAuxilaryDescriptor(depl.getDeploymentStructure());
View Full Code Here

    return false;
  }
 
  @Override public void cacheRemoteDescriptor(IClassPackageRepositoryRemote remote, IClassPackageDescriptor descriptor) {
    try {
      IVirtualDirectory packageDir = directory.getDirectory(this.createPackagePath(descriptor), true);

      String prefix = this.createFilenamePrefix(descriptor);
     
      IVirtualFile imported = packageDir.getFile(remote.getName().replaceAll("[:/]+", "-") + "remote-" + prefix + ".pom", true);
      ((ProjectObjectModel) descriptor).write(imported.getOutputStream());
    } catch (VirtualArtifactNotFoundException e) {
      throw new ClassPackageException(descriptor, "Could not import remote descriptor", e);
    } catch (IOException e) {
      throw new ClassPackageException(descriptor, "Could not import remote descriptor", e);
View Full Code Here

      throw new ClassPackageException(descriptor, "Could not import remote descriptor", e);
    }
  }
 
  @Override public IClassPackageDescriptor getCachedRemotedDescriptor(IClassPackageResolver resolver, IClassPackageRepositoryRemote remote, IClassPackageReference reference) {
    IVirtualDirectory packageDir = directory.getDirectory(this.createPackagePath(reference), true);

    String prefix = this.createFilenamePrefix(reference);
   
    IVirtualFile cache = packageDir.getFile( remote.getName().replaceAll("[:/ ]+", "-") + "remote-" + prefix + ".pom" );
   
    ProjectObjectModel pom = cache == null ? null : ProjectObjectModel.parse(resolver, cache);
   
    return pom;
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.javautil.common.io.IVirtualDirectory

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.