当前位置: 首页>>代码示例>>Java>>正文


Java EventBus类代码示例

本文整理汇总了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));
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:25,代码来源:EventTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:25,代码来源:TestRemoteServiceRegistry.java

示例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());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:19,代码来源:TestMicroserviceRegisterTask.java

示例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);
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:17,代码来源:EventTest.java

示例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);
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:18,代码来源:AnimationEditorComponent.java

示例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;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:27,代码来源:MinecraftServiceImpl.java

示例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();
        }
    });
}
 
开发者ID:rmfisher,项目名称:fx-animation-editor,代码行数:33,代码来源:AnimationEditorApp.java

示例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();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:TestApplication.java

示例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());
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:19,代码来源:OutsideEventBusTest.java

示例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();

}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:18,代码来源:LoadController.java

示例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;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:17,代码来源:FMLModContainer.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:8,代码来源:AbstractServiceRegistry.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:10,代码来源:ServiceRegistryFactory.java


注:本文中的com.google.common.eventbus.EventBus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。