本文整理匯總了Java中com.google.common.eventbus.EventBus類的典型用法代碼示例。如果您正苦於以下問題:Java EventBus類的具體用法?Java EventBus怎麽用?Java EventBus使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EventBus類屬於com.google.common.eventbus包,在下文中一共展示了EventBus類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configure
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Override
protected void configure() {
bind(EventBus.class).toInstance(new EventBus((exception, context) -> {
exceptionOccurred = true;
exception.printStackTrace();
}));
bind(CommandStack.class).in(Singleton.class);
bind(TimelineModel.class).in(Singleton.class);
bind(SceneModel.class).in(Singleton.class);
bind(PropertyModel.class).in(Singleton.class);
bind(InterpolatorListModel.class).in(Singleton.class);
bind(MenuActionHandler.class).asEagerSingleton();
bind(PropertyEditHandler.class).asEagerSingleton();
bind(TimelineHandler.class).asEagerSingleton();
bind(TimelineSceneSynchronizer.class).asEagerSingleton();
bind(ScenePropertySynchronizer.class).asEagerSingleton();
bind(SelectionDragHandler.class).asEagerSingleton();
bind(FileChooserComponent.class).toInstance(Mockito.mock(FileChooserComponent.class));
bind(PanningHelper.class).toInstance(Mockito.mock(PanningHelper.class));
bind(SaveDialogComponent.class).toInstance(Mockito.mock(SaveDialogComponent.class));
}
示例2: onPullMicroserviceVersionsInstancesEvent
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Test
public void onPullMicroserviceVersionsInstancesEvent(@Injectable ServiceRegistryConfig config,
@Injectable MicroserviceDefinition definition, @Mocked MicroserviceVersions microserviceVersions) {
PullMicroserviceVersionsInstancesEvent event = new PullMicroserviceVersionsInstancesEvent(microserviceVersions, 1);
ScheduledThreadPoolExecutor taskPool = new MockUp<ScheduledThreadPoolExecutor>() {
@Mock
ScheduledFuture<?> schedule(Runnable command,
long delay,
TimeUnit unit) {
Assert.assertEquals(1, delay);
throw new Error("ok");
}
}.getMockInstance();
expectedException.expect(Error.class);
expectedException.expectMessage(Matchers.is("ok"));
EventBus bus = new EventBus();
RemoteServiceRegistry remote = new TestingRemoteServiceRegistry(bus, config, definition);
bus.register(remote);
Deencapsulation.setField(remote, "taskPool", taskPool);
bus.post(event);
}
示例3: setup
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Before
public void setup() {
eventBus = new EventBus();
taskList = new ArrayList<>();
eventBus.register(new Object() {
@Subscribe
public void onEvent(MicroserviceInstanceRegisterTask task) {
taskList.add(task);
}
});
microservice = new Microservice();
microservice.setAppId("app");
microservice.setServiceName("ms");
microservice.setServiceId("serviceId");
microservice.setInstance(new MicroserviceInstance());
HealthCheck healthCheck = new HealthCheck();
healthCheck.setMode(HealthCheckMode.HEARTBEAT);
microservice.getInstance().setHealthCheck(healthCheck);
}
開發者ID:apache,項目名稱:incubator-servicecomb-java-chassis,代碼行數:24,代碼來源:TestMicroserviceInstanceRegisterTask.java
示例4: setup
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Before
public void setup() {
eventBus = new EventBus();
taskList = new ArrayList<>();
eventBus.register(new Object() {
@Subscribe
public void onEvent(MicroserviceRegisterTask task) {
taskList.add(task);
}
});
microservice = new Microservice();
microservice.setAppId("app");
microservice.setServiceName("ms");
microservice.setInstance(new MicroserviceInstance());
}
示例5: setUp
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Before
public void setUp() {
Injector injector = Guice.createInjector(new EventTestModule());
eventBus = injector.getInstance(EventBus.class);
sceneModel = injector.getInstance(SceneModel.class);
timelineModel = injector.getInstance(TimelineModel.class);
addInterpolators(injector.getInstance(InterpolatorListModel.class));
configureMockFileChooser(injector.getInstance(FileChooserComponent.class));
configureMockSaveDialog(injector.getInstance(SaveDialogComponent.class));
KeyFrameModel keyFrame = new KeyFrameModel();
timelineModel.getKeyFrames().add(keyFrame);
timelineModel.setSelectedKeyFrame(keyFrame);
actions.remove(MenuActionEvent.EXIT);
}
示例6: AnimationEditorComponent
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Inject
public AnimationEditorComponent(MenuBarComponent menuBar, AnimationEditorPresenter presenter, TimelineEditorComponent timelineEditor,
PropertyEditorComponent propertyEditor, SceneComponent scene, PlayerComponent player, PropertyStore propertyStore,
SaveDialogComponent saveDialogComponent, EventBus eventBus) {
this.menuBar = menuBar;
this.timelineEditor = timelineEditor;
this.propertyEditor = propertyEditor;
this.scene = scene;
this.player = player;
this.propertyStore = propertyStore;
this.saveDialogComponent = saveDialogComponent;
initUi();
initPresenter(presenter);
configureDividerPosition();
subscribeToEvents(eventBus);
}
示例7: MinecraftServiceImpl
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Inject MinecraftServiceImpl(Loggers loggers,
EventBus eventBus,
SyncExecutor syncExecutor,
ServerService serverService,
MinecraftApiConfiguration apiConfiguration,
MessageQueue serverQueue,
LocalServerDocument localServerDocument,
StartupServerDocument startupDocument) {
this.logger = loggers.get(getClass());
this.eventBus = eventBus;
this.syncExecutor = syncExecutor;
this.serverService = serverService;
this.apiConfiguration = apiConfiguration;
this.serverQueue = serverQueue;
this.everfreshLocalServer = ProxyUtils.newProxy(Server.class, new MethodHandleInvoker() {
@Override
protected Object targetFor(Method method) {
if(server != null) return server;
if(Methods.respondsTo(localServerDocument, method)) return localServerDocument;
throw new ApiNotConnected();
}
});
this.startupDocument = startupDocument;
}
示例8: start
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Override
public void start(Stage stage) {
Injector injector = Guice.createInjector(new GlobalModule());
FilePersistence filePersistence = injector.getInstance(FilePersistence.class);
EventBus eventBus = injector.getInstance(EventBus.class);
injector.getInstance(FileChooserComponent.class).setOwner(stage);
Scene scene = new Scene(injector.getInstance(AnimationEditorComponent.class).getRoot(), INITIAL_WIDTH, INITIAL_HEIGHT);
scene.getStylesheets().add(getClass().getResource(STYLESHEET).toExternalForm());
stage.setScene(scene);
if (OsHelper.isWindows()) {
stage.getIcons().add(new Image(getClass().getResource(ICON).toExternalForm()));
}
stage.titleProperty().bind(filePersistence.getTitle());
stage.setOnCloseRequest(event -> {
eventBus.post(MenuActionEvent.EXIT);
event.consume();
});
injector.getInstance(StageConfigurer.class).initialize(stage);
stage.setOpacity(0);
stage.show();
eventBus.post(LifecycleEvent.STAGE_ABOUT_TO_SHOW);
Platform.runLater(() -> {
stage.setOpacity(1);
if (filePersistence.loadLastEditedFileIfExists()) {
injector.getInstance(PanningHelper.class).panToContent();
}
});
}
示例9: testFLUME1854
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Test
public void testFLUME1854() throws Exception {
File configFile = new File(baseDir, "flume-conf.properties");
Files.copy(new File(getClass().getClassLoader()
.getResource("flume-conf.properties").getFile()), configFile);
Random random = new Random();
for (int i = 0; i < 3; i++) {
EventBus eventBus = new EventBus("test-event-bus");
PollingPropertiesFileConfigurationProvider configurationProvider =
new PollingPropertiesFileConfigurationProvider("host1",
configFile, eventBus, 1);
List<LifecycleAware> components = Lists.newArrayList();
components.add(configurationProvider);
Application application = new Application(components);
eventBus.register(application);
application.start();
Thread.sleep(random.nextInt(10000));
application.stop();
}
}
示例10: setUp
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Before
public void setUp() throws Exception {
baseDir = Files.createTempDir();
configFile = new File(baseDir, TESTFILE.getName());
Files.copy(TESTFILE, configFile);
eventBus = new EventBus("test");
provider =
new PollingPropertiesFileConfigurationProvider("host1",
configFile, eventBus, 1);
provider.start();
LifecycleController.waitForOneOf(provider, LifecycleState.START_OR_ERROR);
}
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:16,代碼來源:TestPollingPropertiesFileConfigurationProvider.java
示例11: testAnonymous
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
public void testAnonymous() {
final AtomicReference<String> holder = new AtomicReference<String>();
final AtomicInteger deliveries = new AtomicInteger();
EventBus bus = new EventBus();
bus.register(new Object() {
@Subscribe
public void accept(String str) {
holder.set(str);
deliveries.incrementAndGet();
}
});
String EVENT = "Hello!";
bus.post(EVENT);
assertEquals("Only one event should be delivered.", 1, deliveries.get());
assertEquals("Correct string should be delivered.", EVENT, holder.get());
}
示例12: LoadController
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
public LoadController(Loader loader)
{
this.loader = loader;
this.masterChannel = new EventBus(new SubscriberExceptionHandler()
{
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context)
{
FMLLog.log("FMLMainChannel", Level.ERROR, exception, "Could not dispatch event: %s to %s", context.getEvent(), context.getSubscriberMethod());
}
});
this.masterChannel.register(this);
state = LoaderState.NOINIT;
packageOwners = ArrayListMultimap.create();
}
示例13: registerBus
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
@Override
public boolean registerBus(EventBus bus, LoadController controller)
{
if (this.enabled)
{
FMLLog.log(getModId(), Level.DEBUG, "Enabling mod %s", getModId());
this.eventBus = bus;
this.controller = controller;
eventBus.register(this);
return true;
}
else
{
return false;
}
}
示例14: AbstractServiceRegistry
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
public AbstractServiceRegistry(EventBus eventBus, ServiceRegistryConfig serviceRegistryConfig,
MicroserviceDefinition microserviceDefinition) {
this.eventBus = eventBus;
this.serviceRegistryConfig = serviceRegistryConfig;
this.microserviceDefinition = microserviceDefinition;
this.microservice = microserviceFactory.create(microserviceDefinition);
}
示例15: createLocal
import com.google.common.eventbus.EventBus; //導入依賴的package包/類
public static ServiceRegistry createLocal() {
EventBus eventBus = new EventBus();
ServiceRegistryConfig serviceRegistryConfig = ServiceRegistryConfig.INSTANCE;
MicroserviceConfigLoader loader = new MicroserviceConfigLoader();
loader.loadAndSort();
MicroserviceDefinition microserviceDefinition = new MicroserviceDefinition(loader.getConfigModels());
return new LocalServiceRegistry(eventBus, serviceRegistryConfig, microserviceDefinition);
}