List of usage examples for com.google.common.eventbus EventBus post
public void post(Object event)
From source file:tech.codemaster.bat50question.guava.EventBusExample.java
public static void main(String... args) { EventBus eventBus = new EventBus(); eventBus.register(new EventBusChangeRecorder()); eventBus.post("tomdeng"); }
From source file:org.apache.niolex.common.guava.GuavaEvent.java
public static void changeCustomer(EventBus eventBus) { ChangeEvent event = getChangeEvent(); eventBus.post(event); }
From source file:com.gwtplatform.dispatch.rest.rebind.events.RegisterSerializableTypeEvent.java
public static void post(EventBus eventBus, JType type) { RegisterSerializableTypeEvent event = new RegisterSerializableTypeEvent(type); eventBus.post(event); }
From source file:com.gwtplatform.dispatch.rest.rebind.events.RegisterMetadataEvent.java
public static void post(EventBus eventBus, String actionClass, MetadataType metadataType, String metadata) { RegisterMetadataEvent event = new RegisterMetadataEvent(actionClass, metadataType, metadata); eventBus.post(event); }
From source file:com.gwtplatform.dispatch.rest.rebind.events.RegisterGinBindingEvent.java
public static void post(EventBus eventBus, ClassDefinition definition, ClassDefinition implementation) { RegisterGinBindingEvent event = new RegisterGinBindingEvent(definition, implementation, false); eventBus.post(event); }
From source file:com.gwtplatform.dispatch.rest.rebind.events.RegisterGinBindingEvent.java
public static void postSingleton(EventBus eventBus, ClassDefinition definition, ClassDefinition implementation) { RegisterGinBindingEvent event = new RegisterGinBindingEvent(definition, implementation, true); eventBus.post(event); }
From source file:net.sourceforge.fullsync.cli.Main.java
public static void startup(String[] args, Launcher launcher) throws Exception { initOptions();/*w ww . j a va2s .c om*/ String configDir = getConfigDir(); CommandLineParser parser = new DefaultParser(); CommandLine line = null; try { line = parser.parse(options, args); } catch (ParseException ex) { System.err.println(ex.getMessage()); printHelp(); System.exit(1); } if (line.hasOption('V')) { System.out.println(String.format("FullSync version %s", Util.getFullSyncVersion())); //$NON-NLS-1$ System.exit(0); } // Apply modifying options if (!line.hasOption("v")) { //$NON-NLS-1$ System.setErr(new PrintStream(new FileOutputStream(getLogFileName()))); } if (line.hasOption("h")) { //$NON-NLS-1$ printHelp(); System.exit(0); } upgradeLegacyPreferencesLocation(configDir); String profilesFile; if (line.hasOption("P")) { //$NON-NLS-1$ profilesFile = line.getOptionValue("P"); //$NON-NLS-1$ } else { profilesFile = configDir + FullSync.PROFILES_XML; upgradeLegacyProfilesXmlLocation(profilesFile); } final String prefrencesFile = configDir + FullSync.PREFERENCES_PROPERTIES; final Injector injector = Guice.createInjector(new FullSyncModule(line, prefrencesFile)); final RuntimeConfiguration rtConfig = injector.getInstance(RuntimeConfiguration.class); injector.getInstance(ProfileManager.class).setProfilesFileName(profilesFile); final ScheduledExecutorService scheduledExecutorService = injector .getInstance(ScheduledExecutorService.class); final EventListener deadEventListener = new EventListener() { private final Logger logger = LoggerFactory.getLogger("DeadEventLogger"); //$NON-NLS-1$ @Subscribe private void onDeadEvent(DeadEvent deadEvent) { if (!(deadEvent.getEvent() instanceof ShutdownEvent)) { logger.warn("Dead event triggered: {}", deadEvent); //$NON-NLS-1$ } } }; final EventBus eventBus = injector.getInstance(EventBus.class); eventBus.register(deadEventListener); final Semaphore sem = new Semaphore(0); Runtime.getRuntime().addShutdownHook(new Thread(() -> { Logger logger = LoggerFactory.getLogger(Main.class); logger.debug("shutdown hook called, starting orderly shutdown"); //$NON-NLS-1$ eventBus.post(new ShutdownEvent()); scheduledExecutorService.shutdown(); try { scheduledExecutorService.awaitTermination(5, TimeUnit.MINUTES); } catch (InterruptedException e) { // not relevant } logger.debug("shutdown hook finished, releaseing main thread semaphore"); //$NON-NLS-1$ sem.release(); })); if (rtConfig.isDaemon().orElse(false).booleanValue() || rtConfig.getProfileToRun().isPresent()) { finishStartup(injector); sem.acquireUninterruptibly(); System.exit(0); } else { launcher.launchGui(injector); System.exit(0); } }
From source file:convcao.com.agent.test.AcousticReplay.java
/** * Just for testing purposes. This method will start broadcasting all messages in the log according to time * separations./* w ww. j a v a 2s . c om*/ * * @param timeMultiplier If 1.0 is used, the separation between messages will be approximately the same as * real-time. If this value is higher, the replay will be done faster in the same proportion. */ public static void replay(LsfIndex index, Object listener) { EventBus bus = new EventBus(); bus.register(listener); int numMessages = index.getNumberOfMessages(); int generatorSrcId = index.getMessage(0).getHeader().getInteger("src"); long localStartTime = System.currentTimeMillis(); long lastPrint = 0; TimeZone tz = TimeZone.getTimeZone("UTC"); DateFormat dfGMT = DateFormat.getTimeInstance(DateFormat.DEFAULT); dfGMT.setTimeZone(tz); for (int i = 0; i < numMessages - 1; i++) { long curTime = ((long) (1000.0 * (index.timeOf(i) - index.getStartTime()))) + localStartTime; long sleep_millis = curTime - System.currentTimeMillis(); IMCMessage m = index.getMessage(i); bus.post(m); //transport.sendMessage("127.0.0.1", 6002, m); int src = m.getHeader().getInteger("src"); if (src == generatorSrcId && sleep_millis > 5 && index.timeOf(i + 1) > index.timeOf(i)) { try { Thread.sleep(sleep_millis); } catch (Exception e) { e.printStackTrace(); } } long time = 1000 * (long) index.timeOf(i); if (src == generatorSrcId && time > lastPrint) { System.out.println(dfGMT.format(new Date(time))); lastPrint = time; } } bus.unregister(listener); }
From source file:org.jbr.commons.service.ServiceUtilsSupport.java
protected void postEvent(final ServiceEvent event, final EventBus eventBus) { if (eventBus != null) { eventBus.post(event); }//w w w .j a v a2s . com }
From source file:com.mycollab.vaadin.web.ui.service.AbstractBroadcastReceiverService.java
@Override public void broadcast(BroadcastMessage message) { if (message.getWrapObj() instanceof AbstractNotification) { EventBus eventBus = (EventBus) myCollabApp.getAttribute(EVENT_BUS_VAL); eventBus.post(new ShellEvent.NewNotification(this, message.getWrapObj())); CacheService cacheService = AppContextUtil.getSpringBean(CacheService.class); if (message.getsAccountId() != null) { cacheService.putValue(message.getsAccountId() + "", "notification", message.getWrapObj()); }// w w w . j a va 2s . c o m } else { onBroadcast(message); } }