/** * Store the producer current status in ConfigurationAdmin. * * @param switchStatus the producer switch status to store. */ private void persist(SwitchStatus switchStatus) { try { Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE, null); if (configuration != null) { Dictionary<String, Object> properties = configuration.getProperties(); if (properties != null) { properties.put(Configurations.PRODUCER, switchStatus.getValue().toString()); configuration.update(properties); } } } catch (Exception e) { LOGGER.warn("Can't persist the producer status", e); } }
/** * Store the consumer current status in ConfigurationAdmin. * * @param switchStatus the producer switch status to store. */ private void persist(SwitchStatus switchStatus) { try { Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE, null); if (configuration != null) { Dictionary<String, Object> properties = configuration.getProperties(); if (properties != null) { properties.put(Configurations.CONSUMER, switchStatus.getValue().toString()); configuration.update(properties); } } } catch (Exception e) { LOGGER.warn("Can't persist the consumer status", e); } }
/** * Store the consumer current status in ConfigurationAdmin. * * @param switchStatus the producer switch status to store. */ private void persist(SwitchStatus switchStatus) { try { Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE, null); if (configuration != null) { Dictionary<String, Object> properties = configuration.getProperties(); if (properties != null) { properties.put(Configurations.CONSUMER, switchStatus.getValue().toString()); configuration.update(properties); } } } catch (Exception e) { LOGGER.warn("Can't persist the consumer status", e); } }
/** * Store the producer current status in ConfigurationAdmin. * * @param switchStatus the producer switch status to store. */ private void persist(SwitchStatus switchStatus) { try { Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE, null); if (configuration != null) { Dictionary<String, Object> properties = configuration.getProperties(); if (properties != null) { properties.put(Configurations.PRODUCER, switchStatus.getValue().toString()); configuration.update(properties); } } } catch (Exception e) { LOGGER.warn("Can't persist the producer status", e); } }
/** * Store the handler switch configuration in configuration admin. * * @param handler the handler to store. * @param switchStatus the switch status to store. */ private void persist(String handler, SwitchStatus switchStatus) { try { Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE, null); if (configuration != null) { Dictionary<String, Object> properties = configuration.getProperties(); if (properties != null) { properties.put(Configurations.HANDLER + "." + handler, switchStatus.getValue().toString()); configuration.update(properties); } } } catch (Exception e) { LOGGER.warn("Can't persist the handler {} status", handler, e); } }
/** * Store the handler switch configuration in configuration admin. * * @param handler the handler to store. * @param switchStatus the switch status to store. */ private void persist(String handler, SwitchStatus switchStatus) { try { Configuration configuration = configurationAdmin.getConfiguration(Configurations.NODE, null); if (configuration != null) { Dictionary<String, Object> properties = configuration.getProperties(); if (properties != null) { properties.put(Configurations.HANDLER + "." + handler, switchStatus.getValue().toString()); configuration.update(properties); } } } catch (Exception e) { LOGGER.warn("Can't persist the handler {} status", handler, e); } }
/** * Handle the {@code ProducerSwitchCommand} command. * * @param command */ public ConsumerSwitchResult execute(ConsumerSwitchCommand command) { // query if (command.getStatus() == null) { return new ConsumerSwitchResult(command.getId(), Boolean.TRUE, consumer.getSwitch().getStatus().getValue()); } else if (command.getStatus().equals(SwitchStatus.ON)) { // turn on the switch consumer.getSwitch().turnOn(); // persist the change persist(command.getStatus()); return new ConsumerSwitchResult(command.getId(), Boolean.TRUE, Boolean.TRUE); } else if (command.getStatus().equals(SwitchStatus.OFF)) { // turn on the switch consumer.getSwitch().turnOff(); // persist the change persist(command.getStatus()); return new ConsumerSwitchResult(command.getId(), Boolean.TRUE, Boolean.FALSE); } else { return new ConsumerSwitchResult(command.getId(), Boolean.FALSE, consumer.getSwitch().getStatus().getValue()); } }
/** * Handle the {@code ProducerSwitchCommand} command. * * @param command */ public ConsumerSwitchResult execute(ConsumerSwitchCommand command) { // query if (command.getStatus() == null) { return new ConsumerSwitchResult(command.getId(), Boolean.TRUE, consumer.getSwitch().getStatus().getValue()); } else if (command.getStatus().equals(SwitchStatus.ON)) { // turn on the switch consumer.getSwitch().turnOn(); // persist the change persist(command.getStatus()); return new ConsumerSwitchResult(command.getId(), Boolean.TRUE, Boolean.TRUE); } else if (command.getStatus().equals(SwitchStatus.OFF)) { // turn on the switch consumer.getSwitch().turnOff(); // persist the change persist(command.getStatus()); return new ConsumerSwitchResult(command.getId(), Boolean.TRUE, Boolean.FALSE); } else { return new ConsumerSwitchResult(command.getId(), Boolean.FALSE, consumer.getSwitch().getStatus().getValue()); } }
/** * Execute a producer switch command. * * @param command the producer switch command to execute. * @return the result of the command execution. */ @Override public ProducerSwitchResult execute(ProducerSwitchCommand command) { // query if (command.getStatus() == null) { return new ProducerSwitchResult(command.getId(), Boolean.TRUE, producer.getSwitch().getStatus().getValue()); } else if (command.getStatus().equals(SwitchStatus.ON)) { // turn on the switch producer.getSwitch().turnOn(); // persist the change persist(command.getStatus()); return new ProducerSwitchResult(command.getId(), Boolean.TRUE, Boolean.TRUE); } else if (command.getStatus().equals(SwitchStatus.OFF)) { // turn off the switch producer.getSwitch().turnOff(); // persist the change persist(command.getStatus()); return new ProducerSwitchResult(command.getId(), Boolean.TRUE, Boolean.FALSE); } else { return new ProducerSwitchResult(command.getId(), Boolean.FALSE, producer.getSwitch().getStatus().getValue()); } }
/** * Execute a producer switch command. * * @param command the producer switch command to execute. * @return the result of the command execution. */ @Override public ProducerSwitchResult execute(ProducerSwitchCommand command) { // query if (command.getStatus() == null) { return new ProducerSwitchResult(command.getId(), Boolean.TRUE, producer.getSwitch().getStatus().getValue()); } else if (command.getStatus().equals(SwitchStatus.ON)) { // turn on the switch producer.getSwitch().turnOn(); // persist the change persist(command.getStatus()); return new ProducerSwitchResult(command.getId(), Boolean.TRUE, Boolean.TRUE); } else if (command.getStatus().equals(SwitchStatus.OFF)) { // turn off the switch producer.getSwitch().turnOff(); // persist the change persist(command.getStatus()); return new ProducerSwitchResult(command.getId(), Boolean.TRUE, Boolean.FALSE); } else { return new ProducerSwitchResult(command.getId(), Boolean.FALSE, producer.getSwitch().getStatus().getValue()); } }