Search in sources :

Example 6 with ResourceProvider

use of lucee.commons.io.res.ResourceProvider in project Lucee by lucee.

the class MacAddressWrap method getClassPathes.

/**
 * @return returns a string list of all pathes
 */
public static Resource[] getClassPathes() {
    if (classPathes != null)
        return classPathes;
    ArrayList<Resource> pathes = new ArrayList<Resource>();
    String pathSeperator = System.getProperty("path.separator");
    if (pathSeperator == null)
        pathSeperator = ";";
    // java.ext.dirs
    ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
    // paths from system properties
    String strPathes = System.getProperty("java.class.path");
    if (strPathes != null) {
        Array arr = ListUtil.listToArrayRemoveEmpty(strPathes, pathSeperator);
        int len = arr.size();
        for (int i = 1; i <= len; i++) {
            Resource file = frp.getResource(Caster.toString(arr.get(i, ""), "").trim());
            if (file.exists())
                pathes.add(ResourceUtil.getCanonicalResourceEL(file));
        }
    }
    // paths from url class Loader (dynamic loaded classes)
    ClassLoader cl = InfoImpl.class.getClassLoader();
    if (cl instanceof URLClassLoader)
        getClassPathesFromClassLoader((URLClassLoader) cl, pathes);
    return classPathes = (Resource[]) pathes.toArray(new Resource[pathes.size()]);
}
Also used : Array(lucee.runtime.type.Array) ResourceProvider(lucee.commons.io.res.ResourceProvider) URLClassLoader(java.net.URLClassLoader) Resource(lucee.commons.io.res.Resource) ArrayList(java.util.ArrayList) URLClassLoader(java.net.URLClassLoader)

Example 7 with ResourceProvider

use of lucee.commons.io.res.ResourceProvider in project Lucee by lucee.

the class CompressUtil method main.

public static void main(String[] args) throws IOException {
    ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
    Resource src = frp.getResource("/Users/mic/temp/a");
    Resource tgz = frp.getResource("/Users/mic/temp/b/a.tgz");
    tgz.getParentResource().mkdirs();
    Resource tar = frp.getResource("/Users/mic/temp/b/a.tar");
    tar.getParentResource().mkdirs();
    Resource zip = frp.getResource("/Users/mic/temp/b/a.zip");
    zip.getParentResource().mkdirs();
    Resource tgz1 = frp.getResource("/Users/mic/temp/b/tgz");
    tgz1.mkdirs();
    Resource tar1 = frp.getResource("/Users/mic/temp/b/tar");
    tar1.mkdirs();
    Resource zip1 = frp.getResource("/Users/mic/temp/b/zip");
    zip1.mkdirs();
    compressTGZ(new Resource[] { src }, tgz, -1);
    compressTar(new Resource[] { src }, tar, -1);
    compressZip(new Resource[] { src }, zip, null);
    extractTGZ(tgz, tgz1);
    extractTar(tar, tar1);
    extractZip(src, zip1);
}
Also used : ResourceProvider(lucee.commons.io.res.ResourceProvider) Resource(lucee.commons.io.res.Resource)

Example 8 with ResourceProvider

use of lucee.commons.io.res.ResourceProvider in project Lucee by lucee.

the class XMLConfigAdmin method getResourceProviders.

public Query getResourceProviders() throws PageException {
    checkReadAccess();
    // check parameters
    Element parent = _getRootElement("resources");
    Element[] elProviders = XMLConfigWebFactory.getChildren(parent, "resource-provider");
    Element[] elDefaultProviders = XMLConfigWebFactory.getChildren(parent, "default-resource-provider");
    ResourceProvider[] providers = config.getResourceProviders();
    ResourceProvider defaultProvider = config.getDefaultResourceProvider();
    Query qry = new QueryImpl(new String[] { "support", "scheme", "caseSensitive", "default", "class", "bundleName", "bundleVersion", "arguments" }, elProviders.length + elDefaultProviders.length, "resourceproviders");
    int row = 1;
    for (int i = 0; i < elDefaultProviders.length; i++) {
        getResourceProviders(new ResourceProvider[] { defaultProvider }, qry, elDefaultProviders[i], row++, Boolean.TRUE);
    }
    for (int i = 0; i < elProviders.length; i++) {
        getResourceProviders(providers, qry, elProviders[i], row++, Boolean.FALSE);
    }
    return qry;
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query) Element(org.w3c.dom.Element) ResourceProvider(lucee.commons.io.res.ResourceProvider)

Example 9 with ResourceProvider

use of lucee.commons.io.res.ResourceProvider in project Lucee by lucee.

the class ConfigImpl method setDefaultResourceProvider.

protected void setDefaultResourceProvider(Class defaultProviderClass, Map arguments) throws ClassException {
    Object o = ClassUtil.loadInstance(defaultProviderClass);
    if (o instanceof ResourceProvider) {
        ResourceProvider rp = (ResourceProvider) o;
        rp.init(null, arguments);
        setDefaultResourceProvider(rp);
    } else
        throw new ClassException("object [" + Caster.toClassName(o) + "] must implement the interface " + ResourceProvider.class.getName());
}
Also used : ResourceProvider(lucee.commons.io.res.ResourceProvider) CompressResourceProvider(lucee.commons.io.res.type.compress.CompressResourceProvider) ClassException(lucee.commons.lang.ClassException)

Example 10 with ResourceProvider

use of lucee.commons.io.res.ResourceProvider in project Lucee by lucee.

the class ConfigImpl method addResourceProvider.

protected void addResourceProvider(String strProviderScheme, Class providerClass, Map arguments) throws ClassException {
    Object o = ClassUtil.loadInstance(providerClass);
    if (o instanceof ResourceProvider) {
        ResourceProvider rp = (ResourceProvider) o;
        rp.init(strProviderScheme, arguments);
        addResourceProvider(rp);
    } else
        throw new ClassException("object [" + Caster.toClassName(o) + "] must implement the interface " + ResourceProvider.class.getName());
}
Also used : ResourceProvider(lucee.commons.io.res.ResourceProvider) CompressResourceProvider(lucee.commons.io.res.type.compress.CompressResourceProvider) ClassException(lucee.commons.lang.ClassException)

Aggregations

ResourceProvider (lucee.commons.io.res.ResourceProvider)13 Resource (lucee.commons.io.res.Resource)4 CompressResourceProvider (lucee.commons.io.res.type.compress.CompressResourceProvider)3 ClassException (lucee.commons.lang.ClassException)3 IOException (java.io.IOException)2 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ServletContext (javax.servlet.ServletContext)1 RamResourceProviderOld (lucee.commons.io.res.type.ram.RamResourceProviderOld)1 Config (lucee.runtime.config.Config)1 InfoImpl (lucee.runtime.engine.InfoImpl)1 ApplicationException (lucee.runtime.exp.ApplicationException)1 PageServletException (lucee.runtime.exp.PageServletException)1 Array (lucee.runtime.type.Array)1 Query (lucee.runtime.type.Query)1 QueryImpl (lucee.runtime.type.QueryImpl)1 Struct (lucee.runtime.type.Struct)1