@Override public void shutdown() { if (this.unitRemote != null) { unitRemote.removeDataObserver(dataObserver); unitRemote.removeConnectionStateObserver(connectionStateObserver); } }
/** * Initializes this service panel with the given unit remote. * * @param unitRemote * @throws CouldNotPerformException * @throws InterruptedException */ public void init(final UnitRemote unitRemote, final ServiceConfig serviceConfig) throws CouldNotPerformException, InterruptedException { if (this.unitRemote != null) { unitRemote.removeDataObserver(dataObserver); unitRemote.removeConnectionStateObserver(connectionStateObserver); } this.unitRemote = unitRemote; // bindServiceConfig(serviceConfig); // unitRemote.addDataObserver(dataObserver); // unitRemote.addConnectionStateObserver(connectionStateObserver); // unitRemote.waitForData(); }
/** * {@inheritDoc} * * @throws CouldNotPerformException {@inheritDoc} * @throws InterruptedException {@inheritDoc} */ @Override public void deactivate() throws CouldNotPerformException, InterruptedException { verifyMaintainability(); active = false; unitRemoteMap.values().stream().forEach(remote -> { remote.removeDataObserver(dataObserver); remote.removeConnectionStateObserver(connectionStateObserver); }); }
@Override public void removeUnit(UnitConfig unitConfig) throws CouldNotPerformException, InterruptedException { UnitRemote unitRemote; if (unitRemoteMap.containsKey(unitConfig.getId())) { unitRemote = unitRemoteMap.remove(unitConfig.getId()); serviceMap.remove(unitConfig.getId()); unitRemoteTypeMap.get(unitConfig.getType()).remove(unitRemote); for (UnitType superType : Registries.getUnitRegistry().getSuperUnitTypes(unitRemote.getUnitType())) { unitRemoteTypeMap.get(superType).remove(unitRemote); } } else if (disabledUnitRemoteMap.containsKey(unitConfig.getId())) { unitRemote = disabledUnitRemoteMap.remove(unitConfig.getId()); } else { throw new NotAvailableException("UnitConfig[" + ScopeGenerator.generateStringRep(unitConfig.getScope()) + "]"); } unitRemote.removeDataObserver(dataObserver); unitRemote.removeConnectionStateObserver(connectionStateObserver); unitRemote.removeConfigObserver(unitConfigObserver); }