@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)); }
@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); }
@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); }
@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()); }
@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); }
@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); }
@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; }
@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(); } }); }
@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(); } }
@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); }
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()); }
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(); }
@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; } }
public AbstractServiceRegistry(EventBus eventBus, ServiceRegistryConfig serviceRegistryConfig, MicroserviceDefinition microserviceDefinition) { this.eventBus = eventBus; this.serviceRegistryConfig = serviceRegistryConfig; this.microserviceDefinition = microserviceDefinition; this.microservice = microserviceFactory.create(microserviceDefinition); }
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); }
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); }
@Inject public SelectionResizeHandler(CommandStack commandStack, TimelineModel timelineModel, SceneModel sceneModel, EventBus eventBus) { this.commandStack = commandStack; this.timelineModel = timelineModel; this.sceneModel = sceneModel; subscribeToEvents(eventBus); }
@Inject public SelectionDragBehavior(SceneModel sceneModel, PanningComponent panningComponent, EventBus eventBus) { super(sceneModel); this.sceneModel = sceneModel; this.panningComponent = panningComponent; this.eventBus = eventBus; }
public ServiceCenterTask(EventBus eventBus, int interval, MicroserviceServiceCenterTask microserviceServiceCenterTask) { this.eventBus = eventBus; this.interval = interval; this.microserviceServiceCenterTask = microserviceServiceCenterTask; this.eventBus.register(this); }
@Before public void setup() { eventBus = new EventBus(); microservice = new Microservice(); microservice.setAppId("app"); microservice.setServiceName("ms"); microservice.setInstance(new MicroserviceInstance()); }
@Inject public MenuBarComponent(EventBus eventBus, CommandStack commandStack, PanningHelper panningHelper) { this.eventBus = eventBus; this.commandStack = commandStack; this.panningHelper = panningHelper; loadFxml(); initUi(); initActions(); bindDisabledStates(); }
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); }
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); }
@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); }
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(); }
@Inject public AnimationEditorPresenter(PropertyModel propertyModel, SceneModel sceneModel, TimelineModel timelineModel, EventBus eventBus) { this.propertyModel = propertyModel; this.sceneModel = sceneModel; this.timelineModel = timelineModel; this.eventBus = eventBus; }
@Override protected void setUp() throws Exception { subscriber = createSubscriber(); EventBus bus = new EventBus(); bus.register(subscriber); bus.post(EVENT); }
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(); } }
@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(); }
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 ); }
@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 ); } ); }
@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 ); } ); }
@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 ); }
@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; }
@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 ) ) ); }
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; }
@AssistedInject public S3Transport(@Assisted final Configuration configuration, final EventBus serverEventBus, final ServerStatus serverStatus, LocalMetricRegistry localRegistry) { super(serverEventBus, configuration); this.serverStatus = serverStatus; this.localRegistry = localRegistry; }
@Inject public ScenePresenter(SceneModel model, PlayerModel playerModel, SelectionClickBehavior clickBehavior, EventBus eventBus) { this.model = model; this.playerModel = playerModel; this.clickBehavior = clickBehavior; this.eventBus = eventBus; }
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(); }
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(); }