Search in sources :

Example 1 with ClassUtils

use of org.drools.core.util.ClassUtils in project drools by kiegroup.

the class KieContainerImpl method reinitModifiedClasses.

private Collection<Class<?>> reinitModifiedClasses(InternalKieModule newKM, List<String> modifiedClasses, ClassLoader classLoader, boolean modifyingUsedClass) {
    if (modifiedClasses.isEmpty() || !(classLoader instanceof ProjectClassLoader)) {
        return Collections.emptyList();
    }
    Set<String> reloadedClasses = new HashSet<>(modifiedClasses);
    ProjectClassLoader projectClassLoader = (ProjectClassLoader) classLoader;
    projectClassLoader.clearStore();
    if (modifyingUsedClass) {
        reloadedClasses.addAll(projectClassLoader.reinitTypes().stream().map(ClassUtils::convertClassToResourcePath).collect(toList()));
    }
    List<Class<?>> classes = new ArrayList<Class<?>>();
    for (String resourceName : reloadedClasses) {
        String className = convertResourceToClassName(resourceName);
        byte[] bytes = newKM.getBytes(resourceName);
        if (bytes != null) {
            Class<?> clazz = projectClassLoader.defineClass(className, resourceName, bytes);
            classes.add(clazz);
        }
    }
    return classes;
}
Also used : ProjectClassLoader(org.drools.wiring.api.classloader.ProjectClassLoader) ArrayList(java.util.ArrayList) ClassUtils(org.drools.core.util.ClassUtils) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ClassUtils (org.drools.core.util.ClassUtils)1 ProjectClassLoader (org.drools.wiring.api.classloader.ProjectClassLoader)1