@Test public void testModified() { assertEquals("Incorrect NetConf session timeout, should be default", 5, ctrl.netconfReplyTimeout); ctrl.modified(context); assertEquals("Incorrect NetConf session timeout", 1, ctrl.netconfReplyTimeout); }
@Modified public void modified(ComponentContext context) { if (context == null) { netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS; log.info("No component configuration"); return; } Dictionary<?, ?> properties = context.getProperties(); int newNetconfReplyTimeout; try { String s = get(properties, PROP_NETCONF_REPLY_TIMEOUT); newNetconfReplyTimeout = isNullOrEmpty(s) ? netconfReplyTimeout : Integer.parseInt(s.trim()); } catch (NumberFormatException e) { log.warn("Component configuration had invalid value", e); return; } netconfReplyTimeout = newNetconfReplyTimeout; log.info("Settings: {} = {}", PROP_NETCONF_REPLY_TIMEOUT, netconfReplyTimeout); }
NetconfControllerImpl implements NetconfController { @Modified public void modified(ComponentContext context) { if (context == null) { netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS; log.info("No component configuration"); return; } Dictionary<?, ?> properties = context.getProperties(); int newNetconfReplyTimeout; try { String s = get(properties, PROP_NETCONF_REPLY_TIMEOUT); newNetconfReplyTimeout = isNullOrEmpty(s) ? netconfReplyTimeout : Integer.parseInt(s.trim()); } catch (NumberFormatException e) { log.warn("Component configuration had invalid value", e); return; } netconfReplyTimeout = newNetconfReplyTimeout; log.info("Settings: {} = {}", PROP_NETCONF_REPLY_TIMEOUT, netconfReplyTimeout); } }
NetconfControllerImpl implements NetconfController { @Modified public void modified(ComponentContext context) { if (context == null) { netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS; log.info("No component configuration"); return; } Dictionary<?, ?> properties = context.getProperties(); int newNetconfReplyTimeout; try { String s = get(properties, PROP_NETCONF_REPLY_TIMEOUT); newNetconfReplyTimeout = isNullOrEmpty(s) ? netconfReplyTimeout : Integer.parseInt(s.trim()); } catch (NumberFormatException e) { log.warn("Component configuration had invalid value", e); return; } netconfReplyTimeout = newNetconfReplyTimeout; log.info("Settings: {} = {}", PROP_NETCONF_REPLY_TIMEOUT, netconfReplyTimeout); }  }
NetconfControllerImpl implements NetconfController { @Modified public void modified(ComponentContext context) { if (context == null) { netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS; log.info("No component configuration"); return; } Dictionary<?, ?> properties = context.getProperties(); int newNetconfReplyTimeout; try { String s = get(properties, PROP_NETCONF_REPLY_TIMEOUT); newNetconfReplyTimeout = isNullOrEmpty(s) ? netconfReplyTimeout : Integer.parseInt(s.trim()); } catch (NumberFormatException e) { log.warn("Component configuration had invalid value", e); return; } netconfReplyTimeout = newNetconfReplyTimeout; log.info("Settings: {} = {}", PROP_NETCONF_REPLY_TIMEOUT, netconfReplyTimeout); }  @Activate void activate(ComponentContext context); @Deactivate void deactivate(); @Modified void modified(ComponentContext context); @Override void addDeviceListener(NetconfDeviceListener listener); @Override void removeDeviceListener(NetconfDeviceListener listener); @Override NetconfDevice getNetconfDevice(DeviceId deviceInfo); @Override NetconfDevice getNetconfDevice(IpAddress ip, int port); @Override NetconfDevice connectDevice(DeviceId deviceId); @Override void disconnectDevice(DeviceId deviceId, boolean remove); @Override void removeDevice(DeviceId deviceId); @Override Map<DeviceId, NetconfDevice> getDevicesMap(); @Override Set<DeviceId> getNetconfDevices(); }
NetconfControllerImpl implements NetconfController { @Modified public void modified(ComponentContext context) { if (context == null) { netconfReplyTimeout = DEFAULT_REPLY_TIMEOUT_SECONDS; log.info("No component configuration"); return; } Dictionary<?, ?> properties = context.getProperties(); int newNetconfReplyTimeout; try { String s = get(properties, PROP_NETCONF_REPLY_TIMEOUT); newNetconfReplyTimeout = isNullOrEmpty(s) ? netconfReplyTimeout : Integer.parseInt(s.trim()); } catch (NumberFormatException e) { log.warn("Component configuration had invalid value", e); return; } netconfReplyTimeout = newNetconfReplyTimeout; log.info("Settings: {} = {}", PROP_NETCONF_REPLY_TIMEOUT, netconfReplyTimeout); }  @Activate void activate(ComponentContext context); @Deactivate void deactivate(); @Modified void modified(ComponentContext context); @Override void addDeviceListener(NetconfDeviceListener listener); @Override void removeDeviceListener(NetconfDeviceListener listener); @Override NetconfDevice getNetconfDevice(DeviceId deviceInfo); @Override NetconfDevice getNetconfDevice(IpAddress ip, int port); @Override NetconfDevice connectDevice(DeviceId deviceId); @Override void disconnectDevice(DeviceId deviceId, boolean remove); @Override void removeDevice(DeviceId deviceId); @Override Map<DeviceId, NetconfDevice> getDevicesMap(); @Override Set<DeviceId> getNetconfDevices(); static final Logger log; }