use of lucee.commons.io.res.util.WildCardFilter in project Lucee by lucee.
the class MetaData method get.
public List<String> get(String wildcard) throws IOException {
synchronized (data) {
List<String> list = new ArrayList<String>();
Iterator<Entry<String, String>> it = data.entrySet().iterator();
WildCardFilter filter = new WildCardFilter(wildcard);
Entry<String, String> entry;
String value;
while (it.hasNext()) {
entry = it.next();
value = entry.getValue();
if (filter.accept(value)) {
list.add(entry.getKey());
it.remove();
}
}
if (list.size() > 0)
JavaConverter.serialize(data, file);
return list;
}
}
use of lucee.commons.io.res.util.WildCardFilter in project Lucee by lucee.
the class JavaProxy method loadClassByPath.
private static Class<?> loadClassByPath(PageContext pc, String className, String[] paths) throws PageException {
PageContextImpl pci = (PageContextImpl) pc;
java.util.List<Resource> resources = new ArrayList<Resource>();
if (paths != null && paths.length > 0) {
// load resources
for (int i = 0; i < paths.length; i++) {
Resource res = ResourceUtil.toResourceExisting(pc, paths[i]);
if (res.isDirectory()) {
// a directory was passed, add all of the jar files from it
FileResource dir = (FileResource) res;
Resource[] jars = dir.listResources((ResourceNameFilter) new WildCardFilter("*.jar"));
for (Resource jar : jars) {
resources.add(jar);
}
} else {
resources.add(res);
}
}
// throw new FunctionException(pc, "JavaProxy", 2, "path", "argument path has to be a array of strings or a single string, where every string is defining a path");
}
// load class
try {
ClassLoader cl = resources.isEmpty() ? pci.getClassLoader() : pci.getClassLoader(resources.toArray(new Resource[resources.size()]));
Class clazz = null;
try {
clazz = ClassUtil.loadClass(cl, className);
} catch (ClassException ce) {
// try java.lang if no package definition
if (className.indexOf('.') == -1) {
try {
clazz = ClassUtil.loadClass(cl, "java.lang." + className);
} catch (ClassException e) {
throw ce;
}
} else
throw ce;
}
return clazz;
} catch (Exception e) {
throw Caster.toPageException(e);
}
}
Aggregations