Example usage for com.google.common.eventbus AsyncEventBus AsyncEventBus

List of usage examples for com.google.common.eventbus AsyncEventBus AsyncEventBus

Introduction

In this page you can find the example usage for com.google.common.eventbus AsyncEventBus AsyncEventBus.

Prototype

public AsyncEventBus(Executor executor) 

Source Link

Document

Creates a new AsyncEventBus that will use executor to dispatch events.

Usage

From source file:com.heliosdecompiler.helios.Helios.java

public static void main(String[] args) {
    try {//from w w  w .j  a  v  a 2s .  c  o m
        LanguageController languageController = new LanguageController(); // blehhhhhh
        Message.init(languageController);

        GraphicsProvider launcher = getGraphicsProvider().newInstance();

        launcher.startSplash();
        launcher.updateSplash(Message.STARTUP_PREPARING_ENVIRONMENT);

        Field defaultCharset = Charset.class.getDeclaredField("defaultCharset");
        defaultCharset.setAccessible(true);
        defaultCharset.set(null, StandardCharsets.UTF_8);
        if (!Charset.defaultCharset().equals(StandardCharsets.UTF_8))
            throw new RuntimeException("Charset: " + Charset.defaultCharset());
        if (!Constants.DATA_DIR.exists() && !Constants.DATA_DIR.mkdirs())
            throw new RuntimeException("Could not create data directory");
        if (!Constants.ADDONS_DIR.exists() && !Constants.ADDONS_DIR.mkdirs())
            throw new RuntimeException("Could not create addons directory");
        if (Constants.DATA_DIR.isFile())
            throw new RuntimeException("Data directory is file");
        if (Constants.ADDONS_DIR.isFile())
            throw new RuntimeException("Addons directory is file");

        EventBus eventBus = new AsyncEventBus(Executors.newCachedThreadPool());

        Configuration configuration = loadConfiguration();
        Class<? extends UserInterfaceController> uiController = getUIControllerImpl();

        Injector mainInjector = Guice.createInjector(new AbstractModule() {
            @Override
            protected void configure() {
                bind(MessageHandler.class).to(launcher.getMessageHandlerImpl());
                bind(UserInterfaceController.class).to(uiController);
                bind(Configuration.class).toInstance(configuration);
                bind(EventBus.class).toInstance(eventBus);
            }
        });

        mainInjector.getInstance(UserInterfaceController.class).initialize();

        launcher.updateSplash(Message.STARTUP_LOADING_GRAPHICS);
        launcher.prepare(mainInjector);

        launcher.updateSplash(Message.STARTUP_DONE);
        launcher.start();

        mainInjector.getInstance(PathController.class).reload();
        mainInjector.getInstance(UpdateController.class).doUpdate();
        handleCommandLine(args, mainInjector);
    } catch (Throwable t) {
        displayError(t);
        System.exit(1);
    }
}

From source file:com.kamike.watch.EventInst.java

private EventInst() {
    eventBus = new EventBus();
    asyncEventBus = new AsyncEventBus(Executors.newFixedThreadPool(5));
}

From source file:com.notes.listen.EventInst.java

private EventInst() {
    eventBus = new EventBus();

    asyncEventBus = new AsyncEventBus(Executors.newFixedThreadPool(50));
    asyncEventBus.register(fs);
}

From source file:org.eclipse.hawkbit.simulator.DeviceSimulator.java

/**
 * @return an asynchronous event bus to publish and retrieve events.
 *//*ww w . j  ava 2s .c  o  m*/
@Bean
public EventBus eventBus() {
    return new AsyncEventBus(Executors.newFixedThreadPool(4));
}

From source file:org.obiba.mica.config.EventBusConfiguration.java

@Bean
public EventBus eventBus() {
    return new AsyncEventBus(executor);
}

From source file:org.opendaylight.netconf.sal.streams.listeners.AbstractCommonSubscriber.java

/**
 * Creating {@link EventBus}
 */
protected AbstractCommonSubscriber() {
    this.eventBus = new AsyncEventBus(Executors.newSingleThreadExecutor());
}

From source file:org.eclipse.hawkbit.autoconfigure.eventbus.EventBusAutoConfiguration.java

/**
 * Server internal eventBus that allows parallel event processing if the
 * subscriber is marked as so./*from   w  w w  .  ja  v a2 s.com*/
 *
 * @return eventbus bean
 */
@Bean
@ConditionalOnMissingBean
public EventBus eventBus() {
    return new AsyncEventBus(executor);
}

From source file:com.dangdang.ddframe.job.event.JobEventBus.java

public JobEventBus(final JobEventConfiguration jobEventConfig) {
    this.jobEventConfig = jobEventConfig;
    executorServiceObject = new ExecutorServiceObject("job-event",
            Runtime.getRuntime().availableProcessors() * 2);
    eventBus = new AsyncEventBus(executorServiceObject.createExecutorService());
    register();// w ww  .ja  v a2  s  .  com
}

From source file:org.coinspark.wallet.CSEventBus.java

CSEventBus() {
    //   eventBus = new EventBus();
    asyncEventBus = new AsyncEventBus(executorService);
}

From source file:ch.poiuqwer.saitek.fip4j.demo.Main.java

private void run() {
    try {//from ww w.  ja  v a  2  s  .  c om
        LOGGER.info("Starting {}.", PLUGIN_NAME);
        directOutput = DirectOutputBuilder.createAndLoadDLL().eventBus(new AsyncEventBus(new ForkJoinPool()))
                .build();
        directOutput.setup(PLUGIN_NAME);
        Collection<Device> devices = directOutput.getDevices();
        directOutput.registerSubscriber(this);
        devices.forEach(this::setupDeviceForDemos);
        if (devices.isEmpty()) {
            int seconds = 0;
            LOGGER.info("Waiting 30 seconds for devices to be plugged in ...");
            while (directOutput.getDevices().isEmpty() && seconds++ < 30) {
                Thread.sleep(1000);
            }
        }
        while (numberOfDemosRunning.get() > 0) {
            Thread.sleep(1000);
        }
    } catch (Throwable t) {
        logUnexpectedError(t);
    } finally {
        directOutput.cleanup();
    }
}