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());
}
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();
}
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;
}
Aggregations