
org.openl.rules.extension.instantiation.ExtensionInstantiationStrategy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.openl.rules.project Show documentation
Show all versions of org.openl.rules.project Show documentation
Classes and utilities to work with OpenL Rules Project
package org.openl.rules.extension.instantiation;
import org.apache.commons.collections4.CollectionUtils;
import org.openl.dependency.IDependencyManager;
import org.openl.rules.project.instantiation.RulesInstantiationException;
import org.openl.rules.project.instantiation.SingleModuleInstantiationStrategy;
import org.openl.rules.project.model.Extension;
import org.openl.rules.project.model.MethodFilter;
import org.openl.rules.project.model.Module;
import org.openl.rules.runtime.InterfaceClassGeneratorImpl;
import org.openl.source.IOpenSourceCodeModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ExtensionInstantiationStrategy extends SingleModuleInstantiationStrategy {
private final Logger log = LoggerFactory.getLogger(ExtensionInstantiationStrategy.class);
/**
* Rules engine factory for module that contains only Excel file.
*/
private ExtensionEngineFactory> engineFactory;
private final Extension extension;
public ExtensionInstantiationStrategy(Module module,
boolean executionMode,
IDependencyManager dependencyManager,
ClassLoader classLoader,
Extension extension) {
super(module, executionMode, dependencyManager, classLoader);
this.extension = extension;
}
@Override
public void reset() {
super.reset();
if (engineFactory != null) {
getEngineFactory().reset(false);
}
}
@Override
public void forcedReset() {
super.forcedReset();
engineFactory = null;
}
@Override
public Class> getGeneratedRulesClass() throws RulesInstantiationException {
// Service class for current implementation will be class, generated at
// runtime by factory.
// Using project class loader for interface generation.
//
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(getClassLoader());
try {
return getEngineFactory().getInterfaceClass();
} catch (Exception e) {
throw new RulesInstantiationException("Can't resolve interface.", e);
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
}
@SuppressWarnings("unchecked")
protected ExtensionEngineFactory> getEngineFactory() {
Class
© 2015 - 2025 Weber Informatics LLC | Privacy Policy