@Test public void testSetConfiguration() { Map<String,String> map = new HashMap<String,String>( 0 ); Assert.assertFalse( this.factory.setConfiguration( map )); map.put( MessagingConstants.MESSAGING_TYPE_PROPERTY, "whatever" ); Assert.assertFalse( this.factory.setConfiguration( map )); map.put( MessagingConstants.MESSAGING_TYPE_PROPERTY, HttpConstants.FACTORY_HTTP ); Assert.assertTrue( this.factory.setConfiguration( map )); synchronized( this.factory ) { Assert.assertEquals( HttpConstants.DEFAULT_IP, this.factory.httpServerIp ); Assert.assertEquals( HttpConstants.DEFAULT_PORT, this.factory.httpPort ); } map.put( HttpConstants.HTTP_SERVER_IP, "127.0.0.4" ); map.put( HttpConstants.HTTP_SERVER_PORT, "24658" ); Assert.assertTrue( this.factory.setConfiguration( map )); synchronized( this.factory ) { Assert.assertEquals( "127.0.0.4", this.factory.httpServerIp ); Assert.assertEquals( 24658, this.factory.httpPort ); } }
@Override public boolean setConfiguration( final Map<String, String> configuration ) { boolean valid = HttpConstants.FACTORY_HTTP.equals( configuration.get( MessagingConstants.MESSAGING_TYPE_PROPERTY )); if( valid ) { boolean hasChanged = false; String ip = Utils.getValue( configuration, HTTP_SERVER_IP, DEFAULT_IP ); String portAS = configuration.get( HttpConstants.HTTP_SERVER_PORT ); int port = portAS == null ? HttpConstants.DEFAULT_PORT : Integer.parseInt( portAS ); synchronized( this ) { if( ! Objects.equals( this.httpServerIp, ip )) { this.httpServerIp = ip; hasChanged = true; } if( this.httpPort != port ) { this.httpPort = port; hasChanged = true; } } if( hasChanged ) reconfigure(); } return valid; }
HttpClientFactory implements IMessagingClientFactory { @Override public boolean setConfiguration( final Map<String, String> configuration ) { boolean valid = HttpConstants.FACTORY_HTTP.equals( configuration.get( MessagingConstants.MESSAGING_TYPE_PROPERTY )); if( valid ) { boolean hasChanged = false; String ip = Utils.getValue( configuration, HTTP_SERVER_IP, DEFAULT_IP ); String portAS = configuration.get( HttpConstants.HTTP_SERVER_PORT ); int port = portAS == null ? HttpConstants.DEFAULT_PORT : Integer.parseInt( portAS ); synchronized( this ) { if( ! Objects.equals( this.httpServerIp, ip )) { this.httpServerIp = ip; hasChanged = true; } if( this.httpPort != port ) { this.httpPort = port; hasChanged = true; } } if( hasChanged ) reconfigure(); } return valid; } }
HttpClientFactory implements IMessagingClientFactory { @Override public boolean setConfiguration( final Map<String, String> configuration ) { boolean valid = HttpConstants.FACTORY_HTTP.equals( configuration.get( MessagingConstants.MESSAGING_TYPE_PROPERTY )); if( valid ) { boolean hasChanged = false; String ip = Utils.getValue( configuration, HTTP_SERVER_IP, DEFAULT_IP ); String portAS = configuration.get( HttpConstants.HTTP_SERVER_PORT ); int port = portAS == null ? HttpConstants.DEFAULT_PORT : Integer.parseInt( portAS ); synchronized( this ) { if( ! Objects.equals( this.httpServerIp, ip )) { this.httpServerIp = ip; hasChanged = true; } if( this.httpPort != port ) { this.httpPort = port; hasChanged = true; } } if( hasChanged ) reconfigure(); } return valid; } HttpClientFactory();  HttpClientFactory( BundleContext bundleContext ); }
HttpClientFactory implements IMessagingClientFactory { @Override public boolean setConfiguration( final Map<String, String> configuration ) { boolean valid = HttpConstants.FACTORY_HTTP.equals( configuration.get( MessagingConstants.MESSAGING_TYPE_PROPERTY )); if( valid ) { boolean hasChanged = false; String ip = Utils.getValue( configuration, HTTP_SERVER_IP, DEFAULT_IP ); String portAS = configuration.get( HttpConstants.HTTP_SERVER_PORT ); int port = portAS == null ? HttpConstants.DEFAULT_PORT : Integer.parseInt( portAS ); synchronized( this ) { if( ! Objects.equals( this.httpServerIp, ip )) { this.httpServerIp = ip; hasChanged = true; } if( this.httpPort != port ) { this.httpPort = port; hasChanged = true; } } if( hasChanged ) reconfigure(); } return valid; } HttpClientFactory();  HttpClientFactory( BundleContext bundleContext ); synchronized void setHttpServerIp( final String serverIp ); synchronized void setHttpPort( final int port ); HttpDmClient getDmClient(); void start(); void stop(); @Override IMessagingClient createClient( ReconfigurableClient<?> parent ); @Override String getType(); @Override boolean setConfiguration( final Map<String, String> configuration ); void reconfigure(); }
HttpClientFactory implements IMessagingClientFactory { @Override public boolean setConfiguration( final Map<String, String> configuration ) { boolean valid = HttpConstants.FACTORY_HTTP.equals( configuration.get( MessagingConstants.MESSAGING_TYPE_PROPERTY )); if( valid ) { boolean hasChanged = false; String ip = Utils.getValue( configuration, HTTP_SERVER_IP, DEFAULT_IP ); String portAS = configuration.get( HttpConstants.HTTP_SERVER_PORT ); int port = portAS == null ? HttpConstants.DEFAULT_PORT : Integer.parseInt( portAS ); synchronized( this ) { if( ! Objects.equals( this.httpServerIp, ip )) { this.httpServerIp = ip; hasChanged = true; } if( this.httpPort != port ) { this.httpPort = port; hasChanged = true; } } if( hasChanged ) reconfigure(); } return valid; } HttpClientFactory();  HttpClientFactory( BundleContext bundleContext ); synchronized void setHttpServerIp( final String serverIp ); synchronized void setHttpPort( final int port ); HttpDmClient getDmClient(); void start(); void stop(); @Override IMessagingClient createClient( ReconfigurableClient<?> parent ); @Override String getType(); @Override boolean setConfiguration( final Map<String, String> configuration ); void reconfigure();  }