use of lucee.commons.lang.ClassException 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.lang.ClassException 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());
}
use of lucee.commons.lang.ClassException 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.lang.ClassException 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);
}
}
use of lucee.commons.lang.ClassException in project Lucee by lucee.
the class Duplicator method duplicateMap.
public static Map duplicateMap(Map map, boolean deepCopy) {
Map other;
try {
other = (Map) ClassUtil.loadInstance(map.getClass());
} catch (ClassException e) {
other = new HashMap();
}
boolean inside = ThreadLocalDuplication.set(map, other);
try {
duplicateMap(map, other, deepCopy);
} finally {
if (!inside)
ThreadLocalDuplication.reset();
}
return other;
}
Aggregations