Search in sources :

Example 1 with AcceptsMessageReceiver

use of io.joynr.runtime.AcceptsMessageReceiver in project joynr by bmwcarit.

the class JoynrApplicationLauncher method init.

public void init(Properties properties, Set<Class<? extends JoynrApplication>> joynrApplicationsClasses, AbstractJoynrInjectorFactory injectorFactory, Module... modules) {
    ThreadFactory threadFactory = new ThreadFactory() {

        @Override
        public Thread newThread(Runnable r) {
            return new Thread(r, r.getClass().getSimpleName());
        }
    };
    executionQueue = Executors.newCachedThreadPool(threadFactory);
    try {
        // updateInjectorModule must be called before getInjector can be called.
        // for this reason the injector has to be created here, and not by the creator of the injectorFactory
        injectorFactory.updateInjectorModule(properties, modules);
        joynrInjector = injectorFactory.getInjector();
        for (Class<? extends JoynrApplication> appClass : joynrApplicationsClasses) {
            if (Modifier.isAbstract(appClass.getModifiers())) {
                continue;
            }
            AcceptsMessageReceiver acceptsMessageReceiverAnnotation = appClass.getAnnotation(AcceptsMessageReceiver.class);
            // TODO why not reuse the previously requested value for
            // AcceptsMessageReceiver?
            MessageReceiverType messageReceiverType = acceptsMessageReceiverAnnotation == null ? MessageReceiverType.ANY : appClass.getAnnotation(AcceptsMessageReceiver.class).value();
            if (messageReceiverType.equals(MessageReceiverType.SERVLET)) {
                continue;
            }
            logger.info("Running app: " + appClass.getName());
            final JoynrApplication app = injectorFactory.createApplication(new JoynrApplicationModule(appClass));
            apps.add(app);
            executionQueue.submit(app);
        }
    } catch (RuntimeException e) {
        logger.error("ERROR", e);
        throw e;
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) AcceptsMessageReceiver(io.joynr.runtime.AcceptsMessageReceiver) JoynrApplicationModule(io.joynr.runtime.JoynrApplicationModule) MessageReceiverType(io.joynr.runtime.MessageReceiverType) JoynrApplication(io.joynr.runtime.JoynrApplication)

Aggregations

AcceptsMessageReceiver (io.joynr.runtime.AcceptsMessageReceiver)1 JoynrApplication (io.joynr.runtime.JoynrApplication)1 JoynrApplicationModule (io.joynr.runtime.JoynrApplicationModule)1 MessageReceiverType (io.joynr.runtime.MessageReceiverType)1 ThreadFactory (java.util.concurrent.ThreadFactory)1