/** * <p>Unsubscribe all subscribers from events</p> * <p>This approach ensures all subscribers will be correctly removed during a shutdown</p> */ @SuppressWarnings("unchecked") public static void unsubscribeAll() { Set allSubscribers = Sets.newHashSet(); allSubscribers.addAll(messageEventBusSubscribers); for (Object subscriber : allSubscribers) { unsubscribe(subscriber); } allSubscribers.clear(); log.info("All subscribers removed"); }
/** * <p>Reset the context into a stopped state (the service will have to be stopped and a new one started)</p> */ public void resetToStopped() { log.debug("Reset to 'stopped'"); // Clear relevant information resetAllButFeatures(); // Issue a hard detach - we are done client.hardDetach(); // Unsubscribe from events MessageEvents.unsubscribe(this); // Perform the state change currentState = HardwareWalletStates.newStoppedState(); // Fire the high level event HardwareWalletEvents.fireHardwareWalletEvent(HardwareWalletEventType.SHOW_DEVICE_STOPPED, client.name()); }