@Test public void testServiceRegistersEndpoints() throws Exception { Dictionary<String, String> props = new Hashtable<String, String>(); props.put(NetworkConfig.Keys.COAP_SECURE_PORT, Integer.toString(CoAP.DEFAULT_COAP_SECURE_PORT)); managedServer = new ManagedServer(bundleContext, serverFactory, secureEndpointFactory); managedServer.updated(props); assertFalse(server.getEndpoints().isEmpty()); verify(server).addEndpoint(secureEndpoint); }
@Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { LOGGER.debug("Updating configuration of managed server instance"); if (isRunning()) { stop(); } NetworkConfig networkConfig = NetworkConfig.createStandardWithoutFile(); if (properties != null) { for (Enumeration<String> allKeys = properties.keys(); allKeys.hasMoreElements(); ) { String key = allKeys.nextElement(); networkConfig.set(key, properties.get(key)); } } managedServer = serverFactory.newServer(networkConfig); int securePort = networkConfig.getInt(NetworkConfig.Keys.COAP_SECURE_PORT); if ( securePort > 0 ) { Endpoint secureEndpoint = endpointFactory.getSecureEndpoint( networkConfig, new InetSocketAddress((InetAddress) null, securePort)); if (secureEndpoint != null) { LOGGER.debug("Adding secure endpoint on address {}", secureEndpoint.getAddress()); managedServer.addEndpoint(secureEndpoint); } else { LOGGER.warn("Secure endpoint has been configured in server properties but EndpointFactory does not support creation of secure Endpoints"); } } managedServer.start(); running = true; resourceTracker = new ServiceTracker<Resource, Resource>(context, Resource.class.getName(), this); resourceTracker.open(); }
ManagedServer implements ManagedService, ServiceTrackerCustomizer<Resource, Resource>, ServerEndpointRegistry { @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { LOGGER.debug("Updating configuration of managed server instance"); if (isRunning()) { stop(); } NetworkConfig networkConfig = NetworkConfig.createStandardWithoutFile(); if (properties != null) { for (Enumeration<String> allKeys = properties.keys(); allKeys.hasMoreElements(); ) { String key = allKeys.nextElement(); networkConfig.set(key, properties.get(key)); } } managedServer = serverFactory.newServer(networkConfig); int securePort = networkConfig.getInt(NetworkConfig.Keys.COAP_SECURE_PORT); if ( securePort > 0 ) { Endpoint secureEndpoint = endpointFactory.getSecureEndpoint( networkConfig, new InetSocketAddress((InetAddress) null, securePort)); if (secureEndpoint != null) { LOGGER.debug("Adding secure endpoint on address {}", secureEndpoint.getAddress()); managedServer.addEndpoint(secureEndpoint); } else { LOGGER.warn("Secure endpoint has been configured in server properties but EndpointFactory does not support creation of secure Endpoints"); } } managedServer.start(); running = true; resourceTracker = new ServiceTracker<Resource, Resource>(context, Resource.class.getName(), this); resourceTracker.open(); } }
ManagedServer implements ManagedService, ServiceTrackerCustomizer<Resource, Resource>, ServerEndpointRegistry { @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { LOGGER.debug("Updating configuration of managed server instance"); if (isRunning()) { stop(); } NetworkConfig networkConfig = NetworkConfig.createStandardWithoutFile(); if (properties != null) { for (Enumeration<String> allKeys = properties.keys(); allKeys.hasMoreElements(); ) { String key = allKeys.nextElement(); networkConfig.set(key, properties.get(key)); } } managedServer = serverFactory.newServer(networkConfig); int securePort = networkConfig.getInt(NetworkConfig.Keys.COAP_SECURE_PORT); if ( securePort > 0 ) { Endpoint secureEndpoint = endpointFactory.getSecureEndpoint( networkConfig, new InetSocketAddress((InetAddress) null, securePort)); if (secureEndpoint != null) { LOGGER.debug("Adding secure endpoint on address {}", secureEndpoint.getAddress()); managedServer.addEndpoint(secureEndpoint); } else { LOGGER.warn("Secure endpoint has been configured in server properties but EndpointFactory does not support creation of secure Endpoints"); } } managedServer.start(); running = true; resourceTracker = new ServiceTracker<Resource, Resource>(context, Resource.class.getName(), this); resourceTracker.open(); } ManagedServer(BundleContext bundleContext, EndpointFactory endpointFactory);  ManagedServer(BundleContext bundleContext, ServerInterfaceFactory serverFactory,
			EndpointFactory endpointFactory); }
