Author: cschneider
Date: Wed Nov 28 17:38:16 2012
New Revision: 1414835
URL: http://svn.apache.org/viewvc?rev=1414835&view=rev
Log:
DOSGI-127 DOSGI-126 Use relative default address to create service endpoints
but publish an absolute address for discovery
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Activator.java
Wed Nov 28 17:38:16 2012
@@ -19,7 +19,10 @@
package org.apache.cxf.dosgi.dsw;
import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Map;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
@@ -47,79 +50,95 @@ import org.slf4j.LoggerFactory;
// registered as spring bean -> start / stop called accordingly
public class Activator implements ManagedService, BundleActivator {
-
private static final int DEFAULT_INTENT_TIMEOUT = 30000;
-
private final static Logger LOG = LoggerFactory.getLogger(Activator.class);
-
private static final String CONFIG_SERVICE_PID = "cxf-dsw";
-
private ServiceRegistration rsaFactoryReg;
-
private ServiceRegistration decoratorReg;
-
private IntentTracker intentTracker;
+ private BundleContext bc;
public void start(BundleContext bc) throws Exception {
+ this.bc = bc;
+ start(bc, new Hashtable<String, Object>());
+ }
+
+ private void start(BundleContext bc, Map<String, Object> config) {
+ this.bc = bc;
// Disable the fast infoset as it's not compatible (yet) with OSGi
System.setProperty("org.apache.cxf.nofastinfoset", "true");
- // should we have a seperate PID for a find and publish hook ?
- // context.registerService(ManagedService.class.getName(), this,
getDefaults());
-
+ registerManagedService(bc);
IntentMap intentMap = new IntentMap(new
DefaultIntentMapFactory().create());
intentTracker = new IntentTracker(bc, intentMap);
intentTracker.open();
IntentManager intentManager = new IntentManagerImpl(intentMap,
DEFAULT_INTENT_TIMEOUT);
HttpServiceManager httpServiceManager = new HttpServiceManager(bc);
- ConfigTypeHandlerFactory configTypeHandlerFactory = new
ConfigTypeHandlerFactory(intentManager, httpServiceManager );
- RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc,
configTypeHandlerFactory );
+ ConfigTypeHandlerFactory configTypeHandlerFactory = new
ConfigTypeHandlerFactory(intentManager, httpServiceManager, config);
+ RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc,
configTypeHandlerFactory);
RemoteServiceadminFactory rsaf = new
RemoteServiceadminFactory(rsaCore);
Hashtable<String, Object> props = new Hashtable<String, Object>();
-
- // TODO .... RemoteAdminService.XXX
- // props.put(DistributionProvider.PRODUCT_NAME,
getHeader("Bundle-Name"));
- // props.put(DistributionProvider.PRODUCT_VERSION,
getHeader("Bundle-Version"));
- // props.put(DistributionProvider.VENDOR_NAME,
getHeader("Bundle-Vendor"));
-
String[] supportedIntents = intentMap.keySet().toArray(new String[]
{});
String siString = IntentUtils.formatIntents(supportedIntents);
props.put("remote.intents.supported", siString);
-
- // // TODO make this a little smarter
- String[] supportedConfigs = {
-
org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE,
-
org.apache.cxf.dosgi.dsw.Constants.WS_CONFIG_TYPE_OLD,
-
org.apache.cxf.dosgi.dsw.Constants.RS_CONFIG_TYPE
- };
- props.put("remote.configs.supported", supportedConfigs);
+ props.put("remote.configs.supported",
configTypeHandlerFactory.getSupportedConfigurationTypes());
LOG.info("Registering RemoteServiceAdminFactory...");
rsaFactoryReg = bc.registerService(RemoteServiceAdmin.class.getName(),
rsaf, props);
decoratorReg = bc.registerService(ServiceDecorator.class.getName(),
new ServiceDecoratorImpl(bc), null);
}
+ private void registerManagedService(BundleContext bc) {
+ Dictionary<String, String> props = new Hashtable<String, String>();
+ props.put(Constants.SERVICE_PID, CONFIG_SERVICE_PID);
+ bc.registerService(ManagedService.class.getName(), this, props);
+ }
+
public void stop(BundleContext context) throws Exception {
LOG.debug("RemoteServiceAdmin Implementation is shutting down now");
- intentTracker.close();
- // This also triggers the unimport and unexport of the remote services
- rsaFactoryReg.unregister();
- decoratorReg.unregister();
-
- // shutdown the CXF Bus -> Causes also the shutdown of the embedded
HTTP server
- Bus b = BusFactory.getDefaultBus();
- if (b != null) {
- LOG.debug("Shutting down the CXF Bus");
- b.shutdown(true);
+ if (intentTracker != null) {
+ intentTracker.close();
+ // This also triggers the unimport and unexport of the remote
services
+ rsaFactoryReg.unregister();
+ decoratorReg.unregister();
+ // shutdown the CXF Bus -> Causes also the shutdown of the
embedded HTTP server
+ Bus b = BusFactory.getDefaultBus();
+ if (b != null) {
+ LOG.debug("Shutting down the CXF Bus");
+ b.shutdown(true);
+ }
+ intentTracker = null;
+ rsaFactoryReg = null;
+ decoratorReg = null;
}
+ }
- // unregister other registered services (ManagedService + Hooks)
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ public synchronized void updated(Dictionary config) throws
ConfigurationException {
+ if (rsaFactoryReg != null) {
+ try {
+ stop(bc);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+ if (config != null) {
+ HashMap<String, Object> configMap = getMapFromDictionary(config);
+ start(bc, configMap);
+ }
}
- @SuppressWarnings("rawtypes")
- public synchronized void updated(Dictionary props) throws
ConfigurationException {
- if (props != null &&
CONFIG_SERVICE_PID.equals(props.get(Constants.SERVICE_PID))) {
- // topManager.updated(props);
+ private HashMap<String, Object> getMapFromDictionary(Dictionary<String,
Object> config) {
+ HashMap<String, Object> configMap = new HashMap<String, Object>();
+ if (config == null) {
+ return configMap;
}
+ Enumeration<String> keys = config.keys();
+ while (keys.hasMoreElements()) {
+ String key = (String) keys.nextElement();
+ configMap.put(key, config.get(key));
+ }
+ return configMap;
}
+
}
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/Constants.java
Wed Nov 28 17:38:16 2012
@@ -98,16 +98,22 @@ public class Constants {
// Common Configuration Properties
public static final String CHECK_BUNDLE = "check.bundle";
+
+ // The following constants are not evaluated anymore
+ @Deprecated
public static final String DEFAULT_PORT_CONFIG = "default.port";
+ @Deprecated
public static final String DEFAULT_HOST_CONFIG = "default.host";
+ @Deprecated
public static final String DEFAULT_PORT_VALUE = "9000";
+ @Deprecated
public static final String DEFAULT_HOST_VALUE = "localhost";
+ @Deprecated
public final static String USE_MASTER_MAP = "use.master.map";
-
//DSW Identification - TODO do we really need this one?
public static final String DSW_CLIENT_ID = PROVIDER_PREFIX +
".remote.dsw.client";
public static final String INTENT_NAME_PROP =
"org.apache.cxf.dosgi.IntentName";
-
+ public static final Object SERVLET_BASE = "servletBase";
}
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractConfigurationHandler.java
Wed Nov 28 17:38:16 2012
@@ -19,7 +19,6 @@
package org.apache.cxf.dosgi.dsw.handlers;
import java.lang.reflect.Proxy;
-import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -36,69 +35,31 @@ import org.slf4j.LoggerFactory;
public abstract class AbstractConfigurationHandler implements
ConfigurationTypeHandler {
private static final Logger LOG =
LoggerFactory.getLogger(AbstractConfigurationHandler.class);
- private final Map<String, Object> handlerProps;
protected IntentManager intentManager;
protected BundleContext bundleContext;
+ private String servletBase = null;
protected AbstractConfigurationHandler(BundleContext dswBC, IntentManager
intentManager, Map<String, Object> handlerProps) {
this.bundleContext = dswBC;
this.intentManager = intentManager;
- this.handlerProps = handlerProps;
+ if (handlerProps != null) {
+ this.servletBase = (String)
handlerProps.get(Constants.SERVLET_BASE);
+ }
+ if (this.servletBase == null) {
+ // This default only works for Apache Karaf and cxf with default
settings
+ this.servletBase = "http://" + LocalHostUtil.getLocalIp() +
":8181/cxf";
+ }
}
protected String getDefaultAddress(Class<?> type) {
- return getDefaultAddress(type, null);
- }
-
- protected String getDefaultAddress(Class<?> type, String port) {
- Object h = handlerProps.get(Constants.DEFAULT_HOST_CONFIG);
- if (h == null || h.toString().equals("localhost")) {
- h = LocalHostUtil.getLocalHostAddress();
- }
- String host = h.toString();
-
- if (port == null) {
- Object p = handlerProps.get(Constants.DEFAULT_PORT_CONFIG);
- if (p == null) {
- p = "9000";
- }
- port = p.toString();
- }
- return getAddress("http", host, port, "/" +
type.getName().replace('.', '/'));
+ return "/" + type.getName().replace('.', '/');
}
- protected String getAddress(String scheme, String host, String port,
String context) {
- StringBuilder buf = new StringBuilder();
-
buf.append(scheme).append("://").append(host).append(':').append(port).append(context);
- return buf.toString();
- }
-
protected String constructAddress(BundleContext ctx, String contextRoot,
String relativeEndpointAddress) {
if (relativeEndpointAddress.startsWith("http")) {
return relativeEndpointAddress;
}
- boolean https =
"true".equalsIgnoreCase(ctx.getProperty("org.osgi.service.http.secure.enabled"));
- String port = ctx.getProperty(https ?
"org.osgi.service.http.port.secure" : "org.osgi.service.http.port");
- if (port == null) {
- port = "8080";
- }
-
- String hostName = null;
- try {
- hostName = LocalHostUtil.getLocalHost().getHostAddress();
- } catch (UnknownHostException e) {
- hostName = "localhost";
- }
-
- String address = getAddress(https ? "https" : "http", hostName, port,
contextRoot);
- if (!isEmpty(relativeEndpointAddress) &&
!relativeEndpointAddress.equals("/")) {
- address += relativeEndpointAddress;
- }
- return address;
- }
-
- private boolean isEmpty(String relativeEndpointAddress) {
- return relativeEndpointAddress == null ||
"".equals(relativeEndpointAddress);
+ return this.servletBase + relativeEndpointAddress;
}
protected Object getProxy(Object serviceProxy, Class<?> iType) {
@@ -122,7 +83,7 @@ public abstract class AbstractConfigurat
props.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID,
OsgiUtils.getUUID(bundleContext));
props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
props.put(RemoteConstants.ENDPOINT_PACKAGE_VERSION_ + pkg,
- OsgiUtils.getVersion(iClass, bundleContext));
+ OsgiUtils.getVersion(iClass, bundleContext));
for (String configurationType : importedConfigs) {
if(Constants.WS_CONFIG_TYPE.equals(configurationType))
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/AbstractPojoConfigurationTypeHandler.java
Wed Nov 28 17:38:16 2012
@@ -165,19 +165,7 @@ public abstract class AbstractPojoConfig
LOG.error(e.getMessage(), e);
return null;
}
- if (address == null) {
- String port = null;
- Object p = sd.get(Constants.WS_PORT_PROPERTY);
- if (p instanceof String) {
- port = (String) p;
- }
-
- address = getDefaultAddress(iClass, port);
- if (address != null) {
- LOG.info("Using a default address : " + address);
- }
- }
- return address;
+ return (address == null) ? getDefaultAddress(iClass) : address;
}
protected final ExportResult createServerFromFactory(ServerFactoryBean
factory, Map<String, Object> endpointProps) {
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactory.java
Wed Nov 28 17:38:16 2012
@@ -38,40 +38,38 @@ import org.slf4j.LoggerFactory;
public class ConfigTypeHandlerFactory {
private static Logger LOG =
LoggerFactory.getLogger(ConfigTypeHandlerFactory.class);
// protected because of tests
- protected static final List<String> supportedConfigurationTypes = new
ArrayList<String>();
-
- static {
- supportedConfigurationTypes.add(Constants.WSDL_CONFIG_TYPE);
- supportedConfigurationTypes.add(Constants.RS_CONFIG_TYPE);
- supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE);
- supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE_OLD);
- }
+ protected final List<String> supportedConfigurationTypes;
protected final static String DEFAULT_CONFIGURATION_TYPE =
Constants.WS_CONFIG_TYPE;
private IntentManager intentManager;
private HttpServiceManager httpServiceManager;
+ private Map<String, Object> props;
- public ConfigTypeHandlerFactory(IntentManager intentManager,
HttpServiceManager httpServiceManager) {
+ public ConfigTypeHandlerFactory(IntentManager intentManager,
HttpServiceManager httpServiceManager, Map<String, Object> props) {
+ supportedConfigurationTypes = new ArrayList<String>();
+ supportedConfigurationTypes.add(Constants.WSDL_CONFIG_TYPE);
+ supportedConfigurationTypes.add(Constants.RS_CONFIG_TYPE);
+ supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE);
+ supportedConfigurationTypes.add(Constants.WS_CONFIG_TYPE_OLD);
this.intentManager = intentManager;
this.httpServiceManager = httpServiceManager;
+ this.props = props;
}
public ConfigurationTypeHandler getHandler(BundleContext dswBC,
- Map<String, Object> serviceProperties,
- Map<String, Object> props) {
+ Map<String, Object> serviceProperties) {
List<String> configurationTypes =
determineConfigurationTypes(serviceProperties);
- return getHandler(dswBC, configurationTypes, serviceProperties, props);
+ return getHandler(dswBC, configurationTypes, serviceProperties);
}
public ConfigurationTypeHandler getHandler(BundleContext dswBC,
EndpointDescription endpoint) {
List<String> configurationTypes =
determineConfigTypesForImport(endpoint);
- return getHandler(dswBC, configurationTypes, endpoint.getProperties(),
Collections.<String, Object>emptyMap());
+ return getHandler(dswBC, configurationTypes, endpoint.getProperties());
}
private ConfigurationTypeHandler getHandler(BundleContext dswBC,
List<String> configurationTypes,
- Map<String, Object>
serviceProperties,
- Map<String, Object> props) {
+ Map<String, Object>
serviceProperties) {
intentManager.assertAllIntentsSupported(serviceProperties);
if (configurationTypes.contains(Constants.WS_CONFIG_TYPE)
|| configurationTypes.contains(Constants.WS_CONFIG_TYPE_OLD) ||
configurationTypes.contains(Constants.RS_CONFIG_TYPE)) {
@@ -161,4 +159,8 @@ public class ConfigTypeHandlerFactory {
return usableConfigurationTypes;
}
+ public List<String> getSupportedConfigurationTypes() {
+ return supportedConfigurationTypes;
+ }
+
}
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/LocalHostUtil.java
Wed Nov 28 17:38:16 2012
@@ -88,4 +88,15 @@ public class LocalHostUtil {
return "localhost";
}
}
+
+ public static String getLocalIp() {
+ String localIP;
+ try {
+ localIP = LocalHostUtil.getLocalHost().getHostAddress();
+ } catch (Exception e) {
+ localIP = "localhost";
+ }
+ return localIP;
+ }
+
}
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/qos/IntentUtils.java
Wed Nov 28 17:38:16 2012
@@ -30,11 +30,8 @@ import org.apache.cxf.dosgi.dsw.Constant
import org.apache.cxf.dosgi.dsw.util.OsgiUtils;
import org.apache.cxf.dosgi.dsw.util.Utils;
import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class IntentUtils {
- private static final Logger LOG =
LoggerFactory.getLogger(IntentUtils.class);
public static String formatIntents(String[] intents) {
StringBuilder sb = new StringBuilder();
@@ -83,6 +80,7 @@ public class IntentUtils {
public static Set<String> getRequestedIntents(Map<?, ?> sd) {
Collection<String> intents = Arrays.asList(
IntentUtils.parseIntents(OsgiUtils.getProperty(sd,
RemoteConstants.SERVICE_EXPORTED_INTENTS)));
+ @SuppressWarnings("deprecation")
Collection<String> oldIntents = Arrays.asList(
IntentUtils.parseIntents(OsgiUtils.getProperty(sd,
Constants.EXPORTED_INTENTS_OLD)));
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCore.java
Wed Nov 28 17:38:16 2012
@@ -31,7 +31,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
-import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.dosgi.dsw.handlers.ConfigTypeHandlerFactory;
import org.apache.cxf.dosgi.dsw.handlers.ConfigurationTypeHandler;
import org.apache.cxf.dosgi.dsw.handlers.ExportResult;
@@ -62,10 +61,6 @@ public class RemoteServiceAdminCore impl
private BundleContext bctx;
private EventProducer eventProducer;
- private volatile boolean useMasterMap = true;
- private volatile String defaultPort;
- private volatile String defaultHost;
-
private ConfigTypeHandlerFactory configTypeHandlerFactory;
public RemoteServiceAdminCore(BundleContext bc, ConfigTypeHandlerFactory
configTypeHandlerFactory) {
@@ -113,7 +108,7 @@ public class RemoteServiceAdminCore impl
BundleContext callingContext =
serviceReference.getBundle().getBundleContext();
ConfigurationTypeHandler handler = null;
try {
- handler = configTypeHandlerFactory.getHandler(bctx,
(Map)serviceProperties, getHandlerProperties());
+ handler = configTypeHandlerFactory.getHandler(bctx,
(Map)serviceProperties);
} catch (RuntimeException e) {
LOG.error(e.getMessage(), e);
return Collections.emptyList();
@@ -241,16 +236,6 @@ public class RemoteServiceAdminCore impl
}
}
- protected Map<String, Object> getHandlerProperties() {
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.DEFAULT_PORT_CONFIG, defaultPort == null
- ? Constants.DEFAULT_PORT_VALUE : defaultPort);
- props.put(Constants.DEFAULT_HOST_CONFIG, defaultHost == null
- ? Constants.DEFAULT_HOST_VALUE : defaultHost);
- props.put(Constants.USE_MASTER_MAP, useMasterMap);
- return props;
- }
-
/**
* Importing form here ....
*/
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ConfigTypeHandlerFactoryTest.java
Wed Nov 28 17:38:16 2012
@@ -86,7 +86,7 @@ public class ConfigTypeHandlerFactoryTes
IntentMap intentMap = new IntentMap(new
DefaultIntentMapFactory().create());
IntentManager intentManager = new IntentManagerImpl(intentMap);
HttpServiceManager httpServiceManager = new HttpServiceManager(bc);
- ConfigTypeHandlerFactory f = new
ConfigTypeHandlerFactory(intentManager, httpServiceManager );
- return f.getHandler(bc, serviceProps, null);
+ ConfigTypeHandlerFactory f = new
ConfigTypeHandlerFactory(intentManager, httpServiceManager, null);
+ return f.getHandler(bc, serviceProps);
}
}
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/PojoConfigurationTypeHandlerTest.java
Wed Nov 28 17:38:16 2012
@@ -84,47 +84,14 @@ public class PojoConfigurationTypeHandle
assertEquals(url, handler.getServerAddress(sd, String.class));
}
- public void testGetPojoAddressDefaultWithAlternatePort() {
- Map<String, Object> hp = new HashMap<String, Object>();
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler handler = new
PojoConfigurationTypeHandler(null, intentManager , dummyHttpServiceManager(),
hp);
- Map<String, Object> sd = new HashMap<String, Object>();
- String localIP = getLocalIp();
- String url = "http://"+localIP+":1234/java/lang/String";
- sd.put("org.apache.cxf.ws.port", "1234");
- assertEquals(url, handler.getServerAddress(sd, String.class));
- }
-
public void testGetDefaultPojoAddress() {
Map<String, Object> hp = new HashMap<String, Object>();
IntentManager intentManager = new IntentManagerImpl(new IntentMap());
PojoConfigurationTypeHandler handler = new
PojoConfigurationTypeHandler(null, intentManager , dummyHttpServiceManager(),
hp);
Map<String, Object> sd = new HashMap<String, Object>();
- String localIP = getLocalIp();
- assertEquals("http://"+localIP+":9000/java/lang/String",
handler.getServerAddress(sd, String.class));
+ assertEquals("/java/lang/String", handler.getServerAddress(sd,
String.class));
}
- private String getLocalIp() {
- String localIP;
- try {
- localIP = LocalHostUtil.getLocalHost().getHostAddress();
- } catch (Exception e) {
- localIP = "localhost";
- }
- return localIP;
- }
-
- private Map<String, Object> handlerProps;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- handlerProps = new HashMap<String, Object>();
- handlerProps.put(Constants.DEFAULT_HOST_CONFIG, "somehost");
- handlerProps.put(Constants.DEFAULT_PORT_CONFIG, "54321");
- }
-
// todo: add test for data bindings
public void testCreateProxy(){
IMocksControl c = EasyMock.createNiceControl();
@@ -142,14 +109,14 @@ public class PojoConfigurationTypeHandle
return new String[0];
}
};
- PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(bc1,
intentManager, dummyHttpServiceManager(), handlerProps) {
+ PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(bc1,
intentManager, dummyHttpServiceManager(), null) {
@Override
ClientProxyFactoryBean
createClientProxyFactoryBean(ServiceReference sRef, Class<?> iClass) {
return cpfb;
}
};
- Map props = new HashMap();
+ Map<String, Object> props = new HashMap<String, Object>();
props.put(RemoteConstants.ENDPOINT_ID, "http://google.de/");
props.put(org.osgi.framework.Constants.OBJECTCLASS, new
String[]{"my.class"});
@@ -164,26 +131,10 @@ public class PojoConfigurationTypeHandle
EasyMock.expectLastCall().atLeastOnce();
c.replay();
-
-
-
-
-
Object proxy = p.createProxy(sref, bc1, bc2, CharSequence.class,
endpoint);
-
assertNotNull(proxy);
-
- if (proxy instanceof CharSequence) {
- CharSequence cs = (CharSequence)proxy;
-
- }else{
- assertTrue("Proxy is not of the requested type! ", false);
- }
-
-
-
+ assertTrue("Proxy is not of the requested type! ", proxy instanceof
CharSequence);
c.verify();
-
}
// public void testCreateProxyPopulatesDistributionProvider() {
@@ -279,7 +230,7 @@ public class PojoConfigurationTypeHandle
return new String []{};
}
};
- PojoConfigurationTypeHandler p = new
PojoConfigurationTypeHandler(dswContext, intentManager,
dummyHttpServiceManager(), handlerProps) {
+ PojoConfigurationTypeHandler p = new
PojoConfigurationTypeHandler(dswContext, intentManager,
dummyHttpServiceManager(), null) {
@Override
ServerFactoryBean createServerFactoryBean(ServiceReference sRef,
Class<?> iClass) {
return sfb;
@@ -297,7 +248,7 @@ public class PojoConfigurationTypeHandle
ExportResult exportResult = p.createServer(sr, dswContext,
callingContext, props, String.class, myService);
- Map edProps = exportResult.getEndpointProps();
+ Map<String, Object> edProps = exportResult.getEndpointProps();
assertNotNull(edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
assertEquals(1,
((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS)).length);
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/qos/IntentManagerImplTest.java
Wed Nov 28 17:38:16 2012
@@ -32,24 +32,14 @@ import java.util.Set;
import junit.framework.Assert;
import org.apache.cxf.binding.BindingConfiguration;
-import org.apache.cxf.dosgi.dsw.Constants;
import org.apache.cxf.endpoint.AbstractEndpointFactory;
import org.apache.cxf.feature.AbstractFeature;
import org.apache.cxf.feature.Feature;
import org.easymock.classextension.EasyMock;
import org.easymock.classextension.IMocksControl;
-import org.junit.Before;
import org.junit.Test;
public class IntentManagerImplTest {
- private Map<String, Object> handlerProps;
-
- @Before
- public void setUp() throws Exception {
- handlerProps = new HashMap<String, Object>();
- handlerProps.put(Constants.DEFAULT_HOST_CONFIG, "somehost");
- handlerProps.put(Constants.DEFAULT_PORT_CONFIG, "54321");
- }
@Test
public void testIntents() throws Exception {
@@ -219,7 +209,6 @@ public class IntentManagerImplTest {
}
public void testInheritMasterIntentMap() {
- handlerProps.put(Constants.USE_MASTER_MAP, "true");
List<String> features = runTestInheritMasterIntentMap("A B");
assertEquals(2, features.size());
Modified:
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
URL:
http://svn.apache.org/viewvc/cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java?rev=1414835&r1=1414834&r2=1414835&view=diff
==============================================================================
---
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
(original)
+++
cxf/dosgi/trunk/dsw/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/service/RemoteServiceAdminCoreTest.java
Wed Nov 28 17:38:16 2012
@@ -105,7 +105,7 @@ public class RemoteServiceAdminCoreTest
IntentMap intentMap = new IntentMap(new
DefaultIntentMapFactory().create());
IntentManager intentManager = new IntentManagerImpl(intentMap, 10000);
HttpServiceManager httpServiceManager =
c.createMock(HttpServiceManager.class);
- ConfigTypeHandlerFactory configTypeHandlerFactory = new
ConfigTypeHandlerFactory(intentManager, httpServiceManager);
+ ConfigTypeHandlerFactory configTypeHandlerFactory = new
ConfigTypeHandlerFactory(intentManager, httpServiceManager, null);
RemoteServiceAdminCore rsaCore = new RemoteServiceAdminCore(bc,
configTypeHandlerFactory ) {
@Override
protected void proxifyMatchingInterface(String interfaceName,
ImportRegistrationImpl imReg,