Search in sources :

Example 11 with ResourceProvider

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

the class ConfigImpl method addResourceProvider.

protected void addResourceProvider(String strProviderScheme, ClassDefinition cd, Map arguments) throws ClassException, BundleException {
    Object o = ClassUtil.loadInstance(cd.getClazz());
    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)

Example 12 with ResourceProvider

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

the class Compress method load.

private synchronized void load(boolean caseSensitive) throws IOException {
    long actLastMod = ffile.lastModified();
    lastMod = actLastMod;
    lastCheck = System.currentTimeMillis();
    Map<String, Boolean> args = new HashMap<String, Boolean>();
    args.put("case-sensitive", Caster.toBoolean(caseSensitive));
    if (temp == null) {
        String cid = "";
        Config config = ThreadLocalPageContext.getConfig();
        if (config != null) {
            cid = config.getIdentification().getId();
            temp = config.getTempDirectory();
        }
        if (temp == null)
            temp = SystemUtil.getTempDirectory();
        temp = temp.getRealResource("compress");
        temp = temp.getRealResource(MD5.getDigestAsString(cid + "-" + ffile.getAbsolutePath()));
        if (!temp.exists())
            temp.mkdirs();
    }
    if (temp != null) {
        String name = Caster.toString(actLastMod) + ":" + Caster.toString(ffile.length());
        name = MD5.getDigestAsString(name, name);
        root = temp.getRealResource(name);
        if (actLastMod > 0 && root.exists())
            return;
        ResourceUtil.removeChildrenEL(temp);
        // if(root!=null)ResourceUtil.removeChildrenEL(root);
        // String name=CreateUUID.invoke();
        // root=temp.getRealResource(name);
        root.mkdirs();
    } else {
        ResourceProvider ramProvider = new RamResourceProviderOld().init("ram", args);
        root = ramProvider.getResource("/");
    }
    _load();
}
Also used : RamResourceProviderOld(lucee.commons.io.res.type.ram.RamResourceProviderOld) HashMap(java.util.HashMap) Config(lucee.runtime.config.Config) ResourceProvider(lucee.commons.io.res.ResourceProvider)

Example 13 with ResourceProvider

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

the class MacAddressWrap method parsePlaceHolder.

public static String parsePlaceHolder(String path, ServletContext sc) {
    ResourceProvider frp = ResourcesImpl.getFileResourceProvider();
    if (path == null)
        return null;
    if (path.indexOf('{') != -1) {
        if (StringUtil.startsWith(path, '{')) {
            // Web Root
            if (path.startsWith("{web-root")) {
                if (path.startsWith("}", 9))
                    path = frp.getResource(ReqRspUtil.getRootPath(sc)).getRealResource(path.substring(10)).toString();
                else if (path.startsWith("-dir}", 9))
                    path = frp.getResource(ReqRspUtil.getRootPath(sc)).getRealResource(path.substring(14)).toString();
                else if (path.startsWith("-directory}", 9))
                    path = frp.getResource(ReqRspUtil.getRootPath(sc)).getRealResource(path.substring(20)).toString();
            } else
                path = SystemUtil.parsePlaceHolder(path);
        }
        if ((path.indexOf("{web-context-hash}")) != -1) {
            String id = hash(sc);
            path = StringUtil.replace(path, "{web-context-hash}", id, false);
        }
    }
    return path;
}
Also used : ResourceProvider(lucee.commons.io.res.ResourceProvider)

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