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