@Override public void stop() { super.stop(); for (FermatEventListener fermatEventListener : listenersAdded) { eventManager.removeListener(fermatEventListener); } listenersAdded.clear(); agente.stop(); }
@Override public void start() throws CantStartPluginException { try { FermatEventListener fermatEventListener; FermatEventHandler fermatEventHandler; this.cryptoCustomerActorDao = new CryptoCustomerActorDao(pluginDatabaseSystem, pluginFileSystem, pluginId); this.cryptoCustomerActorDao.initializeDatabase(); fermatManager = new CustomerActorManager( this.cryptoCustomerActorDao, cryptoBrokerANSManager, errorManager, getPluginVersionReference()); ActorCustomerExtraDataEventActions handlerAction = new ActorCustomerExtraDataEventActions( cryptoBrokerANSManager, cryptoCustomerActorDao, cryptoBrokerActorConnectionManager); fermatEventListener = eventManager.getNewListener(EventType.CRYPTO_BROKER_QUOTES_REQUEST_UPDATES); fermatEventHandler = new CryptoCustomerExtraDataEventHandler(handlerAction, this); fermatEventListener.setEventHandler(fermatEventHandler); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); fermatEventListener = eventManager.getNewListener(EventType.CRYPTO_BROKER_ACTOR_CONNECTION_NEW_CONNECTION); fermatEventHandler = new CryptoBrokerNewConnectionEventHandler(handlerAction, this); fermatEventListener.setEventHandler(fermatEventHandler); eventManager.addListener(fermatEventListener); listenersAdded.add(fermatEventListener); agente = new CryptoBrokerExtraDataUpdateAgent( cryptoBrokerANSManager, cryptoCustomerActorDao, errorManager, getPluginVersionReference()); agente.start(); this.serviceStatus = ServiceStatus.STARTED; } catch (CantStartAgentException | CantInitializeCryptoCustomerActorDatabaseException e) { errorManager.reportUnexpectedPluginException( this.getPluginVersionReference(), UnexpectedPluginExceptionSeverity.DISABLES_THIS_PLUGIN, e); throw new CantStartPluginException(e, this.getPluginVersionReference()); } }