Created
October 10, 2016 14:40
-
-
Save ilgrosso/ac3e79b84f8b77ab2f08fff94c29b19f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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