Search in sources :

Example 1 with JobRegistrar

use of com.swiftmq.impl.streams.jobs.JobRegistrar in project swiftmq-ce by iitsoftware.

the class StreamsSwiftlet method startup.

protected void startup(Configuration config) throws SwiftletException {
    ctx = new SwiftletContext(config, this);
    if (!ctx.HASENGINE) {
        ctx.logSwiftlet.logInformation(ctx.streamsSwiftlet.getName(), "You are using Java " + ctx.JAVAVERSION + " but not GraalVM. Cannot start Streams Swiftlet. Please use GraalVM: https://graalvm.org");
        ctx.logSwiftlet.logWarning(ctx.streamsSwiftlet.getName(), "You are using Java " + ctx.JAVAVERSION + " but not GraalVM. Cannot start Streams Swiftlet. Please use GraalVM: https://graalvm.org");
        return;
    }
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(getName(), "startup ...");
    isStartup = true;
    ctx.logSwiftlet.logInformation(ctx.streamsSwiftlet.getName(), "starting, available Scripting Engines:");
    ScriptEngineManager manager = new ScriptEngineManager();
    List<ScriptEngineFactory> factories = manager.getEngineFactories();
    for (int i = 0; i < factories.size(); i++) {
        ctx.logSwiftlet.logInformation(ctx.streamsSwiftlet.getName(), "name=" + factories.get(i).getEngineName() + ", version=" + factories.get(i).getEngineVersion() + ", language name=" + factories.get(i).getLanguageName() + ", language version=" + factories.get(i).getLanguageVersion() + ", names=" + factories.get(i).getNames());
    }
    ctx.authenticationSwiftlet.addTopicAuthenticationDelegate(this);
    createDomainAdapter((EntityList) config.getEntity("domains"));
    try {
        startStreams((EntityList) config.getEntity("domains"));
    } catch (Exception e) {
        throw new SwiftletException(e.getMessage());
    }
    /*${evalstartupmark}*/
    jobRegistrar = new JobRegistrar(ctx);
    jobRegistrar.register();
    Property prop = ctx.root.getProperty("collect-interval");
    prop.setPropertyChangeListener(new PropertyChangeAdapter(null) {

        public void propertyChanged(Property property, Object oldValue, Object newValue) throws PropertyChangeException {
            collectInterval = ((Long) newValue).longValue();
            collectChanged(((Long) oldValue).longValue(), collectInterval);
        }
    });
    collectInterval = ((Long) prop.getValue()).longValue();
    ctx.mgmtSwiftlet.addMgmtListener(new MgmtListener() {

        public void adminToolActivated() {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(getName(), "adminToolActivated");
            collectOn = true;
            collectChanged(-1, collectInterval);
        }

        public void adminToolDeactivated() {
            if (ctx.traceSpace.enabled)
                ctx.traceSpace.trace(getName(), "adminToolDeactivated");
            collectChanged(collectInterval, -1);
            collectOn = false;
        }
    });
    try {
        streamLibDeployer = new StreamLibDeployer(ctx);
    } catch (Exception e) {
        throw new SwiftletException(e.toString());
    }
    isStartup = false;
    if (ctx.traceSpace.enabled)
        ctx.traceSpace.trace(getName(), "startup done.");
}
Also used : MgmtListener(com.swiftmq.swiftlet.mgmt.event.MgmtListener) ScriptEngineManager(javax.script.ScriptEngineManager) JobRegistrar(com.swiftmq.impl.streams.jobs.JobRegistrar) SwiftletException(com.swiftmq.swiftlet.SwiftletException) SwiftletException(com.swiftmq.swiftlet.SwiftletException) ScriptEngineFactory(javax.script.ScriptEngineFactory)

Aggregations

JobRegistrar (com.swiftmq.impl.streams.jobs.JobRegistrar)1 SwiftletException (com.swiftmq.swiftlet.SwiftletException)1 MgmtListener (com.swiftmq.swiftlet.mgmt.event.MgmtListener)1 ScriptEngineFactory (javax.script.ScriptEngineFactory)1 ScriptEngineManager (javax.script.ScriptEngineManager)1