ManagedServer implements ManagedService, ServiceTrackerCustomizer<Resource, Resource>, ServerEndpointRegistry { @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { LOGGER.debug("Updating configuration of managed server instance"); if (isRunning()) { stop(); } NetworkConfig networkConfig = NetworkConfig.createStandardWithoutFile(); if (properties != null) { for (Enumeration<String> allKeys = properties.keys(); allKeys.hasMoreElements(); ) { String key = allKeys.nextElement(); networkConfig.set(key, properties.get(key)); } } managedServer = serverFactory.newServer(networkConfig); int securePort = networkConfig.getInt(NetworkConfig.Keys.COAP_SECURE_PORT); if ( securePort > 0 ) { Endpoint secureEndpoint = endpointFactory.getSecureEndpoint( networkConfig, new InetSocketAddress((InetAddress) null, securePort)); if (secureEndpoint != null) { LOGGER.debug("Adding secure endpoint on address {}", secureEndpoint.getAddress()); managedServer.addEndpoint(secureEndpoint); } else { LOGGER.warn("Secure endpoint has been configured in server properties but EndpointFactory does not support creation of secure Endpoints"); } } managedServer.start(); running = true; resourceTracker = new ServiceTracker<Resource, Resource>(context, Resource.class.getName(), this); resourceTracker.open(); } ManagedServer(BundleContext bundleContext, EndpointFactory endpointFactory);  ManagedServer(BundleContext bundleContext, ServerInterfaceFactory serverFactory,
			EndpointFactory endpointFactory); @Override void updated(Dictionary<String, ?> properties); void stop(); @Override Resource addingService(ServiceReference<Resource> reference); @Override void removedService(ServiceReference<Resource> reference,
			Resource service); @Override void modifiedService(ServiceReference<Resource> reference,
			Resource service); @Override Endpoint getEndpoint(InetSocketAddress address); @Override Endpoint getEndpoint(int port); @Override Set<Endpoint> getAllEndpoints(); }
ManagedServer implements ManagedService, ServiceTrackerCustomizer<Resource, Resource>, ServerEndpointRegistry { @Override public void updated(Dictionary<String, ?> properties) throws ConfigurationException { LOGGER.debug("Updating configuration of managed server instance"); if (isRunning()) { stop(); } NetworkConfig networkConfig = NetworkConfig.createStandardWithoutFile(); if (properties != null) { for (Enumeration<String> allKeys = properties.keys(); allKeys.hasMoreElements(); ) { String key = allKeys.nextElement(); networkConfig.set(key, properties.get(key)); } } managedServer = serverFactory.newServer(networkConfig); int securePort = networkConfig.getInt(NetworkConfig.Keys.COAP_SECURE_PORT); if ( securePort > 0 ) { Endpoint secureEndpoint = endpointFactory.getSecureEndpoint( networkConfig, new InetSocketAddress((InetAddress) null, securePort)); if (secureEndpoint != null) { LOGGER.debug("Adding secure endpoint on address {}", secureEndpoint.getAddress()); managedServer.addEndpoint(secureEndpoint); } else { LOGGER.warn("Secure endpoint has been configured in server properties but EndpointFactory does not support creation of secure Endpoints"); } } managedServer.start(); running = true; resourceTracker = new ServiceTracker<Resource, Resource>(context, Resource.class.getName(), this); resourceTracker.open(); } ManagedServer(BundleContext bundleContext, EndpointFactory endpointFactory);  ManagedServer(BundleContext bundleContext, ServerInterfaceFactory serverFactory,
			EndpointFactory endpointFactory); @Override void updated(Dictionary<String, ?> properties); void stop(); @Override Resource addingService(ServiceReference<Resource> reference); @Override void removedService(ServiceReference<Resource> reference,
			Resource service); @Override void modifiedService(ServiceReference<Resource> reference,
			Resource service); @Override Endpoint getEndpoint(InetSocketAddress address); @Override Endpoint getEndpoint(int port); @Override Set<Endpoint> getAllEndpoints();  }