use of org.drools.core.common.ProjectClassLoader in project drools by kiegroup.
the class CanonicalKieModule method createKieBase.
@Override
public InternalKnowledgeBase createKieBase(KieBaseModelImpl kBaseModel, KieProject kieProject, ResultsImpl messages, KieBaseConfiguration conf) {
this.moduleClassLoader = ((ProjectClassLoader) kieProject.getClassLoader());
KieBaseConfiguration kBaseConf = getKieBaseConfiguration(kBaseModel, moduleClassLoader, conf);
CanonicalKiePackages kpkgs = pkgsInKbase.computeIfAbsent(kBaseModel.getName(), k -> createKiePackages(kBaseModel, kBaseConf));
return new KieBaseBuilder(kBaseModel, kBaseConf).createKieBase(kpkgs);
}
use of org.drools.core.common.ProjectClassLoader in project drools by kiegroup.
the class ScenarioRunner4JUnitTest method setUp.
@Before
public void setUp() throws Exception {
ksession = mock(StatefulKnowledgeSessionImpl.class);
KnowledgeBaseImpl knowledgeBase = mock(KnowledgeBaseImpl.class);
when(ksession.getKieBase()).thenReturn(knowledgeBase);
ProjectClassLoader classLoader = ProjectClassLoader.createProjectClassLoader();
when(knowledgeBase.getRootClassLoader()).thenReturn(classLoader);
}
use of org.drools.core.common.ProjectClassLoader in project drools by kiegroup.
the class ScenarioRunnerTest method setUp.
@Before
public void setUp() throws Exception {
ksession = mock(KieSession.class);
KnowledgeBaseImpl knowledgeBase = mock(KnowledgeBaseImpl.class);
when(ksession.getKieBase()).thenReturn(knowledgeBase);
ProjectClassLoader classLoader = ProjectClassLoader.createProjectClassLoader();
when(knowledgeBase.getRootClassLoader()).thenReturn(classLoader);
}
use of org.drools.core.common.ProjectClassLoader in project drools by kiegroup.
the class PersisterHelper method loadStrategiesIndex.
private static void loadStrategiesIndex(MarshallerReaderContext context, ProtobufMessages.Header _header) throws IOException, ClassNotFoundException {
for (ProtobufMessages.Header.StrategyIndex _entry : _header.getStrategyList()) {
ObjectMarshallingStrategy strategyObject = context.resolverStrategyFactory.getStrategyObject(_entry.getName());
if (strategyObject == null) {
throw new IllegalStateException("No strategy of type " + _entry.getName() + " available.");
}
context.usedStrategies.put(_entry.getId(), strategyObject);
Context ctx = strategyObject.createContext();
context.strategyContexts.put(strategyObject, ctx);
if (_entry.hasData() && ctx != null) {
ClassLoader classLoader = null;
if (context.classLoader != null) {
classLoader = context.classLoader;
} else if (context.kBase != null) {
classLoader = context.kBase.getRootClassLoader();
}
if (classLoader instanceof ProjectClassLoader) {
readRuntimeDefinedClasses(_header, (ProjectClassLoader) classLoader);
}
ctx.read(new DroolsObjectInputStream(_entry.getData().newInput(), classLoader));
}
}
}
use of org.drools.core.common.ProjectClassLoader in project drools by kiegroup.
the class StandaloneTest method init.
@Before
public void init() {
ProjectClassLoader loader = ProjectClassLoader.createProjectClassLoader();
factory = new StandaloneTraitFactory(loader);
}
Aggregations