Java 类com.google.common.eventbus.EventBus 实例源码

项目:fx-animation-editor    文件:EventTest.java   
@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));
}
项目:incubator-servicecomb-java-chassis    文件:TestRemoteServiceRegistry.java   
@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);
}
项目:incubator-servicecomb-java-chassis    文件:TestMicroserviceInstanceRegisterTask.java   
@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);
}
项目:incubator-servicecomb-java-chassis    文件:TestMicroserviceRegisterTask.java   
@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());
}
项目:fx-animation-editor    文件:EventTest.java   
@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);
}
项目:fx-animation-editor    文件:AnimationEditorComponent.java   
@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);
}
项目:ProjectAres    文件:MinecraftServiceImpl.java   
@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;
}
项目:fx-animation-editor    文件:AnimationEditorApp.java   
@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();
        }
    });
}
项目:flume-release-1.7.0    文件:TestApplication.java   
@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();
  }
}
项目:flume-release-1.7.0    文件:TestPollingPropertiesFileConfigurationProvider.java   
@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);
}
项目:googles-monorepo-demo    文件:OutsideEventBusTest.java   
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());
}
项目:CustomWorldGen    文件:LoadController.java   
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();

}
项目:CustomWorldGen    文件:FMLModContainer.java   
@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;
    }
}
项目:incubator-servicecomb-java-chassis    文件:AbstractServiceRegistry.java   
public AbstractServiceRegistry(EventBus eventBus, ServiceRegistryConfig serviceRegistryConfig,
    MicroserviceDefinition microserviceDefinition) {
  this.eventBus = eventBus;
  this.serviceRegistryConfig = serviceRegistryConfig;
  this.microserviceDefinition = microserviceDefinition;
  this.microservice = microserviceFactory.create(microserviceDefinition);
}
项目:incubator-servicecomb-java-chassis    文件:ServiceRegistryFactory.java   
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);
}
项目:incubator-servicecomb-java-chassis    文件:ServiceRegistryFactory.java   
public static ServiceRegistry create(EventBus eventBus, ServiceRegistryConfig serviceRegistryConfig,
    MicroserviceDefinition microserviceDefinition) {
  String localModeFile = System.getProperty(LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY);
  if (!StringUtils.isEmpty(localModeFile)) {
    LOGGER.info(
        "It is running in the local development mode, the local file {} is using as the local registry",
        localModeFile);

    return new LocalServiceRegistry(eventBus, serviceRegistryConfig, microserviceDefinition);
  }

  LOGGER.info("It is running in the normal mode, a separated service registry is required");
  return new RemoteServiceRegistry(eventBus, serviceRegistryConfig, microserviceDefinition);
}
项目:fx-animation-editor    文件:SelectionResizeHandler.java   
@Inject
public SelectionResizeHandler(CommandStack commandStack, TimelineModel timelineModel, SceneModel sceneModel, EventBus eventBus) {
    this.commandStack = commandStack;
    this.timelineModel = timelineModel;
    this.sceneModel = sceneModel;
    subscribeToEvents(eventBus);
}
项目:fx-animation-editor    文件:SelectionDragBehavior.java   
@Inject
public SelectionDragBehavior(SceneModel sceneModel, PanningComponent panningComponent, EventBus eventBus) {
    super(sceneModel);
    this.sceneModel = sceneModel;
    this.panningComponent = panningComponent;
    this.eventBus = eventBus;
}
项目:incubator-servicecomb-java-chassis    文件:ServiceCenterTask.java   
public ServiceCenterTask(EventBus eventBus, int interval,
    MicroserviceServiceCenterTask microserviceServiceCenterTask) {
  this.eventBus = eventBus;
  this.interval = interval;
  this.microserviceServiceCenterTask = microserviceServiceCenterTask;

  this.eventBus.register(this);
}
项目:incubator-servicecomb-java-chassis    文件:TestAbstractRegisterTask.java   
@Before
public void setup() {
  eventBus = new EventBus();

  microservice = new Microservice();
  microservice.setAppId("app");
  microservice.setServiceName("ms");

  microservice.setInstance(new MicroserviceInstance());
}
项目:fx-animation-editor    文件:MenuBarComponent.java   
@Inject
public MenuBarComponent(EventBus eventBus, CommandStack commandStack, PanningHelper panningHelper) {
    this.eventBus = eventBus;
    this.commandStack = commandStack;
    this.panningHelper = panningHelper;
    loadFxml();
    initUi();
    initActions();
    bindDisabledStates();
}
项目:n4js    文件:GHOLD_45_CheckIgnoreAnnotationAtClassLevel_PluginUITest.java   
private void runTestWaitResult(final IFile moduleToTest) {
    final SessionEndedEventLatch latch = new SessionEndedEventLatch();
    final EventBus eventBus = getEventBus();
    final ILaunchShortcut launchShortcut = getLaunchShortcut();
    eventBus.register(latch);
    new Thread(() -> launchShortcut.launch(new StructuredSelection(moduleToTest), ILaunchManager.RUN_MODE)).start();
    latch.startTestAndWait(5L, TimeUnit.SECONDS);
}
项目:Charrizard    文件:Charrizard.java   
public Charrizard(Settings settings) {
    this.settings = settings;
    this.eventBus = new EventBus();
    this.commandCaller = new CommandCaller(this);
    this.redisConnection = new RedisConnection(settings);
    this.cGuildManager = new CGuildManager(this);
    this.keepDataThread = new KeepDataThread(this);
}
项目:event-sourcing-cqrs-examples    文件:AccountServiceTest.java   
@Before
public void setUp() throws Exception {
    eventStore = spy(new InMemoryEventStore());
    EventBus eventBus = new EventBus();
    eventBusCounter = new EventBusCounter();
    eventBus.register(eventBusCounter);
    accountService = new AccountService(eventStore, eventBus);
}
项目:Cypher    文件:Client.java   
Client(Supplier<com.github.cypher.sdk.Client> sdkClientFactory,
              Settings settings,
              EventBus eventBus,
              String userDataDirectory) {

    this.sdkClientFactory = sdkClientFactory;
    this.settings = settings;
    this.eventBus = eventBus;
    eventBus.register(this);

    initialize();

    sessionManager = new SessionManager(userDataDirectory);

    // Loads the session file from the disk if it exists.
    if (sessionManager.savedSessionExists()) {
        Session session = sessionManager.loadSessionFromDisk();
        // If session doesn't exists SessionManager::loadSession returns null
        if (session != null) {
            // No guarantee that the session is valid. setSession doesn't throw an exception if the session is invalid.
            sdkClient.setSession(session);
            loggedIn = true;
            startNewUpdater();
        }
    }
    addListeners();
}
项目:fx-animation-editor    文件:AnimationEditorPresenter.java   
@Inject
public AnimationEditorPresenter(PropertyModel propertyModel, SceneModel sceneModel, TimelineModel timelineModel, EventBus eventBus) {
    this.propertyModel = propertyModel;
    this.sceneModel = sceneModel;
    this.timelineModel = timelineModel;
    this.eventBus = eventBus;
}
项目:guava-mock    文件:AnnotatedSubscriberFinderTests.java   
@Override
protected void setUp() throws Exception {
  subscriber = createSubscriber();
  EventBus bus = new EventBus();
  bus.register(subscriber);
  bus.post(EVENT);
}
项目:ProjectAres    文件:ReentrantEventBus.java   
private ThreadLocal<Boolean> getIsDispatching() {
    try {
        final Field field = EventBus.class.getDeclaredField("isDispatching");
        field.setAccessible(true);
        return (ThreadLocal<Boolean>) field.get(this);
    } catch(IllegalAccessException | NoSuchFieldException e) {
        throw new IllegalStateException();
    }
}
项目:ProjectAres    文件:RestartManager.java   
@Inject RestartManager(Loggers loggers, LocalServer minecraftServer, MinecraftService minecraftService, Server localServer, RestartConfiguration config, EventBus eventBus, OnlinePlayers onlinePlayers, NamedThreadFactory threads) {
    this.localServer = localServer;
    this.onlinePlayers = onlinePlayers;
    this.logger = loggers.get(getClass());
    this.minecraftServer = minecraftServer;
    this.minecraftService = minecraftService;
    this.config = config;
    this.eventBus = eventBus;
    this.threads = threads;
    this.startTime = Instant.now();
}
项目:wall-t    文件:WallApplication.java   
public WallApplication( ) {
    LOGGER.info( "Starting ..." );
    _injector = Guice.createInjector( modules( ) );
    _executorService = _injector.getInstance( ExecutorService.class );
    _scheduledExecutorService = _injector.getInstance( ScheduledExecutorService.class );
    _eventBus = _injector.getInstance( EventBus.class );
    _apiMonitoringService = _injector.getInstance( IApiMonitoringService.class );
}
项目:wall-t    文件:BuildTypeViewModel.java   
@Inject
BuildTypeViewModel( final IBuildTypeManager buildManager, final EventBus eventBus, @Assisted final BuildTypeData data ) {
    _id.setValue( data.getId( ) );
    _projectName.setValue( data.getProjectName( ) );
    _name.setValue( data.getName( ) );

    _aliasName.setValue( data.getAliasName( ) );
    _aliasName.addListener( ( o, oldValue, newValue ) -> {
        data.setAliasName( newValue );
        eventBus.post( data );
    } );

    _selected.setValue( buildManager.getMonitoredBuildTypes( ).contains( data ) );
    _selected.addListener( ( o, oldValue, newValue ) -> {
        if ( newValue )
            buildManager.activateMonitoring( data );
        else
            buildManager.unactivateMonitoring( data );
        eventBus.post( buildManager );
    } );

    _position.setValue( buildManager.getPosition( data ) );
    _position.addListener( ( o, oldValue, newValue ) -> {
        final int position = (int) newValue;
        if ( position > 0 ) {
            buildManager.requestPosition( data, position );
        }
        eventBus.post( buildManager );
    } );
}
项目:wall-t    文件:ProjectViewModel.java   
@Inject
ProjectViewModel( final IProjectManager projectManager, final EventBus eventBus, @Assisted final ProjectData data ) {
    _id.setValue( data.getId( ) );
    _name.setValue( data.getName( ) );

    _aliasName.setValue( data.getAliasName( ) );
    _aliasName.addListener( ( o, oldValue, newValue ) -> {
        data.setAliasName( newValue );
        eventBus.post( data );
    } );

    _selected.setValue( projectManager.getMonitoredProjects( ).contains( data ) );
    _selected.addListener( ( o, oldValue, newValue ) -> {
        if ( newValue )
            projectManager.activateMonitoring( data );
        else
            projectManager.unactivateMonitoring( data );
        eventBus.post( projectManager );
    } );

    _position.setValue( projectManager.getPosition( data ) );
    _position.addListener( ( o, oldValue, newValue ) -> {
        final int position = (int) newValue;
        if ( position > 0 ) {
            projectManager.requestPosition( data, position );
        }
        eventBus.post( projectManager );
    } );
}
项目:wall-t    文件:WallViewModel.java   
@Inject
WallViewModel( final EventBus eventBus, final Configuration configuration, final IBuildTypeManager buildManager, final IProjectManager projectManager, final TileViewModel.Factory tileViewModeFactory, final ProjectTileViewModel.Factory projectTileViewModeFactory ) {
    _eventBus = eventBus;
    _tileViewModeFactory = tileViewModeFactory;
    _projectTileViewModeFactory = projectTileViewModeFactory;
    updateConfiguration( configuration );
    updateBuildList( buildManager );
    updateProjectList( projectManager );
}
项目:wall-t    文件:ApiController.java   
@Inject
ApiController( final Configuration configuration, final IProjectManager projectManager, final IBuildTypeManager buildManager, final IApiRequestController apiRequestController, final EventBus eventBus, final ExecutorService executorService, final Map<ApiVersion, Function<Build, BuildData>> buildFunctionsByVersion, final Map<ApiVersion, Function<BuildType, BuildTypeData>> buildTypeProvider, final Map<ApiVersion, Function<Project, ProjectData>> projectProvider ) {
    _configuration = configuration;
    _projectManager = projectManager;
    _apiRequestController = apiRequestController;
    _buildManager = buildManager;
    _eventBus = eventBus;
    _executorService = executorService;
    _buildProvider = buildFunctionsByVersion;
    _buildTypeProvider = buildTypeProvider;
    _projectProvider = projectProvider;
}
项目:wall-t    文件:WallApplicationModuleTest.java   
@Test
public void can_inject_EventBus_in_singleton( ) {
    // Setup
    // Exercise
    final EventBus instance = _injector.getInstance( EventBus.class );
    final EventBus instance2 = _injector.getInstance( EventBus.class );
    // Verify
    assertThat( instance, is( notNullValue( ) ) );
    assertThat( instance, is( sameInstance( instance2 ) ) );
}
项目:flume-release-1.7.0    文件:PollingPropertiesFileConfigurationProvider.java   
public PollingPropertiesFileConfigurationProvider(String agentName,
    File file, EventBus eventBus, int interval) {
  super(agentName, file);
  this.eventBus = eventBus;
  this.file = file;
  this.interval = interval;
  counterGroup = new CounterGroup();
  lifecycleState = LifecycleState.IDLE;
}
项目:graylog-plugin-s3    文件:S3Transport.java   
@AssistedInject
public S3Transport(@Assisted final Configuration configuration,
                   final EventBus serverEventBus,
                   final ServerStatus serverStatus,
                   LocalMetricRegistry localRegistry) {
    super(serverEventBus, configuration);
    this.serverStatus = serverStatus;
    this.localRegistry = localRegistry;
}
项目:fx-animation-editor    文件:ScenePresenter.java   
@Inject
public ScenePresenter(SceneModel model, PlayerModel playerModel, SelectionClickBehavior clickBehavior, EventBus eventBus) {
    this.model = model;
    this.playerModel = playerModel;
    this.clickBehavior = clickBehavior;
    this.eventBus = eventBus;
}
项目:WebPLP    文件:ExecuteStage.java   
public ExecuteStage(SimulatorStatusManager statusManager, EventBus simulatorBus)
{
    this.bus = simulatorBus;
    //this.addressBus = addressBus;
    this.eventHandler = new ExecuteEventHandler();
    this.statusManager = statusManager;

    this.bus.register(eventHandler);

    this.state = new CpuState();

    alu = new ALU();

    reset();
}
项目:WebPLP    文件:MemoryStage.java   
public MemoryStage(PLPAddressBus addressBus, SimulatorStatusManager statusManager, EventBus simulatorBus)
{
    this.bus = simulatorBus;
    this.addressBus = addressBus;
    this.eventHandler = new MemoryEventHandler();
    this.statusManager = statusManager;

    this.bus.register(eventHandler);

    this.state = new CpuState();

    reset();
}