@Inject private void subscribe(EventService eventService) { eventService.subscribe(this); } }
@PreDestroy public void unsubscribe() { eventService.unsubscribe(this, StackPersistedEvent.class); } }
@Override public void showMessage(MessageParams messageParams) { eventService.publish(messageParams); }
/** * Subscribe event listener. The event to subscribe to is inferred by checking the generic type * arguments of the given subscriber. * * @param subscriber event subscriber */ public void subscribe(EventSubscriber<?> subscriber) { final Class<?> eventType = getEventType(subscriber); doSubscribe(subscriber, eventType); }
bootstrapFuture.complete(null); eventService.unsubscribe(bootstrapperStatusListener, BootstrapperStatusEvent.class); }); bootstrapFuture.whenComplete((ok, ex) -> finishEventFuture.cancel(true)); eventService.subscribe(bootstrapperStatusListener, BootstrapperStatusEvent.class); try { doBootstrapAsync(installerEndpoint, outputEndpoint);
/** * Subscribe to an event. The given subscriber will be called whenever an instance of the * specified event is published. * * @param subscriber The subscriber to call when an event is published. * @param eventType The event to subscribe to. */ public <T> void subscribe(EventSubscriber<? extends T> subscriber, Class<T> eventType) { doSubscribe(subscriber, eventType); }
eventService.subscribe(bootstrapperStatusListener, BootstrapperStatusEvent.class); try { doBootstrapAsync(installerEndpoint, outputEndpoint); "Bootstrapping of machine " + machineName + " reached timeout"); } finally { eventService.unsubscribe(bootstrapperStatusListener, BootstrapperStatusEvent.class);
@Inject public void subscribe(EventService eventService) { eventService.subscribe(this, RuntimeLogEvent.class); }
/** * Blocks starting new workspaces and waits until all workspaces that are currently in a * starting/stopping state to finish this process * * @throws InterruptedException * @throws UnsupportedOperationException */ @Override public void suspend() throws InterruptedException, UnsupportedOperationException { try { runtimeInfrastructure.getIdentities(); } catch (UnsupportedOperationException | InfrastructureException e) { throw new UnsupportedOperationException("Current infrastructure does not support suspend."); } Preconditions.checkState(runtimes.refuseStart()); WorkspaceSuspendedEventsPropagator propagator = new WorkspaceSuspendedEventsPropagator(); eventService.subscribe(propagator); try { waitAllWorkspacesRunningOrStopped(); sharedPool.shutdown(); } finally { eventService.unsubscribe(propagator); } try { workspaceRemover.shutdown(); } catch (Exception ignored) { } }
private <T> void handle(T event) { eventService.publish(event); } }
@PreDestroy public void unsubscribe() { eventService.unsubscribe(this, BeforeStackRemovedEvent.class); }
@PostConstruct public void subscribe() { eventService.subscribe(this, BeforeAccountRemovedEvent.class); }
/** * Blocks starting new workspaces and stops all that already running * * @throws InterruptedException */ @Override public void terminate() throws InterruptedException { Preconditions.checkState(runtimes.refuseStart()); WorkspaceStoppedEventsPropagator propagator = new WorkspaceStoppedEventsPropagator(); eventService.subscribe(propagator); try { stopRunningAndStartingWorkspacesAsync(); waitAllWorkspacesStopped(); sharedPool.shutdown(); } finally { eventService.unsubscribe(propagator); } try { workspaceRemover.shutdown(); } catch (Exception ignored) { } }
@Override public void publishDiagnostics(PublishDiagnosticsParams diagnostics) { eventService.publish(new ExtendedPublishDiagnosticsParams(serverId, diagnostics)); }
@PreDestroy public void unsubscribe() { eventService.unsubscribe(this, BeforeWorkspaceRemovedEvent.class); }
@PostConstruct public void subscribe() { eventService.subscribe(this, BeforeWorkspaceRemovedEvent.class); }
/** Synchronously stops corresponding services. */ private void doStopServices() { LOG.info("Preparing system to shutdown"); eventService.publish(asDto(new SystemStatusChangedEvent(RUNNING, PREPARING_TO_SHUTDOWN))); try { terminator.terminateAll(); statusRef.set(READY_TO_SHUTDOWN); eventService.publish( asDto(new SystemStatusChangedEvent(PREPARING_TO_SHUTDOWN, READY_TO_SHUTDOWN))); LOG.info("System is ready to shutdown"); } catch (InterruptedException x) { LOG.error("Interrupted while waiting for system service to shutdown components"); Thread.currentThread().interrupt(); } finally { shutdownLatch.countDown(); } }
@PreDestroy public void unsubscribe() { eventService.unsubscribe(this, BeforeUserRemovedEvent.class); }
@PostConstruct public void subscribe() { eventService.subscribe(this, BeforeAccountRemovedEvent.class); }
/** Synchronously stops corresponding services. */ private void doSuspendServices() { LOG.info("Preparing system to shutdown"); eventService.publish(asDto(new SystemStatusChangedEvent(RUNNING, PREPARING_TO_SHUTDOWN))); try { terminator.suspendAll(); statusRef.set(READY_TO_SHUTDOWN); eventService.publish( asDto(new SystemStatusChangedEvent(PREPARING_TO_SHUTDOWN, READY_TO_SHUTDOWN))); LOG.info("System is ready to shutdown"); } catch (InterruptedException x) { LOG.error("Interrupted while waiting for system service to shutdown components"); Thread.currentThread().interrupt(); } finally { shutdownLatch.countDown(); } }