Skip to content

Instantly share code, notes, and snippets.

@ilgrosso
Created October 10, 2016 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ilgrosso/ac3e79b84f8b77ab2f08fff94c29b19f to your computer and use it in GitHub Desktop.
Save ilgrosso/ac3e79b84f8b77ab2f08fff94c29b19f to your computer and use it in GitHub Desktop.
List<PullActions> actions = new ArrayList<>();
for (String className : pullTask.getActionsClassNames()) {
try {
PullActions pullActions;
if (className.indexOf('.') == -1) {
ExtensionScript script = null; // suppose to fetch it using className as key
ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
engine.eval(new InputStreamReader(script.getContent()));
pullActions = (PullActions) ApplicationContextProvider.getBeanFactory().
createBean(JSPullActions.class, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, true);
((JSPullActions) pullActions).setScriptEngine(engine);
} else {
Class<?> actionsClass = Class.forName(className);
pullActions = (PullActions) ApplicationContextProvider.getBeanFactory().
createBean(actionsClass, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, true);
}
actions.add(pullActions);
} catch (Exception e) {
LOG.warn("Class '{}' not found", className, e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment