use of org.drools.core.common.ProjectClassLoader in project jbpm by kiegroup.
the class ObjectDataType method getXStream.
private XStream getXStream() {
XStream xstream = createXStream();
if (classLoader != null) {
xstream.setClassLoader(classLoader);
if (classLoader instanceof ProjectClassLoader) {
Map<String, byte[]> store = ((ProjectClassLoader) classLoader).getStore();
if (store != null) {
String[] classes = store.keySet().stream().map(s -> s.replace('/', '.')).map(s -> s.endsWith(".class") ? s.substring(0, s.length() - ".class".length()) : s).toArray(String[]::new);
xstream.addPermission(new ExplicitTypePermission(classes));
}
}
}
return xstream;
}
use of org.drools.core.common.ProjectClassLoader in project jbpm by kiegroup.
the class KModuleDeploymentService method processClassloader.
/**
* This processes the deployment dependencies, which are made available by the {@link KieContainer} {@link ClassLoader}.
*
* @param kieContainer The {@link KieContainer}, used to get the {@link ClassLoader}
* @param deployedUnit The {@link DeployedUnitImpl}, used to store the classes loaded
*/
protected void processClassloader(KieContainer kieContainer, DeployedUnitImpl deployedUnit) {
if (kieContainer.getClassLoader() instanceof ProjectClassLoader) {
ClassLoader parentCl = kieContainer.getClassLoader().getParent();
if (parentCl instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader) parentCl).getURLs();
if (urls == null || urls.length == 0) {
return;
}
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addUrls(urls);
builder.addClassLoader(kieContainer.getClassLoader());
Reflections reflections = new Reflections(builder);
Set<Class<?>> xmlRootElemClasses = reflections.getTypesAnnotatedWith(XmlRootElement.class);
Set<Class<?>> xmlTypeClasses = reflections.getTypesAnnotatedWith(XmlType.class);
Set<Class<?>> remoteableClasses = reflections.getTypesAnnotatedWith(Remotable.class);
Set<Class<?>> allClasses = new HashSet<Class<?>>();
for (Set<Class<?>> classesToAdd : new Set[] { xmlRootElemClasses, xmlTypeClasses, remoteableClasses }) {
if (classesToAdd != null) {
allClasses.addAll(classesToAdd);
}
}
for (Class<?> clazz : allClasses) {
filterClassesAddedToDeployedUnit(deployedUnit, clazz);
}
}
}
}
Aggregations