use of org.opennms.netmgt.config.scriptd.StartScript in project opennms by OpenNMS.
the class Executor method start.
public synchronized void start() {
for (final Engine engine : m_config.getEngines()) {
LOG.debug("Registering engine: {}", engine.getLanguage());
String[] extensions = null;
if (engine.getExtensions().isPresent()) {
StringTokenizer st = new StringTokenizer(engine.getExtensions().get());
extensions = new String[st.countTokens()];
int j = 0;
while (st.hasMoreTokens()) {
extensions[j++] = st.nextToken();
}
}
BSFManager.registerScriptingEngine(engine.getLanguage(), engine.getClassName(), extensions);
}
m_scriptManager = new BSFManager();
m_scriptManager.registerBean("log", LOG);
// Run all start scripts
for (final StartScript startScript : m_config.getStartScripts()) {
if (startScript.getContent().isPresent()) {
try {
m_scriptManager.exec(startScript.getLanguage(), "", 0, 0, startScript.getContent().get());
} catch (BSFException e) {
LOG.error("Start script failed: " + startScript, e);
}
} else {
LOG.warn("Start script has no script content: " + startScript);
}
}
// Start the thread pool
m_executorService = Executors.newFixedThreadPool(1, new LogPreservingThreadFactory("Scriptd-Executor", 1));
// started
try {
m_broadcastEventProcessor = new BroadcastEventProcessor(this);
} catch (Throwable e) {
LOG.error("Failed to setup event reader", e);
throw new UndeclaredThrowableException(e);
}
LOG.debug("Scriptd executor started");
}
Aggregations