use of org.walkmod.query.QueryEngine in project walkmod-core by walkmod.
the class ScriptProcessor method initialize.
public void initialize(VisitorContext context, Object node) {
if (engine == null) {
ScriptEngineManager factory = new ScriptEngineManager(context.getClassLoader());
engine = factory.getEngineByName(language);
if (engine instanceof GroovyScriptEngineImpl) {
((GroovyScriptEngineImpl) engine).setClassLoader(new GroovyClassLoader(context.getClassLoader(), new CompilerConfiguration()));
}
}
if (queryEngine == null) {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("language", "groovy");
List<String> includes = new LinkedList<String>();
includes.add("query.alias.groovy");
parameters.put("includes", includes);
Object bean = context.getBean("org.walkmod.query.ScriptingQueryEngine", parameters);
if (bean != null) {
if (bean instanceof QueryEngine) {
queryEngine = (QueryEngine) bean;
}
} else {
throw new WalkModException("Query Engine not found");
}
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("node", node);
queryEngine.initialize(context, params);
}
Aggregations