You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by cs...@apache.org on 2016/07/05 15:27:12 UTC
[1/3] cxf-dosgi git commit: [DOSGI-245] Split cxf provider into rs
and ws provider
Repository: cxf-dosgi
Updated Branches:
refs/heads/master ccf5a7a73 -> f0dea5061
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
----------------------------------------------------------------------
diff --git a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
new file mode 100644
index 0000000..050c642
--- /dev/null
+++ b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
@@ -0,0 +1,229 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.rest;
+
+import static org.apache.cxf.dosgi.common.util.OsgiUtils.getMultiValueProperty;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED;
+
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.aries.rsa.spi.DistributionProvider;
+import org.apache.aries.rsa.spi.Endpoint;
+import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.util.ProxyClassLoader;
+import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.common.intent.IntentManager;
+import org.apache.cxf.dosgi.common.proxy.ProxyFactory;
+import org.apache.cxf.dosgi.common.util.OsgiUtils;
+import org.apache.cxf.dosgi.common.util.ServerWrapper;
+import org.apache.cxf.endpoint.AbstractEndpointFactory;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.client.Client;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component(property = //
+{//
+ REMOTE_CONFIGS_SUPPORTED + "=" + RsConstants.RS_CONFIG_TYPE,
+ REMOTE_INTENTS_SUPPORTED + "="
+})
+public class RsProvider implements DistributionProvider {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RsProvider.class);
+ private IntentManager intentManager;
+ private HttpServiceManager httpServiceManager;
+
+ @Reference
+ public void setHttpServiceManager(HttpServiceManager httpServiceManager) {
+ this.httpServiceManager = httpServiceManager;
+ }
+
+ @Reference
+ public void setIntentManager(IntentManager intentManager) {
+ this.intentManager = intentManager;
+ }
+
+ public String[] getSupportedTypes() {
+ return new String[] {RsConstants.RS_CONFIG_TYPE};
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object importEndpoint(ClassLoader consumerLoader,
+ BundleContext consumerContext,
+ Class[] interfaces,
+ EndpointDescription endpoint) {
+ intentManager.assertAllIntentsSupported(endpoint.getProperties());
+ Class<?> iClass = interfaces[0];
+ String address = OsgiUtils.getProperty(endpoint, RsConstants.RS_ADDRESS_PROPERTY);
+ if (address == null) {
+ LOG.warn("Remote address is unavailable");
+ return null;
+ }
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(JAXRSClientFactoryBean.class.getClassLoader());
+ return createJaxrsProxy(address, consumerContext, iClass, null, endpoint);
+ } catch (Throwable e) {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+
+ try {
+ ProxyClassLoader cl = new ProxyClassLoader(iClass.getClassLoader());
+ cl.addLoader(Client.class.getClassLoader());
+ return createJaxrsProxy(address, consumerContext, iClass, cl, endpoint);
+ } catch (Throwable e) {
+ LOG.warn("proxy creation failed", e);
+ }
+
+ return null;
+ }
+
+ protected Object createJaxrsProxy(String address,
+ BundleContext callingContext,
+ Class<?> iClass,
+ ClassLoader loader,
+ EndpointDescription endpoint) {
+ JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+ bean.setAddress(address);
+ if (loader != null) {
+ bean.setClassLoader(loader);
+ }
+ addContextProperties(bean, endpoint.getProperties(), RsConstants.RS_CONTEXT_PROPS_PROP_KEY);
+ bean.setServiceClass(iClass);
+ intentManager.applyIntents(bean.getFeatures(), bean, endpoint.getProperties());
+ return ProxyFactory.create(bean.create(), iClass);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Endpoint exportService(Object serviceBean,
+ BundleContext callingContext,
+ Map<String, Object> endpointProps,
+ Class[] exportedInterfaces) throws IntentUnsatisfiedException {
+ if (!configTypeSupported(endpointProps, RsConstants.RS_CONFIG_TYPE)) {
+ return null;
+ }
+ String contextRoot = OsgiUtils.getProperty(endpointProps, RsConstants.RS_HTTP_SERVICE_CONTEXT);
+ String address;
+ Class<?> iClass = exportedInterfaces[0];
+ if (contextRoot == null) {
+ address = getServerAddress(endpointProps, iClass);
+ } else {
+ address = OsgiUtils.getProperty(endpointProps, RsConstants.RS_ADDRESS_PROPERTY);
+ if (address == null) {
+ address = "/";
+ }
+ }
+ final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
+ intentManager.assertAllIntentsSupported(endpointProps);
+ Bus bus = BusFactory.newInstance().createBus();
+ if (contextRoot != null) {
+ httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid);
+ }
+ LOG.info("Creating JAXRS endpoint for " + iClass.getName() + " with address " + address);
+
+ JAXRSServerFactoryBean factory = createServerFactory(callingContext, endpointProps,
+ iClass, serviceBean, address, bus);
+ String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, endpointProps);
+ String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
+ EndpointDescription epd = createEndpointDesc(endpointProps, new String[] {RsConstants.RS_CONFIG_TYPE},
+ completeEndpointAddress, intents);
+ return createServerFromFactory(factory, epd);
+ }
+
+ private boolean configTypeSupported(Map<String, Object> endpointProps, String configType) {
+ Collection<String> configs = getMultiValueProperty(endpointProps.get(RemoteConstants.SERVICE_EXPORTED_CONFIGS));
+ return configs == null || configs.isEmpty() || configs.contains(configType);
+ }
+
+ private Endpoint createServerFromFactory(JAXRSServerFactoryBean factory,
+ EndpointDescription epd) {
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
+ Server server = factory.create();
+ return new ServerWrapper(epd, server);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ }
+
+ private JAXRSServerFactoryBean createServerFactory(BundleContext callingContext,
+ Map<String, Object> sd,
+ Class<?> iClass,
+ Object serviceBean,
+ String address,
+ Bus bus) {
+ JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
+ factory.setBus(bus);
+ factory.setServiceClass(iClass);
+ factory.setResourceProvider(iClass, new SingletonResourceProvider(serviceBean));
+ factory.setAddress(address);
+ addContextProperties(factory, sd, RsConstants.RS_CONTEXT_PROPS_PROP_KEY);
+ String location = OsgiUtils.getProperty(sd, RsConstants.RS_WADL_LOCATION);
+ setWadlLocation(callingContext, factory, location);
+ return factory;
+ }
+
+ private void setWadlLocation(BundleContext callingContext, JAXRSServerFactoryBean factory,
+ String location) {
+ if (location != null) {
+ URL wadlURL = callingContext.getBundle().getResource(location);
+ if (wadlURL != null) {
+ factory.setDocLocation(wadlURL.toString());
+ }
+ }
+ }
+
+ protected EndpointDescription createEndpointDesc(Map<String, Object> props,
+ String[] importedConfigs,
+ String address,
+ String[] intents) {
+ props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
+ props.put(RsConstants.RS_ADDRESS_PROPERTY, address);
+ props.put(RemoteConstants.SERVICE_INTENTS, intents);
+ props.put(RemoteConstants.ENDPOINT_ID, address);
+ return new EndpointDescription(props);
+ }
+
+ protected String getServerAddress(Map<String, Object> sd, Class<?> iClass) {
+ String address = OsgiUtils.getProperty(sd, RsConstants.RS_ADDRESS_PROPERTY);
+ return address == null ? httpServiceManager.getDefaultAddress(iClass) : address;
+ }
+
+ private static void addContextProperties(AbstractEndpointFactory factory, Map<String, Object> sd, String propName) {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> props = (Map<String, Object>)sd.get(propName);
+ if (props != null) {
+ factory.getProperties(true).putAll(props);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/bnd.bnd
----------------------------------------------------------------------
diff --git a/provider-ws/bnd.bnd b/provider-ws/bnd.bnd
new file mode 100644
index 0000000..99f067a
--- /dev/null
+++ b/provider-ws/bnd.bnd
@@ -0,0 +1,3 @@
+Import-Package: javax.servlet;version='[2,4)', javax.servlet.http;version='[2,4)', *
+
+Private-Package: org.apache.cxf.dosgi.dsw.*
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/pom.xml
----------------------------------------------------------------------
diff --git a/provider-ws/pom.xml b/provider-ws/pom.xml
new file mode 100644
index 0000000..21e741f
--- /dev/null
+++ b/provider-ws/pom.xml
@@ -0,0 +1,61 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-dosgi-ri-provider-ws</artifactId>
+ <packaging>bundle</packaging>
+ <name>CXF dOSGi provider ws</name>
+
+ <parent>
+ <groupId>org.apache.cxf.dosgi</groupId>
+ <artifactId>cxf-dosgi-ri-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <properties>
+ <topDirectoryLocation>..</topDirectoryLocation>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf.dosgi</groupId>
+ <artifactId>cxf-dosgi-ri-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-core</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-databinding-aegis</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsConstants.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsConstants.java b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsConstants.java
new file mode 100644
index 0000000..196a0e5
--- /dev/null
+++ b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsConstants.java
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.ws;
+
+public final class WsConstants {
+ public static final String WS_CONFIG_TYPE = "org.apache.cxf" + ".ws";
+ public static final String WS_ADDRESS_PROPERTY = WS_CONFIG_TYPE + ".address";
+ public static final String WS_PORT_PROPERTY = WS_CONFIG_TYPE + ".port";
+ public static final String WS_HTTP_SERVICE_CONTEXT = WS_CONFIG_TYPE + ".httpservice.context";
+
+ public static final String WS_FRONTEND_PROP_KEY = WS_CONFIG_TYPE + ".frontend";
+ public static final String WS_FRONTEND_JAXWS = "jaxws";
+ public static final String WS_FRONTEND_SIMPLE = "simple";
+
+ public static final String WS_CONTEXT_PROPS_PROP_KEY = WS_CONFIG_TYPE + ".context.properties";
+
+ public static final String WS_DATABINDING_PROP_KEY = WS_CONFIG_TYPE + ".databinding";
+ public static final String WS_DATABINDING_BEAN_PROP_KEY = WS_DATABINDING_PROP_KEY + ".bean";
+ public static final String WS_DATA_BINDING_JAXB = "jaxb";
+ public static final String WS_DATA_BINDING_AEGIS = "aegis";
+
+ public static final String WS_WSDL_SERVICE_NAMESPACE = WS_CONFIG_TYPE + ".service.ns";
+ public static final String WS_WSDL_SERVICE_NAME = WS_CONFIG_TYPE + ".service.name";
+ public static final String WS_WSDL_PORT_NAME = WS_CONFIG_TYPE + ".port.name";
+ public static final String WS_WSDL_LOCATION = WS_CONFIG_TYPE + ".wsdl.location";
+
+ private WsConstants() {
+ // never constructed
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
new file mode 100644
index 0000000..e4cbcdc
--- /dev/null
+++ b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
@@ -0,0 +1,244 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.ws;
+
+import static org.apache.cxf.dosgi.common.util.OsgiUtils.getMultiValueProperty;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED;
+
+import java.util.Collection;
+import java.util.Map;
+
+import javax.jws.WebService;
+
+import org.apache.aries.rsa.spi.DistributionProvider;
+import org.apache.aries.rsa.spi.Endpoint;
+import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.binding.soap.SoapBindingConfiguration;
+import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.common.intent.IntentManager;
+import org.apache.cxf.dosgi.common.proxy.ProxyFactory;
+import org.apache.cxf.dosgi.common.util.OsgiUtils;
+import org.apache.cxf.dosgi.common.util.ServerWrapper;
+import org.apache.cxf.endpoint.AbstractEndpointFactory;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxb.JAXBDataBinding;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component(configurationPid = "cxf-dsw", property = //
+{//
+ REMOTE_CONFIGS_SUPPORTED + "=" + WsConstants.WS_CONFIG_TYPE,
+ REMOTE_INTENTS_SUPPORTED + "="
+})
+public class WsProvider implements DistributionProvider {
+ private static final Logger LOG = LoggerFactory.getLogger(WsProvider.class);
+ protected BundleContext bundleContext;
+ protected IntentManager intentManager;
+ protected HttpServiceManager httpServiceManager;
+
+ @Reference
+ public void setHttpServiceManager(HttpServiceManager httpServiceManager) {
+ this.httpServiceManager = httpServiceManager;
+ }
+
+ @Reference
+ public void setIntentManager(IntentManager intentManager) {
+ this.intentManager = intentManager;
+ }
+
+ @Activate
+ public void activate(BundleContext context) {
+ this.bundleContext = context;
+ }
+
+ public String[] getSupportedTypes() {
+ return new String[] {WsConstants.WS_CONFIG_TYPE};
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Object importEndpoint(ClassLoader consumerLoader,
+ BundleContext consumerContext,
+ Class[] interfaces,
+ EndpointDescription endpoint) throws IntentUnsatisfiedException {
+ Class<?> iClass = interfaces[0];
+ Map<String, Object> sd = endpoint.getProperties();
+ String address = getClientAddress(sd);
+ LOG.info("Creating a " + iClass.getName() + " client, endpoint address is " + address);
+
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ ClientProxyFactoryBean factory = createClientProxyFactoryBean(sd, iClass);
+ factory.setDataBinding(getDataBinding(sd, iClass));
+ factory.setBindingConfig(new SoapBindingConfiguration());
+ factory.setServiceClass(iClass);
+ factory.setAddress(address);
+ addContextProperties(factory.getClientFactoryBean(), sd, WsConstants.WS_CONTEXT_PROPS_PROP_KEY);
+ WsdlSupport.setWsdlProperties(factory.getClientFactoryBean(), bundleContext, sd);
+
+ intentManager.assertAllIntentsSupported(sd);
+ intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd);
+
+ Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
+ return ProxyFactory.create(factory.create(), iClass);
+ } catch (Exception e) {
+ LOG.warn("proxy creation failed", e);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Endpoint exportService(Object serviceO,
+ BundleContext serviceContext,
+ Map<String, Object> endpointProps,
+ Class[] exportedInterfaces) throws IntentUnsatisfiedException {
+ if (!configTypeSupported(endpointProps, WsConstants.WS_CONFIG_TYPE)) {
+ return null;
+ }
+ Class<?> iClass = exportedInterfaces[0];
+ String address = getPojoAddress(endpointProps, iClass);
+ ServerFactoryBean factory = createServerFactoryBean(endpointProps, iClass);
+ String contextRoot = OsgiUtils.getProperty(endpointProps, WsConstants.WS_HTTP_SERVICE_CONTEXT);
+
+ final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
+ intentManager.assertAllIntentsSupported(endpointProps);
+ Bus bus = createBus(sid, serviceContext, contextRoot);
+ factory.setDataBinding(getDataBinding(endpointProps, iClass));
+ factory.setBindingConfig(new SoapBindingConfiguration());
+ factory.setBus(bus);
+ factory.setServiceClass(iClass);
+ factory.setAddress(address);
+ factory.setServiceBean(serviceO);
+ addContextProperties(factory, endpointProps, WsConstants.WS_CONTEXT_PROPS_PROP_KEY);
+ WsdlSupport.setWsdlProperties(factory, serviceContext, endpointProps);
+ String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, endpointProps);
+
+ String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
+ EndpointDescription epd = createEndpointDesc(endpointProps,
+ new String[]{WsConstants.WS_CONFIG_TYPE},
+ completeEndpointAddress, intents);
+ return createServerFromFactory(factory, epd);
+ }
+
+ private boolean configTypeSupported(Map<String, Object> endpointProps, String configType) {
+ Collection<String> configs = getMultiValueProperty(endpointProps.get(RemoteConstants.SERVICE_EXPORTED_CONFIGS));
+ return configs == null || configs.isEmpty() || configs.contains(configType);
+ }
+
+ protected EndpointDescription createEndpointDesc(Map<String, Object> props,
+ String[] importedConfigs,
+ String address,
+ String[] intents) {
+ props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
+ props.put(WsConstants.WS_ADDRESS_PROPERTY, address);
+ props.put(RemoteConstants.SERVICE_INTENTS, intents);
+ props.put(RemoteConstants.ENDPOINT_ID, address);
+ return new EndpointDescription(props);
+ }
+
+ private String getPojoAddress(Map<String, Object> sd, Class<?> iClass) {
+ String address = getClientAddress(sd);
+ if (address != null) {
+ return address;
+ }
+
+ // If the property is not of type string this will cause an ClassCastException which
+ // will be propagated to the ExportRegistration exception property.
+ Object port = sd.get(WsConstants.WS_PORT_PROPERTY);
+ if (port == null) {
+ port = "9000";
+ }
+
+ address = "http://localhost:" + port + "/" + iClass.getName().replace('.', '/');
+ LOG.info("Using a default address: " + address);
+ return address;
+ }
+
+ protected String getClientAddress(Map<String, Object> sd) {
+ return OsgiUtils.getFirstNonEmptyStringProperty(sd, WsConstants.WS_ADDRESS_PROPERTY,
+ RemoteConstants.ENDPOINT_ID);
+ }
+
+ protected String getServerAddress(Map<String, Object> sd, Class<?> iClass) {
+ String address = getClientAddress(sd);
+ return address == null ? httpServiceManager.getDefaultAddress(iClass) : address;
+ }
+
+ protected Bus createBus(Long sid, BundleContext callingContext, String contextRoot) {
+ Bus bus = BusFactory.newInstance().createBus();
+ if (contextRoot != null) {
+ httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid);
+ }
+ return bus;
+ }
+
+ protected Endpoint createServerFromFactory(ServerFactoryBean factory, EndpointDescription epd) {
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
+ Server server = factory.create();
+ return new ServerWrapper(epd, server);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ }
+
+ protected static void addContextProperties(AbstractEndpointFactory factory,
+ Map<String, Object> sd, String propName) {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> props = (Map<String, Object>)sd.get(propName);
+ if (props != null) {
+ factory.getProperties(true).putAll(props);
+ }
+ }
+
+ private DataBinding getDataBinding(Map<String, Object> sd, Class<?> iClass) {
+ return isJAXWS(sd, iClass) ? new JAXBDataBinding() : new AegisDatabinding();
+ }
+
+ // Isolated so that it can be substituted for testing
+ protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return isJAXWS(sd, iClass) ? new JaxWsProxyFactoryBean() : new ClientProxyFactoryBean();
+ }
+
+ // Isolated so that it can be substituted for testing
+ protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return isJAXWS(sd, iClass) ? new JaxWsServerFactoryBean() : new ServerFactoryBean();
+ }
+
+ private boolean isJAXWS(Map<String, Object> sd, Class<?> iClass) {
+ return iClass.getAnnotation(WebService.class) != null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsdlSupport.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsdlSupport.java b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsdlSupport.java
new file mode 100644
index 0000000..810e445
--- /dev/null
+++ b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsdlSupport.java
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.ws;
+
+import java.net.URL;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.dosgi.common.util.OsgiUtils;
+import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
+import org.osgi.framework.BundleContext;
+
+public final class WsdlSupport {
+
+ private WsdlSupport() {
+ }
+
+ public static void setWsdlProperties(AbstractWSDLBasedEndpointFactory factory, //
+ BundleContext context, //
+ Map<String, Object> sd) {
+ String location = OsgiUtils.getProperty(sd, WsConstants.WS_WSDL_LOCATION);
+ if (location != null) {
+ URL wsdlURL = context.getBundle().getResource(location);
+ if (wsdlURL != null) {
+ factory.setWsdlURL(wsdlURL.toString());
+ }
+ QName serviceName = getServiceQName(null, sd,
+ WsConstants.WS_WSDL_SERVICE_NAMESPACE,
+ WsConstants.WS_WSDL_SERVICE_NAME);
+ if (serviceName != null) {
+ factory.setServiceName(serviceName);
+ QName portName = getPortQName(serviceName.getNamespaceURI(), sd,
+ WsConstants.WS_WSDL_PORT_NAME);
+ if (portName != null) {
+ factory.setEndpointName(portName);
+ }
+ }
+ }
+ }
+
+ protected static QName getServiceQName(Class<?> iClass, Map<String, Object> sd, String nsPropName,
+ String namePropName) {
+ String serviceNs = OsgiUtils.getProperty(sd, nsPropName);
+ String serviceName = OsgiUtils.getProperty(sd, namePropName);
+ if (iClass == null && (serviceNs == null || serviceName == null)) {
+ return null;
+ }
+ if (serviceNs == null) {
+ serviceNs = PackageUtils.getNamespace(PackageUtils.getPackageName(iClass));
+ }
+ if (serviceName == null) {
+ serviceName = iClass.getSimpleName();
+ }
+ return new QName(serviceNs, serviceName);
+ }
+
+ protected static QName getPortQName(String ns, Map<String, Object> sd, String propName) {
+ String portName = OsgiUtils.getProperty(sd, propName);
+ if (portName == null) {
+ return null;
+ }
+ return new QName(ns, portName);
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java
new file mode 100644
index 0000000..7814267
--- /dev/null
+++ b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java
@@ -0,0 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.jaxws;
+
+import javax.jws.WebService;
+
+@WebService
+public interface MyJaxWsEchoService {
+ String echo(String message);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java
new file mode 100644
index 0000000..699c9ae
--- /dev/null
+++ b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.jaxws;
+
+public class MyJaxWsEchoServiceImpl implements MyJaxWsEchoService {
+
+ @Override
+ public String echo(String message) {
+ return message;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java
new file mode 100644
index 0000000..7d574ca
--- /dev/null
+++ b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java
@@ -0,0 +1,23 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.simple;
+
+public interface MySimpleEchoService {
+ String echo(String message);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java
new file mode 100644
index 0000000..19dda4b
--- /dev/null
+++ b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.simple;
+
+public class MySimpleEchoServiceImpl implements MySimpleEchoService {
+
+ @Override
+ public String echo(String message) {
+ return message;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ws/PojoConfigurationTypeHandlerTest.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ws/PojoConfigurationTypeHandlerTest.java b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ws/PojoConfigurationTypeHandlerTest.java
new file mode 100644
index 0000000..4ab9b31
--- /dev/null
+++ b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ws/PojoConfigurationTypeHandlerTest.java
@@ -0,0 +1,415 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.ws;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.xml.namespace.QName;
+
+import org.apache.aries.rsa.spi.Endpoint;
+import org.apache.aries.rsa.util.EndpointHelper;
+import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
+import org.apache.cxf.dosgi.common.intent.IntentManager;
+import org.apache.cxf.dosgi.common.intent.IntentManagerImpl;
+import org.apache.cxf.dosgi.common.util.ServerWrapper;
+import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoService;
+import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoService;
+import org.apache.cxf.endpoint.AbstractEndpointFactory;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.feature.Feature;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.frontend.ServerFactoryBean;
+import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.ws.addressing.AttributedURIType;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+import org.easymock.IMocksControl;
+import org.junit.Assert;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Version;
+import org.osgi.service.remoteserviceadmin.EndpointDescription;
+import org.osgi.service.remoteserviceadmin.RemoteConstants;
+
+import junit.framework.TestCase;
+
+public class PojoConfigurationTypeHandlerTest extends TestCase {
+
+ public void testGetPojoAddressEndpointURI() {
+ IntentManager intentManager = new IntentManagerImpl();
+ WsProvider handler = new WsProvider();
+ handler.setIntentManager(intentManager);
+ handler.setHttpServiceManager(dummyHttpServiceManager());
+ Map<String, Object> sd = new HashMap<String, Object>();
+ String url = "http://somewhere:1234/blah";
+ sd.put(RemoteConstants.ENDPOINT_ID, url);
+ assertEquals(url, handler.getServerAddress(sd, String.class));
+ }
+
+ private HttpServiceManager dummyHttpServiceManager() {
+ return new HttpServiceManager();
+ }
+
+ public void testGetPojoAddressEndpointCxf() {
+ IntentManager intentManager = new IntentManagerImpl();
+ WsProvider handler = new WsProvider();
+ handler.setIntentManager(intentManager);
+ handler.setHttpServiceManager(dummyHttpServiceManager());
+ Map<String, Object> sd = new HashMap<String, Object>();
+ String url = "http://somewhere:29/boo";
+ sd.put("org.apache.cxf.ws.address", url);
+ assertEquals(url, handler.getServerAddress(sd, String.class));
+ }
+
+ public void testGetDefaultPojoAddress() {
+ IntentManager intentManager = new IntentManagerImpl();
+ WsProvider handler = new WsProvider();
+ handler.setIntentManager(intentManager);
+ handler.setHttpServiceManager(dummyHttpServiceManager());
+ Map<String, Object> sd = new HashMap<String, Object>();
+ assertEquals("/java/lang/String", handler.getServerAddress(sd, String.class));
+ }
+
+ // todo: add test for data bindings
+ public void testCreateProxy() {
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext bc1 = c.createMock(BundleContext.class);
+
+ BundleContext requestingContext = c.createMock(BundleContext.class);
+
+ final ClientProxyFactoryBean cpfb = c.createMock(ClientProxyFactoryBean.class);
+ ReflectionServiceFactoryBean sf = c.createMock(ReflectionServiceFactoryBean.class);
+ EasyMock.expect(cpfb.getServiceFactory()).andReturn(sf).anyTimes();
+ IntentManager intentManager = new IntentManagerImpl() {
+ @Override
+ public String[] applyIntents(List<Feature> features,
+ AbstractEndpointFactory factory,
+ Map<String, Object> sd) {
+ return new String[0];
+ }
+ };
+ WsProvider p = new WsProvider() {
+ @Override
+ protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return cpfb;
+ }
+ };
+ p.setIntentManager(intentManager);
+ p.setHttpServiceManager(dummyHttpServiceManager());
+ p.activate(bc1);
+
+ Class<?>[] exportedInterfaces = new Class[]{Runnable.class};
+
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(RemoteConstants.ENDPOINT_ID, "http://google.de/");
+ EndpointHelper.addObjectClass(props, exportedInterfaces);
+ props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, new String[]{"my.config"});
+ EndpointDescription endpoint = new EndpointDescription(props);
+
+ cpfb.setAddress((String)EasyMock.eq(props.get(RemoteConstants.ENDPOINT_ID)));
+ EasyMock.expectLastCall().atLeastOnce();
+
+ cpfb.setServiceClass(EasyMock.eq(Runnable.class));
+ EasyMock.expectLastCall().atLeastOnce();
+
+ c.replay();
+ ClassLoader cl = null;
+ Object proxy = p.importEndpoint(cl, requestingContext, exportedInterfaces, endpoint);
+ assertNotNull(proxy);
+ assertTrue("Proxy is not of the requested type! ", proxy instanceof Runnable);
+ c.verify();
+ }
+
+ public void testCreateServerWithAddressProperty() throws Exception {
+ BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(dswContext);
+
+ String myService = "Hi";
+ final ServerFactoryBean sfb = createMockServerFactoryBean();
+
+ IntentManager intentManager = new IntentManagerImpl() {
+ @Override
+ public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory,
+ Map<String, Object> sd) {
+ return new String[]{};
+ }
+ };
+ WsProvider p = new WsProvider() {
+ @Override
+ protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
+ return sfb;
+ }
+ };
+ p.activate(dswContext);
+ p.setIntentManager(intentManager);
+ p.setHttpServiceManager(dummyHttpServiceManager());
+ BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bundleContext);
+
+ Class<?>[] exportedInterface = new Class[]{String.class};
+ Map<String, Object> props = new HashMap<String, Object>();
+ EndpointHelper.addObjectClass(props, exportedInterface);
+ props.put(WsConstants.WS_ADDRESS_PROPERTY, "http://alternate_host:80/myString");
+
+ Endpoint exportResult = p.exportService(myService, bundleContext, props, exportedInterface);
+ Map<String, Object> edProps = exportResult.description().getProperties();
+
+ assertNotNull(edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
+ assertEquals(1, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS)).length);
+ assertEquals(WsConstants.WS_CONFIG_TYPE, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS))[0]);
+ assertEquals("http://alternate_host:80/myString", edProps.get(RemoteConstants.ENDPOINT_ID));
+ }
+
+ public void testAddressing() throws Exception {
+ runAddressingTest(new HashMap<String, Object>(), "http://localhost:9000/java/lang/Runnable");
+
+ Map<String, Object> p1 = new HashMap<String, Object>();
+ p1.put("org.apache.cxf.ws.address", "http://somewhere");
+ runAddressingTest(p1, "http://somewhere");
+
+ Map<String, Object> p3 = new HashMap<String, Object>();
+ p3.put("org.apache.cxf.ws.port", 65535);
+ runAddressingTest(p3, "http://localhost:65535/java/lang/Runnable");
+
+ Map<String, Object> p4 = new HashMap<String, Object>();
+ p4.put("org.apache.cxf.ws.port", "8181");
+ runAddressingTest(p4, "http://localhost:8181/java/lang/Runnable");
+ }
+
+ private void runAddressingTest(Map<String, Object> properties, String expectedAddress) throws Exception {
+ Class<?>[] exportedInterface = new Class[]{Runnable.class};
+ EndpointHelper.addObjectClass(properties, exportedInterface);
+ BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
+ String expectedUUID = UUID.randomUUID().toString();
+ EasyMock.expect(dswContext.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID)).andReturn(expectedUUID);
+ EasyMock.replay(dswContext);
+
+ IntentManager intentManager = EasyMock.createNiceMock(IntentManager.class);
+ EasyMock.replay(intentManager);
+
+ WsProvider handler = new WsProvider() {
+ @Override
+ protected Endpoint createServerFromFactory(ServerFactoryBean factory,
+ EndpointDescription epd) {
+ return new ServerWrapper(epd, null);
+ }
+ };
+ handler.setIntentManager(intentManager);
+ handler.setHttpServiceManager(dummyHttpServiceManager());
+ handler.activate(dswContext);
+ Runnable myService = EasyMock.createMock(Runnable.class);
+ EasyMock.replay(myService);
+
+ BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(bundleContext);
+
+ Endpoint result = handler.exportService(myService, bundleContext, properties, exportedInterface);
+ Map<String, Object> props = result.description().getProperties();
+ assertEquals(expectedAddress, props.get("org.apache.cxf.ws.address"));
+ Assert.assertArrayEquals(new String[] {"org.apache.cxf.ws"},
+ (String[]) props.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
+ Assert.assertArrayEquals(new String[] {"java.lang.Runnable"},
+ (String[]) props.get(org.osgi.framework.Constants.OBJECTCLASS));
+ }
+
+ public void t2estCreateServerException() {
+ BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.replay(dswContext);
+
+ IntentManager intentManager = EasyMock.createNiceMock(IntentManager.class);
+ EasyMock.replay(intentManager);
+
+ WsProvider handler = new WsProvider() {
+ @Override
+ protected Endpoint createServerFromFactory(ServerFactoryBean factory,
+ EndpointDescription epd) {
+ throw new TestException();
+ }
+ };
+ handler.setIntentManager(intentManager);
+ handler.setHttpServiceManager(dummyHttpServiceManager());
+ handler.activate(dswContext);
+
+ Map<String, Object> props = new HashMap<String, Object>();
+
+ Runnable myService = EasyMock.createMock(Runnable.class);
+ EasyMock.replay(myService);
+ try {
+ handler.exportService(myService, null, props, new Class[]{Runnable.class});
+ fail("Expected TestException");
+ } catch (TestException e) {
+ // Expected
+ }
+ }
+
+ private ServerFactoryBean createMockServerFactoryBean() {
+ ReflectionServiceFactoryBean sf = EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
+ EasyMock.replay(sf);
+
+ final StringBuilder serverURI = new StringBuilder();
+
+ ServerFactoryBean sfb = EasyMock.createNiceMock(ServerFactoryBean.class);
+ Server server = createMockServer(sfb);
+
+ EasyMock.expect(sfb.getServiceFactory()).andReturn(sf).anyTimes();
+ EasyMock.expect(sfb.create()).andReturn(server);
+ sfb.setAddress((String) EasyMock.anyObject());
+ EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
+ public Object answer() throws Throwable {
+ serverURI.setLength(0);
+ serverURI.append(EasyMock.getCurrentArguments()[0]);
+ return null;
+ }
+ });
+ EasyMock.expect(sfb.getAddress()).andAnswer(new IAnswer<String>() {
+ public String answer() throws Throwable {
+ return serverURI.toString();
+ }
+ });
+ EasyMock.replay(sfb);
+ return sfb;
+ }
+
+ private Server createMockServer(final ServerFactoryBean sfb) {
+ AttributedURIType addr = EasyMock.createMock(AttributedURIType.class);
+ EasyMock.expect(addr.getValue()).andAnswer(new IAnswer<String>() {
+ public String answer() throws Throwable {
+ return sfb.getAddress();
+ }
+ });
+ EasyMock.replay(addr);
+
+ EndpointReferenceType er = EasyMock.createMock(EndpointReferenceType.class);
+ EasyMock.expect(er.getAddress()).andReturn(addr);
+ EasyMock.replay(er);
+
+ Destination destination = EasyMock.createMock(Destination.class);
+ EasyMock.expect(destination.getAddress()).andReturn(er);
+ EasyMock.replay(destination);
+
+ Server server = EasyMock.createNiceMock(Server.class);
+ EasyMock.expect(server.getDestination()).andReturn(destination);
+ EasyMock.replay(server);
+ return server;
+ }
+
+ public void testCreateEndpointProps() {
+ BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
+ EasyMock.expect(bc.getProperty("org.osgi.framework.uuid")).andReturn("some_uuid1");
+ EasyMock.replay(bc);
+
+ IntentManager intentManager = new IntentManagerImpl();
+ WsProvider pch = new WsProvider();
+ pch.setIntentManager(intentManager);
+ pch.setHttpServiceManager(dummyHttpServiceManager());
+ pch.activate(bc);
+ Class<?>[] exportedInterfaces = new Class[] {String.class};
+ Map<String, Object> sd = new HashMap<String, Object>();
+ sd.put(org.osgi.framework.Constants.SERVICE_ID, 42);
+ EndpointHelper.addObjectClass(sd, exportedInterfaces);
+ EndpointDescription epd = pch.createEndpointDesc(sd, new String[] {"org.apache.cxf.ws"},
+ "http://localhost:12345", new String[] {"my_intent", "your_intent"});
+
+ assertEquals("http://localhost:12345", epd.getId());
+ assertEquals(Arrays.asList("java.lang.String"), epd.getInterfaces());
+ assertEquals(Arrays.asList("org.apache.cxf.ws"), epd.getConfigurationTypes());
+ assertEquals(Arrays.asList("my_intent", "your_intent"), epd.getIntents());
+ assertEquals(new Version("0.0.0"), epd.getPackageVersion("java.lang"));
+ }
+
+ public void t2estCreateJaxWsEndpointWithoutIntents() {
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext dswBC = c.createMock(BundleContext.class);
+
+ IntentManager intentManager = new DummyIntentManager();
+ WsProvider handler = new WsProvider();
+ handler.setIntentManager(intentManager);
+ handler.setHttpServiceManager(dummyHttpServiceManager());
+ handler.activate(dswBC);
+
+ Map<String, Object> sd = new HashMap<String, Object>();
+ sd.put(WsConstants.WS_ADDRESS_PROPERTY, "/somewhere");
+ BundleContext serviceBC = c.createMock(BundleContext.class);
+ Object myService = null;
+ c.replay();
+
+ ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(myService,
+ serviceBC,
+ sd,
+ new Class[]{MyJaxWsEchoService.class});
+ c.verify();
+
+ org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
+ QName bindingName = ep.getEndpointInfo().getBinding().getName();
+ Assert.assertEquals(JaxWsEndpointImpl.class, ep.getClass());
+ Assert.assertEquals(new QName("http://jaxws.handlers.dsw.dosgi.cxf.apache.org/",
+ "MyJaxWsEchoServiceServiceSoapBinding"),
+ bindingName);
+ }
+
+ public void t2estCreateSimpleEndpointWithoutIntents() {
+ IMocksControl c = EasyMock.createNiceControl();
+ BundleContext dswBC = c.createMock(BundleContext.class);
+
+ IntentManager intentManager = new DummyIntentManager();
+ WsProvider handler = new WsProvider();
+ handler.setIntentManager(intentManager);
+ handler.setHttpServiceManager(dummyHttpServiceManager());
+ handler.activate(dswBC);
+ Map<String, Object> sd = new HashMap<String, Object>();
+ sd.put(WsConstants.WS_ADDRESS_PROPERTY, "/somewhere_else");
+ BundleContext serviceBC = c.createMock(BundleContext.class);
+ c.replay();
+ ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(null, serviceBC, sd,
+ new Class[]{MySimpleEchoService.class});
+ c.verify();
+
+ org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
+ QName bindingName = ep.getEndpointInfo().getBinding().getName();
+ Assert.assertEquals(EndpointImpl.class, ep.getClass());
+ Assert.assertEquals(new QName("http://simple.handlers.dsw.dosgi.cxf.apache.org/",
+ "MySimpleEchoServiceSoapBinding"),
+ bindingName);
+ }
+
+ public static class DummyIntentManager implements IntentManager {
+
+ @Override
+ public String[] applyIntents(List<Feature> features,
+ AbstractEndpointFactory factory,
+ Map<String, Object> props) {
+ return new String[]{};
+ }
+
+ @Override
+ public void assertAllIntentsSupported(Map<String, Object> serviceProperties) {
+ }
+ }
+
+ @SuppressWarnings("serial")
+ public static class TestException extends RuntimeException {
+ }
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/ds/client/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/client/pom.xml b/samples/ds/client/pom.xml
index 3e833d5..625907a 100644
--- a/samples/ds/client/pom.xml
+++ b/samples/ds/client/pom.xml
@@ -18,7 +18,7 @@
<parent>
<groupId>org.apache.cxf.dosgi.samples</groupId>
<artifactId>cxf-dosgi-ri-samples-ds-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<properties>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/ds/impl/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/impl/pom.xml b/samples/ds/impl/pom.xml
index 11bcdcb..25b71b2 100644
--- a/samples/ds/impl/pom.xml
+++ b/samples/ds/impl/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.cxf.dosgi.samples</groupId>
<artifactId>cxf-dosgi-ri-samples-ds-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<properties>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/ds/interface/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/interface/pom.xml b/samples/ds/interface/pom.xml
index 3db2187..04a9378 100644
--- a/samples/ds/interface/pom.xml
+++ b/samples/ds/interface/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf.dosgi.samples</groupId>
<artifactId>cxf-dosgi-ri-samples-ds-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<properties>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/ds/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/pom.xml b/samples/ds/pom.xml
index bd42e92..78deb66 100644
--- a/samples/ds/pom.xml
+++ b/samples/ds/pom.xml
@@ -16,12 +16,12 @@
<artifactId>cxf-dosgi-ri-samples-ds-parent</artifactId>
<packaging>pom</packaging>
<name>Distributed OSGI DS Sample</name>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/greeter/client/pom.xml
----------------------------------------------------------------------
diff --git a/samples/greeter/client/pom.xml b/samples/greeter/client/pom.xml
index b8ece5d..163fcfe 100644
--- a/samples/greeter/client/pom.xml
+++ b/samples/greeter/client/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf.dosgi.samples</groupId>
<artifactId>cxf-dosgi-ri-samples-greeter-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/greeter/impl/pom.xml
----------------------------------------------------------------------
diff --git a/samples/greeter/impl/pom.xml b/samples/greeter/impl/pom.xml
index dbefbd5..928aab3 100644
--- a/samples/greeter/impl/pom.xml
+++ b/samples/greeter/impl/pom.xml
@@ -26,7 +26,7 @@
<parent>
<groupId>org.apache.cxf.dosgi.samples</groupId>
<artifactId>cxf-dosgi-ri-samples-greeter-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/greeter/interface/pom.xml
----------------------------------------------------------------------
diff --git a/samples/greeter/interface/pom.xml b/samples/greeter/interface/pom.xml
index 2161c3a..57e0729 100644
--- a/samples/greeter/interface/pom.xml
+++ b/samples/greeter/interface/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf.dosgi.samples</groupId>
<artifactId>cxf-dosgi-ri-samples-greeter-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java
----------------------------------------------------------------------
diff --git a/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java b/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java
index 1a0d0e0..a04bb4a 100644
--- a/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java
+++ b/samples/greeter/interface/src/main/java/org/apache/cxf/dosgi/samples/greeter/GreeterService.java
@@ -21,7 +21,6 @@ package org.apache.cxf.dosgi.samples.greeter;
import java.util.Map;
public interface GreeterService {
-
Map<GreetingPhrase, String> greetMe(String name);
GreetingPhrase[] greetMe(GreeterData name) throws GreeterException;
}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/greeter/pom.xml
----------------------------------------------------------------------
diff --git a/samples/greeter/pom.xml b/samples/greeter/pom.xml
index 07d14c1..ca2606d 100644
--- a/samples/greeter/pom.xml
+++ b/samples/greeter/pom.xml
@@ -28,7 +28,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/greeter_rest/client/pom.xml
----------------------------------------------------------------------
diff --git a/samples/greeter_rest/client/pom.xml b/samples/greeter_rest/client/pom.xml
index 03425ed..a35bf78 100644
--- a/samples/greeter_rest/client/pom.xml
+++ b/samples/greeter_rest/client/pom.xml
@@ -19,7 +19,7 @@
<parent>
<groupId>org.apache.cxf.dosgi.samples</groupId>
<artifactId>cxf-dosgi-ri-samples-greeter-rest-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/greeter_rest/impl/pom.xml
----------------------------------------------------------------------
diff --git a/samples/greeter_rest/impl/pom.xml b/samples/greeter_rest/impl/pom.xml
index 9ed99fd..2ede1ed 100644
--- a/samples/greeter_rest/impl/pom.xml
+++ b/samples/greeter_rest/impl/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf.dosgi.samples</groupId>
<artifactId>cxf-dosgi-ri-samples-greeter-rest-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/greeter_rest/interface/pom.xml
----------------------------------------------------------------------
diff --git a/samples/greeter_rest/interface/pom.xml b/samples/greeter_rest/interface/pom.xml
index 91b33da..745c0fe 100644
--- a/samples/greeter_rest/interface/pom.xml
+++ b/samples/greeter_rest/interface/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../../../parent/pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/greeter_rest/pom.xml
----------------------------------------------------------------------
diff --git a/samples/greeter_rest/pom.xml b/samples/greeter_rest/pom.xml
index f0dcad0..d757c53 100644
--- a/samples/greeter_rest/pom.xml
+++ b/samples/greeter_rest/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
index 3b0bcb1..251f4bf 100644
--- a/samples/pom.xml
+++ b/samples/pom.xml
@@ -29,7 +29,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/samples/security_filter/pom.xml
----------------------------------------------------------------------
diff --git a/samples/security_filter/pom.xml b/samples/security_filter/pom.xml
index 1c6d0c6..4f58c4d 100644
--- a/samples/security_filter/pom.xml
+++ b/samples/security_filter/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/systests2/multi-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/pom.xml b/systests2/multi-bundle/pom.xml
index cb8b205..4fb0947 100644
--- a/systests2/multi-bundle/pom.xml
+++ b/systests2/multi-bundle/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
index 2e727fe..383d7e9 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/AbstractDosgiTest.java
@@ -46,6 +46,7 @@ import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.cm.ConfigurationAdminOptions;
import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.ops4j.pax.exam.options.extra.VMOption;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -236,8 +237,12 @@ public class AbstractDosgiTest {
systemProperty("pax.exam.osgi.unresolved.fail").value("true"), //
configLogging(),
frameworkStartLevel(100)
- // CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005") //
);
}
+
+ protected static VMOption debug() {
+ return CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
index c66b358..9928db0 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestCustomIntent.java
@@ -51,14 +51,15 @@ public class TestCustomIntent extends AbstractDosgiTest {
basicTestOptions(), //
greeterInterface(), //
streamBundle(getCustomIntentBundle()).noStart(), //
- provision(getServiceBundle())
+ provision(getServiceBundle()),
+ //debug()
};
}
@Test
public void testCustomIntent() throws Exception {
// There should be warnings of unsatisfied intent myIntent in the log at debug level
- Thread.sleep(2000);
+ //Thread.sleep(2000);
getBundleByName(bundleContext, "CustomIntent").start();
waitPort(9090);
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
index 7ce7d43..0ed885a 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportRestService.java
@@ -46,7 +46,8 @@ public class TestExportRestService extends AbstractDosgiTest {
{//
basicTestOptions(), //
systemProperty("org.osgi.service.http.port").value(webPort), //
- provision(getServiceBundle())
+ provision(getServiceBundle()),
+ //debug()
};
}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
index 1516499..e79f76a 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/TestExportService.java
@@ -48,6 +48,7 @@ public class TestExportService extends AbstractDosgiTest {
return new Option[] //
{//
basicTestOptions(), //
+ //debug(),
greeterInterface(), //
greeterImpl(),
};
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/rest/TranslateActivator.java
----------------------------------------------------------------------
diff --git a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/rest/TranslateActivator.java b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/rest/TranslateActivator.java
index 1c48fb5..36fe7d2 100644
--- a/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/rest/TranslateActivator.java
+++ b/systests2/multi-bundle/src/test/java/org/apache/cxf/dosgi/systests2/multi/rest/TranslateActivator.java
@@ -30,7 +30,6 @@ public class TranslateActivator implements BundleActivator {
Dictionary<String, String> props = new Hashtable<String, String>();
props.put("service.exported.interfaces", "*");
props.put("service.exported.configs", "org.apache.cxf.rs");
- props.put("service.exported.intents", "HTTP");
props.put("org.apache.cxf.rs.address", "/translate");
context.registerService(RestTranslate.class.getName(), new RestTranslateImpl(), props);
}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/systests2/pom.xml
----------------------------------------------------------------------
diff --git a/systests2/pom.xml b/systests2/pom.xml
index 15b871c..423b338 100644
--- a/systests2/pom.xml
+++ b/systests2/pom.xml
@@ -24,13 +24,13 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
<groupId>org.apache.cxf.dosgi.systests</groupId>
<artifactId>cxf-dosgi-ri-systests2</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Distributed OSGi System Tests</name>
[2/3] cxf-dosgi git commit: [DOSGI-245] Split cxf provider into rs
and ws provider
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSPojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSPojoConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSPojoConfigurationTypeHandler.java
deleted file mode 100644
index 9befacf..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSPojoConfigurationTypeHandler.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.rest;
-
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.aries.rsa.spi.DistributionProvider;
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.common.util.ProxyClassLoader;
-import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
-import org.apache.cxf.dosgi.common.intent.IntentManager;
-import org.apache.cxf.dosgi.common.proxy.ProxyFactory;
-import org.apache.cxf.dosgi.common.util.OsgiUtils;
-import org.apache.cxf.dosgi.common.util.ServerWrapper;
-import org.apache.cxf.dosgi.dsw.handlers.pojo.InterceptorSupport;
-import org.apache.cxf.dosgi.dsw.osgi.Constants;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.client.Client;
-import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.apache.cxf.jaxrs.model.UserResource;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class JaxRSPojoConfigurationTypeHandler implements DistributionProvider {
- private static final Logger LOG = LoggerFactory.getLogger(JaxRSPojoConfigurationTypeHandler.class);
- protected BundleContext bundleContext;
- protected IntentManager intentManager;
- protected HttpServiceManager httpServiceManager;
-
- public JaxRSPojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager,
- HttpServiceManager httpServiceManager) {
- this.bundleContext = dswBC;
- this.intentManager = intentManager;
- this.httpServiceManager = httpServiceManager;
- }
-
- public String[] getSupportedTypes() {
- return new String[] {Constants.RS_CONFIG_TYPE};
- }
-
- protected EndpointDescription createEndpointDesc(Map<String, Object> props,
- String[] importedConfigs,
- String address,
- String[] intents) {
- props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
- for (String configurationType : importedConfigs) {
- if (Constants.RS_CONFIG_TYPE.equals(configurationType)) {
- props.put(Constants.RS_ADDRESS_PROPERTY, address);
- }
- }
- props.put(RemoteConstants.SERVICE_INTENTS, intents);
- props.put(RemoteConstants.ENDPOINT_ID, address);
- return new EndpointDescription(props);
- }
-
- @SuppressWarnings("rawtypes")
- public Object importEndpoint(ClassLoader consumerLoader,
- BundleContext consumerContext,
- Class[] interfaces,
- EndpointDescription endpoint) {
- Class<?> iClass = interfaces[0];
- String address = getPojoAddress(endpoint, iClass);
- if (address == null) {
- LOG.warn("Remote address is unavailable");
- return null;
- }
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- return createJaxrsProxy(address, consumerContext, iClass, null, endpoint);
- } catch (Throwable e) {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
-
- try {
- ProxyClassLoader cl = new ProxyClassLoader(iClass.getClassLoader());
- cl.addLoader(Client.class.getClassLoader());
- return createJaxrsProxy(address, consumerContext, iClass, cl, endpoint);
- } catch (Throwable e) {
- LOG.warn("proxy creation failed", e);
- }
-
- return null;
- }
-
- protected Object createJaxrsProxy(String address,
- BundleContext callingContext,
- Class<?> iClass,
- ClassLoader loader,
- EndpointDescription endpoint) {
- JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
- bean.setAddress(address);
- if (loader != null) {
- bean.setClassLoader(loader);
- }
-
- addRsInterceptorsFeaturesProps(bean, callingContext, endpoint.getProperties());
-
- List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
- if (resources != null) {
- bean.setModelBeansWithServiceClass(resources, iClass);
- } else {
- bean.setServiceClass(iClass);
- }
- List<Object> providers = JaxRSUtils.getProviders(callingContext, endpoint.getProperties());
- if (providers != null && !providers.isEmpty()) {
- bean.setProviders(providers);
- }
- Thread.currentThread().setContextClassLoader(JAXRSClientFactoryBean.class.getClassLoader());
- return ProxyFactory.create(bean.create(), iClass);
- }
-
- @SuppressWarnings("rawtypes")
- public Endpoint exportService(Object serviceBean,
- BundleContext callingContext,
- Map<String, Object> endpointProps,
- Class[] exportedInterfaces) throws IntentUnsatisfiedException {
- String contextRoot = OsgiUtils.getProperty(endpointProps, Constants.RS_HTTP_SERVICE_CONTEXT);
- String address;
- Class<?> iClass = exportedInterfaces[0];
- if (contextRoot == null) {
- address = getServerAddress(endpointProps, iClass);
- } else {
- address = getClientAddress(endpointProps);
- if (address == null) {
- address = "/";
- }
- }
- final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
- Bus bus = createBus(sid, callingContext, contextRoot);
-
- LOG.info("Creating a " + iClass.getName()
- + " endpoint via JaxRSPojoConfigurationTypeHandler, address is " + address);
-
- JAXRSServerFactoryBean factory = createServerFactory(callingContext, endpointProps,
- iClass, serviceBean, address, bus);
- String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
-
- EndpointDescription epd = createEndpointDesc(endpointProps, new String[] {Constants.RS_CONFIG_TYPE},
- completeEndpointAddress, new String[] {"HTTP"});
-
- return createServerFromFactory(factory, epd);
- }
-
- protected String getClientAddress(Map<String, Object> sd) {
- return OsgiUtils.getFirstNonEmptyStringProperty(sd, RemoteConstants.ENDPOINT_ID,
- Constants.RS_ADDRESS_PROPERTY);
- }
-
- protected String getServerAddress(Map<String, Object> sd, Class<?> iClass) {
- String address = OsgiUtils.getProperty(sd, Constants.RS_ADDRESS_PROPERTY);
- return address == null ? httpServiceManager.getDefaultAddress(iClass) : address;
- }
-
- protected Bus createBus(Long sid, BundleContext callingContext, String contextRoot) {
- Bus bus = BusFactory.newInstance().createBus();
- if (contextRoot != null) {
- httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid);
- }
- return bus;
- }
-
- private Endpoint createServerFromFactory(JAXRSServerFactoryBean factory,
- EndpointDescription epd) {
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(JAXRSServerFactoryBean.class.getClassLoader());
- Server server = factory.create();
- return new ServerWrapper(epd, server);
- } finally {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
- }
-
- private JAXRSServerFactoryBean createServerFactory(BundleContext callingContext,
- Map<String, Object> sd,
- Class<?> iClass,
- Object serviceBean,
- String address,
- Bus bus) {
- JAXRSServerFactoryBean factory = new JAXRSServerFactoryBean();
- factory.setBus(bus);
- List<UserResource> resources = JaxRSUtils.getModel(callingContext, iClass);
- if (resources != null) {
- factory.setModelBeansWithServiceClass(resources, iClass);
- factory.setServiceBeanObjects(serviceBean);
- } else {
- factory.setServiceClass(iClass);
- factory.setResourceProvider(iClass, new SingletonResourceProvider(serviceBean));
- }
- factory.setAddress(address);
- List<Object> providers = JaxRSUtils.getProviders(callingContext, sd);
- if (providers != null && !providers.isEmpty()) {
- factory.setProviders(providers);
- }
- addRsInterceptorsFeaturesProps(factory, callingContext, sd);
- String location = OsgiUtils.getProperty(sd, Constants.RS_WADL_LOCATION);
- if (location != null) {
- URL wadlURL = callingContext.getBundle().getResource(location);
- if (wadlURL != null) {
- factory.setDocLocation(wadlURL.toString());
- }
- }
- return factory;
- }
-
- protected String getPojoAddress(EndpointDescription endpoint, Class<?> iClass) {
- String address = OsgiUtils.getProperty(endpoint, Constants.RS_ADDRESS_PROPERTY);
-
- if (address == null) {
- address = httpServiceManager.getDefaultAddress(iClass);
- if (address != null) {
- LOG.info("Using a default address: " + address);
- }
- }
- return address;
- }
-
- protected void addRsInterceptorsFeaturesProps(AbstractEndpointFactory factory,
- BundleContext callingContext,
- Map<String, Object> sd) {
- InterceptorSupport.addInterceptors(factory, callingContext, sd, Constants.RS_IN_INTERCEPTORS_PROP_KEY);
- InterceptorSupport.addInterceptors(factory, callingContext, sd, Constants.RS_OUT_INTERCEPTORS_PROP_KEY);
- InterceptorSupport.addInterceptors(factory, callingContext, sd, Constants.RS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
- InterceptorSupport.addInterceptors(factory, callingContext, sd, Constants.RS_IN_FAULT_INTERCEPTORS_PROP_KEY);
- InterceptorSupport.addFeatures(factory, callingContext, sd, Constants.RS_FEATURES_PROP_KEY);
- addContextProperties(factory, sd, Constants.RS_CONTEXT_PROPS_PROP_KEY);
- }
-
- private void addContextProperties(AbstractEndpointFactory factory, Map<String, Object> sd, String propName) {
- @SuppressWarnings("unchecked")
- Map<String, Object> props = (Map<String, Object>)sd.get(propName);
- if (props != null) {
- factory.getProperties(true).putAll(props);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java
deleted file mode 100644
index e8f0a75..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.rest;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.dosgi.common.util.ClassUtils;
-import org.apache.cxf.dosgi.common.util.OsgiUtils;
-import org.apache.cxf.jaxrs.model.UserResource;
-import org.apache.cxf.jaxrs.provider.aegis.AegisElementProvider;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public final class JaxRSUtils {
-
- public static final String MODEL_FOLDER = "/OSGI-INF/cxf/jaxrs/";
- public static final String DEFAULT_MODEL = "/OSGI-INF/cxf/jaxrs/model.xml";
- public static final String PROVIDERS_FILTER = "(|"
- + "(objectClass=javax.ws.rs.ext.MessageBodyReader)"
- + "(objectClass=javax.ws.rs.ext.MessageBodyWriter)"
- + "(objectClass=javax.ws.rs.ext.ExceptionMapper)"
- + "(objectClass=org.apache.cxf.jaxrs.ext.RequestHandler)"
- + "(objectClass=org.apache.cxf.jaxrs.ext.ResponseHandler)"
- + "(objectClass=org.apache.cxf.jaxrs.ext.ParameterHandler)"
- + "(objectClass=org.apache.cxf.jaxrs.ext.ResponseExceptionMapper)"
- + ")";
- private static final Logger LOG = LoggerFactory.getLogger(JaxRSUtils.class);
-
- private JaxRSUtils() {
- // never constructed
- }
-
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- static List<Object> getProviders(BundleContext callingContext, Map<String, Object> sd) {
- List<Object> providers = new ArrayList<Object>();
- if ("aegis".equals(sd.get(org.apache.cxf.dosgi.dsw.osgi.Constants.RS_DATABINDING_PROP_KEY))) {
- providers.add(new AegisElementProvider());
- }
-
- providers.addAll(ClassUtils.loadProviderClasses(callingContext,
- sd,
- org.apache.cxf.dosgi.dsw.osgi.Constants.RS_PROVIDER_PROP_KEY));
-
- Object globalQueryProp = sd.get(org.apache.cxf.dosgi.dsw.osgi.Constants.RS_PROVIDER_GLOBAL_PROP_KEY);
- boolean globalQueryRequired = globalQueryProp == null || OsgiUtils.toBoolean(globalQueryProp);
- if (!globalQueryRequired) {
- return providers;
- }
-
- boolean cxfProvidersOnly = OsgiUtils.getBooleanProperty(sd,
- org.apache.cxf.dosgi.dsw.osgi.Constants.RS_PROVIDER_EXPECTED_PROP_KEY);
-
- try {
- ServiceReference[] refs = callingContext.getServiceReferences((String)null, PROVIDERS_FILTER);
- if (refs != null) {
- for (ServiceReference ref : refs) {
- if (!cxfProvidersOnly
- || OsgiUtils.toBoolean(ref
- .getProperty(org.apache.cxf.dosgi.dsw.osgi.Constants.RS_PROVIDER_PROP_KEY))) {
- providers.add(callingContext.getService(ref));
- }
- }
- }
- } catch (Exception ex) {
- LOG.debug("Problems finding JAXRS providers " + ex.getMessage(), ex);
- }
- return providers;
- }
-
- static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass) {
- String classModel = MODEL_FOLDER + iClass.getSimpleName() + "-model.xml";
- List<UserResource> list = getModel(callingContext, iClass, classModel);
- return list != null ? list : getModel(callingContext, iClass, DEFAULT_MODEL);
- }
-
- private static List<UserResource> getModel(BundleContext callingContext, Class<?> iClass, String name) {
- InputStream r = iClass.getClassLoader().getResourceAsStream(name);
- if (r == null) {
- URL u = callingContext.getBundle().getResource(name);
- if (u != null) {
- try {
- r = u.openStream();
- } catch (Exception ex) {
- LOG.info("Problems opening a user model resource at " + u.toString());
- }
- }
- }
- if (r != null) {
- try {
- return ResourceUtils.getUserResources(r);
- } catch (Exception ex) {
- LOG.info("Problems reading a user model, it will be ignored");
- }
- }
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Constants.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Constants.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Constants.java
deleted file mode 100644
index 5619b5f..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/osgi/Constants.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.osgi;
-
-public final class Constants {
-
- // WSDL
- public static final String WSDL_CONFIG_TYPE = "wsdl";
- public static final String WSDL_CONFIG_PREFIX = "osgi.remote.configuration" + "." + WSDL_CONFIG_TYPE;
- public static final String WSDL_SERVICE_NAMESPACE = WSDL_CONFIG_PREFIX + ".service.ns";
- public static final String WSDL_SERVICE_NAME = WSDL_CONFIG_PREFIX + ".service.name";
- public static final String WSDL_PORT_NAME = WSDL_CONFIG_PREFIX + ".port.name";
- public static final String WSDL_LOCATION = WSDL_CONFIG_PREFIX + ".location";
- public static final String WSDL_HTTP_SERVICE_CONTEXT = WSDL_CONFIG_PREFIX + ".httpservice.context";
-
- // WS
- public static final String WS_CONFIG_TYPE = "org.apache.cxf" + ".ws";
- public static final String WS_ADDRESS_PROPERTY = WS_CONFIG_TYPE + ".address";
- public static final String WS_PORT_PROPERTY = WS_CONFIG_TYPE + ".port";
- public static final String WS_HTTP_SERVICE_CONTEXT = WS_CONFIG_TYPE + ".httpservice.context";
-
- public static final String WS_FRONTEND_PROP_KEY = WS_CONFIG_TYPE + ".frontend";
- public static final String WS_FRONTEND_JAXWS = "jaxws";
- public static final String WS_FRONTEND_SIMPLE = "simple";
-
- public static final String WS_IN_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".in.interceptors";
- public static final String WS_OUT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".out.interceptors";
- public static final String WS_OUT_FAULT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".out.fault.interceptors";
- public static final String WS_IN_FAULT_INTERCEPTORS_PROP_KEY = WS_CONFIG_TYPE + ".in.fault.interceptors";
- public static final String WS_CONTEXT_PROPS_PROP_KEY = WS_CONFIG_TYPE + ".context.properties";
- public static final String WS_FEATURES_PROP_KEY = WS_CONFIG_TYPE + ".features";
-
- public static final String WS_DATABINDING_PROP_KEY = WS_CONFIG_TYPE + ".databinding";
- public static final String WS_DATABINDING_BEAN_PROP_KEY = WS_DATABINDING_PROP_KEY + ".bean";
- public static final String WS_DATA_BINDING_JAXB = "jaxb";
- public static final String WS_DATA_BINDING_AEGIS = "aegis";
-
- public static final String WS_WSDL_SERVICE_NAMESPACE = WS_CONFIG_TYPE + ".service.ns";
- public static final String WS_WSDL_SERVICE_NAME = WS_CONFIG_TYPE + ".service.name";
- public static final String WS_WSDL_PORT_NAME = WS_CONFIG_TYPE + ".port.name";
- public static final String WS_WSDL_LOCATION = WS_CONFIG_TYPE + ".wsdl.location";
-
- // Rest
- public static final String RS_CONFIG_TYPE = "org.apache.cxf" + ".rs";
- public static final String RS_ADDRESS_PROPERTY = RS_CONFIG_TYPE + ".address";
- public static final String RS_HTTP_SERVICE_CONTEXT = RS_CONFIG_TYPE + ".httpservice.context";
- public static final String RS_DATABINDING_PROP_KEY = RS_CONFIG_TYPE + ".databinding";
- public static final String RS_IN_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".in.interceptors";
- public static final String RS_OUT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".out.interceptors";
- public static final String RS_IN_FAULT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".in.fault.interceptors";
- public static final String RS_OUT_FAULT_INTERCEPTORS_PROP_KEY = RS_CONFIG_TYPE + ".out.fault.interceptors";
- public static final String RS_CONTEXT_PROPS_PROP_KEY = RS_CONFIG_TYPE + ".context.properties";
- public static final String RS_FEATURES_PROP_KEY = RS_CONFIG_TYPE + ".features";
- public static final String RS_PROVIDER_PROP_KEY = RS_CONFIG_TYPE + ".provider";
- public static final String RS_PROVIDER_EXPECTED_PROP_KEY = RS_PROVIDER_PROP_KEY + ".expected";
- public static final String RS_PROVIDER_GLOBAL_PROP_KEY = RS_PROVIDER_PROP_KEY + ".globalquery";
- public static final String RS_WADL_LOCATION = RS_CONFIG_TYPE + ".wadl.location";
-
- // POJO (old value for WS)
- public static final String WS_CONFIG_TYPE_OLD = "pojo";
- public static final String WS_CONFIG_OLD_PREFIX = "osgi.remote.configuration." + WS_CONFIG_TYPE_OLD;
- public static final String WS_ADDRESS_PROPERTY_OLD = WS_CONFIG_OLD_PREFIX + ".address";
- public static final String WS_HTTP_SERVICE_CONTEXT_OLD = WS_CONFIG_OLD_PREFIX + ".httpservice.context";
-
- private Constants() {
- // never constructed
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
deleted file mode 100644
index d161b2d..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProviderTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.aries.rsa.spi.DistributionProvider;
-import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
-import org.apache.cxf.dosgi.common.intent.IntentManager;
-import org.apache.cxf.dosgi.common.intent.IntentManagerImpl;
-import org.apache.cxf.dosgi.dsw.handlers.pojo.PojoConfigurationTypeHandler;
-import org.apache.cxf.dosgi.dsw.handlers.pojo.WsdlConfigurationTypeHandler;
-import org.apache.cxf.dosgi.dsw.handlers.rest.JaxRSPojoConfigurationTypeHandler;
-import org.apache.cxf.dosgi.dsw.osgi.Constants;
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import org.junit.Test;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public class CXFDistributionProviderTest {
-
- @Test
- public void testGetDefaultHandlerNoIntents() {
- DistributionProvider handler = getHandlerWith(null, null);
- assertTrue(handler instanceof PojoConfigurationTypeHandler);
- }
-
- @Test
- public void testGetJaxrsHandlerNoIntents() {
- DistributionProvider handler = getHandlerWith(Constants.RS_CONFIG_TYPE, null);
- assertTrue(handler instanceof JaxRSPojoConfigurationTypeHandler);
- }
-
- @Test
- public void testGetJaxrsHandlerHttpIntents() {
- DistributionProvider handler = getHandlerWith(Constants.RS_CONFIG_TYPE, "HTTP");
- assertTrue(handler instanceof JaxRSPojoConfigurationTypeHandler);
- }
-
- @Test
- public void testJaxrsPropertyIgnored() {
- DistributionProvider handler = getHandlerWith(Constants.RS_CONFIG_TYPE, "SOAP HTTP");
- assertTrue(handler instanceof PojoConfigurationTypeHandler);
- assertTrue(!(handler instanceof JaxRSPojoConfigurationTypeHandler));
- }
-
- @Test
- public void testJaxrsPropertyIgnored2() {
- DistributionProvider handler = getHandlerWith(Constants.RS_CONFIG_TYPE, new String[] {"HTTP", "SOAP"});
- assertTrue(handler instanceof PojoConfigurationTypeHandler);
- assertTrue(!(handler instanceof JaxRSPojoConfigurationTypeHandler));
- }
-
- @Test
- public void testGetPojoHandler() {
- DistributionProvider handler = getHandlerWith(Constants.WS_CONFIG_TYPE, null);
- assertTrue(handler instanceof PojoConfigurationTypeHandler);
- }
-
- @Test
- public void testGetWSDLHandler() {
- DistributionProvider handler = getHandlerWith(Constants.WSDL_CONFIG_TYPE, null);
- assertTrue(handler instanceof WsdlConfigurationTypeHandler);
- }
-
- @Test
- public void testUnsupportedConfiguration() {
- DistributionProvider handler = getHandlerWith("notSupportedConfig", null);
- Assert.assertNull(handler);
- }
-
- private DistributionProvider getHandlerWith(String configType, Object intents) {
- BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(bc);
- Map<String, Object> serviceProps = new HashMap<String, Object>();
- serviceProps.put(RemoteConstants.SERVICE_EXPORTED_CONFIGS, configType);
- serviceProps.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, intents);
- IntentManager intentManager = new IntentManagerImpl();
- HttpServiceManager httpServiceManager = new HttpServiceManager();
- httpServiceManager.setContext(bc);
- CXFDistributionProvider provider = new CXFDistributionProvider();
- provider.setHttpServiceManager(httpServiceManager);
- provider.setIntentManager(intentManager);
- provider.init(bc, null);
- List<String> configurationTypes = provider.determineConfigurationTypes(serviceProps);
- return provider.getHandler(configurationTypes, serviceProps);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
deleted file mode 100644
index df90758..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/WsdlConfigurationTypeHandlerTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import junit.framework.TestCase;
-
-public class WsdlConfigurationTypeHandlerTest extends TestCase {
-
- public void testDUMMY() {
- assertTrue(true);
- }
-
-// 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");
-// }
-//
-// public void testCreateProxyPopulatesDistributionProvider() {
-// ServiceReference sr = EasyMock.createNiceMock(ServiceReference.class);
-// BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
-// BundleContext callingContext = EasyMock.createNiceMock(BundleContext.class);
-// ServiceEndpointDescription sd = TestUtils.mockServiceDescription("Foo");
-// EasyMock.replay(sr);
-// EasyMock.replay(dswContext);
-// EasyMock.replay(callingContext);
-// EasyMock.replay(sd);
-//
-// RemoteServiceAdminCore dp = new RemoteServiceAdminCore(dswContext);
-// WsdlConfigurationTypeHandler w = new WsdlConfigurationTypeHandler(dswContext, dp, handlerProps) {
-// @Override
-// Service createWebService(URL wsdlAddress, QName serviceQname) {
-// Service svc = EasyMock.createMock(Service.class);
-// EasyMock.expect(svc.getPort(CharSequence.class)).andReturn("Hi").anyTimes();
-// EasyMock.replay(svc);
-// return svc;
-// }
-// };
-//
-// assertEquals("Precondition failed", 0, dp.getRemoteServices().size());
-// w.createProxy(sr, dswContext, callingContext, CharSequence.class, sd);
-// assertEquals(1, dp.getRemoteServices().size());
-// assertSame(sr, dp.getRemoteServices().iterator().next());
-//
-// }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java
deleted file mode 100644
index 7814267..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.jaxws;
-
-import javax.jws.WebService;
-
-@WebService
-public interface MyJaxWsEchoService {
- String echo(String message);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java
deleted file mode 100644
index 699c9ae..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/jaxws/MyJaxWsEchoServiceImpl.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.jaxws;
-
-public class MyJaxWsEchoServiceImpl implements MyJaxWsEchoService {
-
- @Override
- public String echo(String message) {
- return message;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandlerTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandlerTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandlerTest.java
deleted file mode 100644
index d02008c..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandlerTest.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.pojo;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.xml.namespace.QName;
-
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.aries.rsa.util.EndpointHelper;
-import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
-import org.apache.cxf.dosgi.common.intent.IntentManager;
-import org.apache.cxf.dosgi.common.intent.IntentManagerImpl;
-import org.apache.cxf.dosgi.common.intent.IntentMap;
-import org.apache.cxf.dosgi.common.util.ServerWrapper;
-import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoService;
-import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoService;
-import org.apache.cxf.dosgi.dsw.osgi.Constants;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.endpoint.EndpointImpl;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.feature.Feature;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
-import org.apache.cxf.transport.Destination;
-import org.apache.cxf.ws.addressing.AttributedURIType;
-import org.apache.cxf.ws.addressing.EndpointReferenceType;
-import org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.easymock.IMocksControl;
-import org.junit.Assert;
-import org.junit.Test;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Version;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-import junit.framework.TestCase;
-
-public class PojoConfigurationTypeHandlerTest extends TestCase {
- @Test
- public void testMergeArrays() {
- Assert.assertNull(AbstractPojoConfigurationTypeHandler.mergeArrays(null, null));
-
- String[] sa1 = {};
- Assert.assertEquals(0, AbstractPojoConfigurationTypeHandler.mergeArrays(sa1, null).length);
-
- String[] sa2 = {"X"};
- Assert.assertEquals(1, AbstractPojoConfigurationTypeHandler.mergeArrays(null, sa2).length);
- Assert.assertEquals("X", AbstractPojoConfigurationTypeHandler.mergeArrays(null, sa2)[0]);
-
- String[] sa3 = {"Y", "Z"};
- String[] sa4 = {"A", "Z"};
- Assert.assertEquals(3, AbstractPojoConfigurationTypeHandler.mergeArrays(sa3, sa4).length);
- Assert.assertEquals(new HashSet<String>(Arrays.asList("A", "Y", "Z")),
- new HashSet<String>(Arrays.asList(AbstractPojoConfigurationTypeHandler.mergeArrays(sa3, sa4))));
- }
-
- public void testGetPojoAddressEndpointURI() {
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
- intentManager,
- dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- String url = "http://somewhere:1234/blah";
- sd.put(RemoteConstants.ENDPOINT_ID, url);
- assertEquals(url, handler.getServerAddress(sd, String.class));
- }
-
- private HttpServiceManager dummyHttpServiceManager() {
- return new HttpServiceManager();
- }
-
- public void testGetPojoAddressEndpointCxf() {
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
- intentManager,
- dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- String url = "http://somewhere:29/boo";
- sd.put("org.apache.cxf.ws.address", url);
- assertEquals(url, handler.getServerAddress(sd, String.class));
- }
-
- public void testGetPojoAddressEndpointPojo() {
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
- intentManager,
- dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- String url = "http://somewhere:32768/foo";
- sd.put("osgi.remote.configuration.pojo.address", url);
- assertEquals(url, handler.getServerAddress(sd, String.class));
- }
-
- public void testGetDefaultPojoAddress() {
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(null,
- intentManager,
- dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- assertEquals("/java/lang/String", handler.getServerAddress(sd, String.class));
- }
-
- // todo: add test for data bindings
- public void testCreateProxy() {
- IMocksControl c = EasyMock.createNiceControl();
- BundleContext bc1 = c.createMock(BundleContext.class);
-
- BundleContext requestingContext = c.createMock(BundleContext.class);
-
- final ClientProxyFactoryBean cpfb = c.createMock(ClientProxyFactoryBean.class);
- ReflectionServiceFactoryBean sf = c.createMock(ReflectionServiceFactoryBean.class);
- EasyMock.expect(cpfb.getServiceFactory()).andReturn(sf).anyTimes();
- IntentManager intentManager = new IntentManagerImpl(new IntentMap()) {
- @Override
- public String[] applyIntents(List<Feature> features,
- AbstractEndpointFactory factory,
- Map<String, Object> sd) {
- return new String[0];
- }
- };
- PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(bc1,
- intentManager,
- dummyHttpServiceManager()) {
- @Override
- protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
- return cpfb;
- }
- };
-
- Class<?>[] exportedInterfaces = new Class[]{Runnable.class};
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(RemoteConstants.ENDPOINT_ID, "http://google.de/");
- EndpointHelper.addObjectClass(props, exportedInterfaces);
- props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, new String[]{"my.config"});
- EndpointDescription endpoint = new EndpointDescription(props);
-
- cpfb.setAddress((String)EasyMock.eq(props.get(RemoteConstants.ENDPOINT_ID)));
- EasyMock.expectLastCall().atLeastOnce();
-
- cpfb.setServiceClass(EasyMock.eq(Runnable.class));
- EasyMock.expectLastCall().atLeastOnce();
-
- c.replay();
- ClassLoader cl = null;
- Object proxy = p.importEndpoint(cl, requestingContext, exportedInterfaces, endpoint);
- assertNotNull(proxy);
- assertTrue("Proxy is not of the requested type! ", proxy instanceof Runnable);
- c.verify();
- }
-
- public void testCreateServerWithAddressProperty() throws Exception {
- BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(dswContext);
-
- String myService = "Hi";
- final ServerFactoryBean sfb = createMockServerFactoryBean();
-
- IntentMap intentMap = new IntentMap();
- IntentManager intentManager = new IntentManagerImpl(intentMap) {
- @Override
- public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory,
- Map<String, Object> sd) {
- return new String[]{};
- }
- };
- PojoConfigurationTypeHandler p = new PojoConfigurationTypeHandler(dswContext, intentManager,
- dummyHttpServiceManager()) {
- @Override
- protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
- return sfb;
- }
- };
- BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(bundleContext);
-
- Class<?>[] exportedInterface = new Class[]{String.class};
- Map<String, Object> props = new HashMap<String, Object>();
- EndpointHelper.addObjectClass(props, exportedInterface);
- props.put(Constants.WS_ADDRESS_PROPERTY, "http://alternate_host:80/myString");
-
- Endpoint exportResult = p.exportService(myService, bundleContext, props, exportedInterface);
- Map<String, Object> edProps = exportResult.description().getProperties();
-
- assertNotNull(edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
- assertEquals(1, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS)).length);
- assertEquals(Constants.WS_CONFIG_TYPE, ((String[])edProps.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS))[0]);
- assertEquals("http://alternate_host:80/myString", edProps.get(RemoteConstants.ENDPOINT_ID));
- }
-
- public void testAddressing() throws Exception {
- runAddressingTest(new HashMap<String, Object>(), "http://localhost:9000/java/lang/Runnable");
-
- Map<String, Object> p1 = new HashMap<String, Object>();
- p1.put("org.apache.cxf.ws.address", "http://somewhere");
- runAddressingTest(p1, "http://somewhere");
-
- Map<String, Object> p2 = new HashMap<String, Object>();
- p2.put("org.apache.cxf.rs.address", "https://somewhereelse");
- runAddressingTest(p2, "https://somewhereelse");
-
- Map<String, Object> p3 = new HashMap<String, Object>();
- p3.put("org.apache.cxf.ws.port", 65535);
- runAddressingTest(p3, "http://localhost:65535/java/lang/Runnable");
-
- Map<String, Object> p4 = new HashMap<String, Object>();
- p4.put("org.apache.cxf.ws.port", "8181");
- runAddressingTest(p4, "http://localhost:8181/java/lang/Runnable");
- }
-
- private void runAddressingTest(Map<String, Object> properties, String expectedAddress) throws Exception {
- Class<?>[] exportedInterface = new Class[]{Runnable.class};
- EndpointHelper.addObjectClass(properties, exportedInterface);
- BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
- String expectedUUID = UUID.randomUUID().toString();
- EasyMock.expect(dswContext.getProperty(org.osgi.framework.Constants.FRAMEWORK_UUID)).andReturn(expectedUUID);
- EasyMock.replay(dswContext);
-
- IntentManager intentManager = EasyMock.createNiceMock(IntentManager.class);
- EasyMock.replay(intentManager);
-
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswContext,
- intentManager,
- dummyHttpServiceManager()) {
- @Override
- protected Endpoint createServerFromFactory(ServerFactoryBean factory,
- EndpointDescription epd) {
- return new ServerWrapper(epd, null);
- }
- };
- Runnable myService = EasyMock.createMock(Runnable.class);
- EasyMock.replay(myService);
-
- BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(bundleContext);
-
- Endpoint result = handler.exportService(myService, bundleContext, properties, exportedInterface);
- Map<String, Object> props = result.description().getProperties();
- assertEquals(expectedAddress, props.get("org.apache.cxf.ws.address"));
- Assert.assertArrayEquals(new String[] {"org.apache.cxf.ws"},
- (String[]) props.get(RemoteConstants.SERVICE_IMPORTED_CONFIGS));
- Assert.assertArrayEquals(new String[] {"java.lang.Runnable"},
- (String[]) props.get(org.osgi.framework.Constants.OBJECTCLASS));
- }
-
- public void t2estCreateServerException() {
- BundleContext dswContext = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.replay(dswContext);
-
- IntentManager intentManager = EasyMock.createNiceMock(IntentManager.class);
- EasyMock.replay(intentManager);
-
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswContext,
- intentManager,
- dummyHttpServiceManager()) {
- @Override
- protected Endpoint createServerFromFactory(ServerFactoryBean factory,
- EndpointDescription epd) {
- throw new TestException();
- }
- };
-
- Map<String, Object> props = new HashMap<String, Object>();
-
- Runnable myService = EasyMock.createMock(Runnable.class);
- EasyMock.replay(myService);
- try {
- handler.exportService(myService, null, props, new Class[]{Runnable.class});
- fail("Expected TestException");
- } catch (TestException e) {
- // Expected
- }
- }
-
- private ServerFactoryBean createMockServerFactoryBean() {
- ReflectionServiceFactoryBean sf = EasyMock.createNiceMock(ReflectionServiceFactoryBean.class);
- EasyMock.replay(sf);
-
- final StringBuilder serverURI = new StringBuilder();
-
- ServerFactoryBean sfb = EasyMock.createNiceMock(ServerFactoryBean.class);
- Server server = createMockServer(sfb);
-
- EasyMock.expect(sfb.getServiceFactory()).andReturn(sf).anyTimes();
- EasyMock.expect(sfb.create()).andReturn(server);
- sfb.setAddress((String) EasyMock.anyObject());
- EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
- public Object answer() throws Throwable {
- serverURI.setLength(0);
- serverURI.append(EasyMock.getCurrentArguments()[0]);
- return null;
- }
- });
- EasyMock.expect(sfb.getAddress()).andAnswer(new IAnswer<String>() {
- public String answer() throws Throwable {
- return serverURI.toString();
- }
- });
- EasyMock.replay(sfb);
- return sfb;
- }
-
- private Server createMockServer(final ServerFactoryBean sfb) {
- AttributedURIType addr = EasyMock.createMock(AttributedURIType.class);
- EasyMock.expect(addr.getValue()).andAnswer(new IAnswer<String>() {
- public String answer() throws Throwable {
- return sfb.getAddress();
- }
- });
- EasyMock.replay(addr);
-
- EndpointReferenceType er = EasyMock.createMock(EndpointReferenceType.class);
- EasyMock.expect(er.getAddress()).andReturn(addr);
- EasyMock.replay(er);
-
- Destination destination = EasyMock.createMock(Destination.class);
- EasyMock.expect(destination.getAddress()).andReturn(er);
- EasyMock.replay(destination);
-
- Server server = EasyMock.createNiceMock(Server.class);
- EasyMock.expect(server.getDestination()).andReturn(destination);
- EasyMock.replay(server);
- return server;
- }
-
- public void testCreateEndpointProps() {
- BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
- EasyMock.expect(bc.getProperty("org.osgi.framework.uuid")).andReturn("some_uuid1");
- EasyMock.replay(bc);
-
- IntentManager intentManager = new IntentManagerImpl(new IntentMap());
- PojoConfigurationTypeHandler pch = new PojoConfigurationTypeHandler(bc,
- intentManager,
- dummyHttpServiceManager());
- Class<?>[] exportedInterfaces = new Class[] {String.class};
- Map<String, Object> sd = new HashMap<String, Object>();
- sd.put(org.osgi.framework.Constants.SERVICE_ID, 42);
- EndpointHelper.addObjectClass(sd, exportedInterfaces);
- EndpointDescription epd = pch.createEndpointDesc(sd, new String[] {"org.apache.cxf.ws"},
- "http://localhost:12345", new String[] {"my_intent", "your_intent"});
-
- assertEquals("http://localhost:12345", epd.getId());
- assertEquals(Arrays.asList("java.lang.String"), epd.getInterfaces());
- assertEquals(Arrays.asList("org.apache.cxf.ws"), epd.getConfigurationTypes());
- assertEquals(Arrays.asList("my_intent", "your_intent"), epd.getIntents());
- assertEquals(new Version("0.0.0"), epd.getPackageVersion("java.lang"));
- }
-
- public void t2estCreateJaxWsEndpointWithoutIntents() {
- IMocksControl c = EasyMock.createNiceControl();
- BundleContext dswBC = c.createMock(BundleContext.class);
-
- IntentManager intentManager = new DummyIntentManager();
- PojoConfigurationTypeHandler handler = new PojoConfigurationTypeHandler(dswBC,
- intentManager,
- dummyHttpServiceManager());
-
- Map<String, Object> sd = new HashMap<String, Object>();
- sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere");
- BundleContext serviceBC = c.createMock(BundleContext.class);
- Object myService = null;
- c.replay();
-
- ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(myService,
- serviceBC,
- sd,
- new Class[]{MyJaxWsEchoService.class});
- c.verify();
-
- org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
- QName bindingName = ep.getEndpointInfo().getBinding().getName();
- Assert.assertEquals(JaxWsEndpointImpl.class, ep.getClass());
- Assert.assertEquals(new QName("http://jaxws.handlers.dsw.dosgi.cxf.apache.org/",
- "MyJaxWsEchoServiceServiceSoapBinding"),
- bindingName);
- }
-
- public void t2estCreateSimpleEndpointWithoutIntents() {
- IMocksControl c = EasyMock.createNiceControl();
- BundleContext dswBC = c.createMock(BundleContext.class);
-
- IntentManager intentManager = new DummyIntentManager();
- PojoConfigurationTypeHandler handler
- = new PojoConfigurationTypeHandler(dswBC, intentManager, dummyHttpServiceManager());
- Map<String, Object> sd = new HashMap<String, Object>();
- sd.put(Constants.WS_ADDRESS_PROPERTY, "/somewhere_else");
- BundleContext serviceBC = c.createMock(BundleContext.class);
- c.replay();
- ServerWrapper serverWrapper = (ServerWrapper)handler.exportService(null, serviceBC, sd,
- new Class[]{MySimpleEchoService.class});
- c.verify();
-
- org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();
- QName bindingName = ep.getEndpointInfo().getBinding().getName();
- Assert.assertEquals(EndpointImpl.class, ep.getClass());
- Assert.assertEquals(new QName("http://simple.handlers.dsw.dosgi.cxf.apache.org/",
- "MySimpleEchoServiceSoapBinding"),
- bindingName);
- }
-
- public static class DummyIntentManager implements IntentManager {
-
- @Override
- public String[] applyIntents(List<Feature> features,
- AbstractEndpointFactory factory,
- Map<String, Object> props) {
- return new String[]{};
- }
-
- @Override
- public void assertAllIntentsSupported(Map<String, Object> serviceProperties) {
- }
- }
-
- @SuppressWarnings("serial")
- public static class TestException extends RuntimeException {
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtilsTest.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtilsTest.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtilsTest.java
deleted file mode 100644
index 72e578b..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/rest/JaxRSUtilsTest.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.rest;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.cxf.dosgi.dsw.osgi.Constants;
-import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
-import org.apache.cxf.jaxrs.provider.aegis.AegisElementProvider;
-import org.easymock.EasyMock;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public class JaxRSUtilsTest extends TestCase {
-
- private void addRequiredProps(Map<String, Object> props) {
- props.put(RemoteConstants.ENDPOINT_ID, "http://google.de");
- props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myGreatConfiguration");
- props.put(org.osgi.framework.Constants.OBJECTCLASS, new String[] {"my.class"});
- }
-
- public void testNoGlobalProviders() {
- Map<String, Object> props = new HashMap<String, Object>();
- addRequiredProps(props);
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
-
- assertEquals(0, JaxRSUtils.getProviders(null, props).size());
- }
-
- public void testAegisProvider() {
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_DATABINDING_PROP_KEY, "aegis");
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
-
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(null, props);
- assertEquals(1, providers.size());
- assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
- }
-
- @SuppressWarnings("rawtypes")
- public void testServiceProviders() {
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_PROP_KEY, new Object[] {
- new AegisElementProvider()
- });
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(null, props);
- assertEquals(1, providers.size());
- assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
- }
-
- public void testServiceProviderProperty() throws Exception {
- BundleContext bc = EasyMock.createMock(BundleContext.class);
- Bundle bundle = EasyMock.createMock(Bundle.class);
- bc.getBundle();
- EasyMock.expectLastCall().andReturn(bundle).times(2);
- bundle.loadClass(AegisElementProvider.class.getName());
- EasyMock.expectLastCall().andReturn(AegisElementProvider.class);
- bundle.loadClass(JAXBElementProvider.class.getName());
- EasyMock.expectLastCall().andReturn(JAXBElementProvider.class);
- EasyMock.replay(bc, bundle);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_PROP_KEY,
- "\r\n " + AegisElementProvider.class.getName() + " , \r\n"
- + JAXBElementProvider.class.getName() + "\r\n");
-
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(2, providers.size());
- assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
- assertEquals(JAXBElementProvider.class.getName(), providers.get(1).getClass().getName());
- }
-
- public void testServiceProviderStrings() throws Exception {
- BundleContext bc = EasyMock.createMock(BundleContext.class);
- Bundle bundle = EasyMock.createMock(Bundle.class);
- bc.getBundle();
- EasyMock.expectLastCall().andReturn(bundle).times(2);
- bundle.loadClass(AegisElementProvider.class.getName());
- EasyMock.expectLastCall().andReturn(AegisElementProvider.class);
- bundle.loadClass(JAXBElementProvider.class.getName());
- EasyMock.expectLastCall().andReturn(JAXBElementProvider.class);
- EasyMock.replay(bc, bundle);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_PROP_KEY, new String[] {
- "\r\n " + AegisElementProvider.class.getName(),
- JAXBElementProvider.class.getName() + "\r\n"
- });
-
- props.put(Constants.RS_PROVIDER_GLOBAL_PROP_KEY, "false");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(2, providers.size());
- assertEquals(AegisElementProvider.class.getName(), providers.get(0).getClass().getName());
- assertEquals(JAXBElementProvider.class.getName(), providers.get(1).getClass().getName());
- }
-
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- public void testCustomGlobalProvider() throws Exception {
- ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
- BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
- bc.getServiceReferences((String)null, JaxRSUtils.PROVIDERS_FILTER);
- EasyMock.expectLastCall().andReturn(new ServiceReference[] {sref});
- sref.getProperty(Constants.RS_PROVIDER_EXPECTED_PROP_KEY);
- EasyMock.expectLastCall().andReturn(false);
- bc.getService(sref);
- AegisElementProvider<?> p = new AegisElementProvider();
- EasyMock.expectLastCall().andReturn(p);
- EasyMock.replay(bc, sref);
- Map<String, Object> props = new HashMap<String, Object>();
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(1, providers.size());
- assertSame(p, providers.get(0));
- }
-
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- public void testNoCustomGlobalProvider() throws Exception {
- ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
- BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
- bc.getServiceReferences((String)null, JaxRSUtils.PROVIDERS_FILTER);
- EasyMock.expectLastCall().andReturn(new ServiceReference[] {sref});
- sref.getProperty(Constants.RS_PROVIDER_PROP_KEY);
- EasyMock.expectLastCall().andReturn(false);
- bc.getService(sref);
- AegisElementProvider<?> p = new AegisElementProvider();
- EasyMock.expectLastCall().andReturn(p);
- EasyMock.replay(bc);
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_EXPECTED_PROP_KEY, "true");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(0, providers.size());
- }
-
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- public void testCustomGlobalProviderExpected() throws Exception {
- ServiceReference sref = EasyMock.createNiceMock(ServiceReference.class);
- BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
- bc.getServiceReferences((String)null, JaxRSUtils.PROVIDERS_FILTER);
- EasyMock.expectLastCall().andReturn(new ServiceReference[] {sref});
- sref.getProperty(Constants.RS_PROVIDER_PROP_KEY);
- EasyMock.expectLastCall().andReturn(true);
- bc.getService(sref);
- AegisElementProvider<?> p = new AegisElementProvider();
- EasyMock.expectLastCall().andReturn(p);
- EasyMock.replay(bc, sref);
- Map<String, Object> props = new HashMap<String, Object>();
- props.put(Constants.RS_PROVIDER_EXPECTED_PROP_KEY, "true");
- addRequiredProps(props);
-
- List<Object> providers = JaxRSUtils.getProviders(bc, props);
- assertEquals(1, providers.size());
- assertSame(p, providers.get(0));
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java
deleted file mode 100644
index 7d574ca..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.simple;
-
-public interface MySimpleEchoService {
- String echo(String message);
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java b/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java
deleted file mode 100644
index 19dda4b..0000000
--- a/cxf-dsw/src/test/java/org/apache/cxf/dosgi/dsw/handlers/simple/MySimpleEchoServiceImpl.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.simple;
-
-public class MySimpleEchoServiceImpl implements MySimpleEchoService {
-
- @Override
- public String echo(String message) {
- return message;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/decorator/pom.xml
----------------------------------------------------------------------
diff --git a/decorator/pom.xml b/decorator/pom.xml
index e894925..9e37865 100644
--- a/decorator/pom.xml
+++ b/decorator/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/distribution/features/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/features/pom.xml b/distribution/features/pom.xml
index 6b8e9db..3e43801 100644
--- a/distribution/features/pom.xml
+++ b/distribution/features/pom.xml
@@ -21,7 +21,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-distribution-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/distribution/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/distribution/features/src/main/resources/features.xml b/distribution/features/src/main/resources/features.xml
index 9e2a22e..ed36c23 100644
--- a/distribution/features/src/main/resources/features.xml
+++ b/distribution/features/src/main/resources/features.xml
@@ -12,20 +12,29 @@
<bundle start-level="20">mvn:org.apache.aries.proxy/org.apache.aries.proxy.api/1.0.1</bundle>
</feature>
-
- <feature name="cxf-dosgi-provider-cxf" version="${project.version}">
+
+ <feature name="cxf-dosgi-common" version="${project.version}">
<feature>aries-rsa-core</feature>
<feature>cxf-specs</feature>
- <feature>cxf-jaxws</feature>
- <feature>cxf-jaxrs</feature>
- <feature>cxf-databinding-aegis</feature>
- <feature>cxf-http-jetty</feature>
<feature>cxf-http</feature>
<feature>http</feature>
+ <feature>cxf-http-jetty</feature>
<bundle dependency="true">mvn:org.apache.felix/org.apache.felix.scr/2.0.2</bundle>
<bundle>mvn:${project.groupId}/cxf-dosgi-ri-common/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/cxf-dosgi-ri-dsw-cxf/${project.version}</bundle>
<bundle>mvn:${project.groupId}/cxf-dosgi-ri-decorator/${project.version}</bundle>
</feature>
+ <feature name="cxf-dosgi-provider-ws" version="${project.version}">
+ <feature>cxf-dosgi-common</feature>
+ <feature>cxf-jaxws</feature>
+ <feature>cxf-databinding-aegis</feature>
+ <bundle>mvn:${project.groupId}/cxf-dosgi-ri-provider-ws/${project.version}</bundle>
+ </feature>
+
+ <feature name="cxf-dosgi-provider-rs" version="${project.version}">
+ <feature>cxf-dosgi-common</feature>
+ <feature>cxf-jaxrs</feature>
+ <bundle>mvn:${project.groupId}/cxf-dosgi-ri-provider-rs/${project.version}</bundle>
+ </feature>
+
</features>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/distribution/multi-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/multi-bundle/pom.xml b/distribution/multi-bundle/pom.xml
index b3e2cd4..3afda1c 100644
--- a/distribution/multi-bundle/pom.xml
+++ b/distribution/multi-bundle/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-distribution-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -67,7 +67,8 @@
<features>
<feature>cxf-dosgi-base</feature>
<feature>aries-rsa-discovery-zookeeper</feature>
- <feature>cxf-dosgi-provider-cxf</feature>
+ <feature>cxf-dosgi-provider-ws</feature>
+ <feature>cxf-dosgi-provider-rs</feature>
</features>
<repository>target/distribution_bundles</repository>
<resolveDefinedRepositoriesRecursively>true</resolveDefinedRepositoriesRecursively>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/distribution/multi-bundle/src/main/xsl/filter_features.xslt
----------------------------------------------------------------------
diff --git a/distribution/multi-bundle/src/main/xsl/filter_features.xslt b/distribution/multi-bundle/src/main/xsl/filter_features.xslt
index 5fdfd2e..81b33a3 100644
--- a/distribution/multi-bundle/src/main/xsl/filter_features.xslt
+++ b/distribution/multi-bundle/src/main/xsl/filter_features.xslt
@@ -9,6 +9,9 @@
<xsl:template match="bundle[@artifactId='org.apache.karaf.http.core']"></xsl:template>
<xsl:template match="bundle[@artifactId='org.apache.aries.spifly.dynamic.bundle']"></xsl:template>
<xsl:template match="bundle[@groupId='org.eclipse.jetty.websocket']"></xsl:template>
+ <xsl:template match="bundle[@artifactId='org.apache.karaf.scr.command']"></xsl:template>
+ <xsl:template match="bundle[@artifactId='org.apache.felix.webconsole.plugins.ds']"></xsl:template>
+ <xsl:template match="bundle[@artifactId='org.apache.aries.rsa.discovery.command']"></xsl:template>
<!-- Copy the rest unachanged -->
<xsl:template match="@* | node()">
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/distribution/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/pom.xml b/distribution/pom.xml
index be71e5a..8b60b4b 100644
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-distribution-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Distributed OSGI Distribution Parent</name>
<url>http://cxf.apache.org</url>
@@ -29,7 +29,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/distribution/sources/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/sources/pom.xml b/distribution/sources/pom.xml
index 39a53e8..6c6b05f 100644
--- a/distribution/sources/pom.xml
+++ b/distribution/sources/pom.xml
@@ -22,14 +22,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-source-distribution</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<name>Distributed OSGI Source Distribution</name>
<url>http://cxf.apache.org</url>
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-distribution-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index f9d71c5..64a68d0 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -15,7 +15,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -30,8 +30,8 @@
<osgi.version>5.0.0</osgi.version>
<osgi.compendium.version>5.0.0</osgi.compendium.version>
- <aries.rsa.version>1.8.0</aries.rsa.version>
- <cxf.version>3.1.6</cxf.version>
+ <aries.rsa.version>1.9-SNAPSHOT</aries.rsa.version>
+ <cxf.version>3.1.7-SNAPSHOT</cxf.version>
<felix.version>5.4.0</felix.version>
<zookeeper.version>3.4.8</zookeeper.version>
<remote.service.admin.interfaces.version>1.0.0</remote.service.admin.interfaces.version>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 095346f..b07da5c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Distributed OSGI Reference Implementation</name>
@@ -104,7 +104,8 @@
<module>parent</module>
<module>decorator</module>
<module>common</module>
- <module>cxf-dsw</module>
+ <module>provider-ws</module>
+ <module>provider-rs</module>
<module>samples</module>
<module>distribution</module>
<module>systests2</module>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-rs/bnd.bnd
----------------------------------------------------------------------
diff --git a/provider-rs/bnd.bnd b/provider-rs/bnd.bnd
new file mode 100644
index 0000000..99f067a
--- /dev/null
+++ b/provider-rs/bnd.bnd
@@ -0,0 +1,3 @@
+Import-Package: javax.servlet;version='[2,4)', javax.servlet.http;version='[2,4)', *
+
+Private-Package: org.apache.cxf.dosgi.dsw.*
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-rs/pom.xml
----------------------------------------------------------------------
diff --git a/provider-rs/pom.xml b/provider-rs/pom.xml
new file mode 100644
index 0000000..664b3d7
--- /dev/null
+++ b/provider-rs/pom.xml
@@ -0,0 +1,61 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>cxf-dosgi-ri-provider-rs</artifactId>
+ <packaging>bundle</packaging>
+ <name>CXF dOSGi provider rs</name>
+
+ <parent>
+ <groupId>org.apache.cxf.dosgi</groupId>
+ <artifactId>cxf-dosgi-ri-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <properties>
+ <topDirectoryLocation>..</topDirectoryLocation>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cxf.dosgi</groupId>
+ <artifactId>cxf-dosgi-ri-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-core</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-rs-client</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsConstants.java
----------------------------------------------------------------------
diff --git a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsConstants.java b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsConstants.java
new file mode 100644
index 0000000..9d13064
--- /dev/null
+++ b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsConstants.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.dosgi.dsw.handlers.rest;
+
+public final class RsConstants {
+
+ public static final String RS_CONFIG_TYPE = "org.apache.cxf.rs";
+ public static final String RS_ADDRESS_PROPERTY = RS_CONFIG_TYPE + ".address";
+ public static final String RS_HTTP_SERVICE_CONTEXT = RS_CONFIG_TYPE + ".httpservice.context";
+ public static final String RS_DATABINDING_PROP_KEY = RS_CONFIG_TYPE + ".databinding";
+ public static final String RS_CONTEXT_PROPS_PROP_KEY = RS_CONFIG_TYPE + ".context.properties";
+ public static final String RS_PROVIDER_PROP_KEY = RS_CONFIG_TYPE + ".provider";
+ public static final String RS_PROVIDER_EXPECTED_PROP_KEY = RS_PROVIDER_PROP_KEY + ".expected";
+ public static final String RS_PROVIDER_GLOBAL_PROP_KEY = RS_PROVIDER_PROP_KEY + ".globalquery";
+ public static final String RS_WADL_LOCATION = RS_CONFIG_TYPE + ".wadl.location";
+
+ private RsConstants() {
+ // never constructed
+ }
+}
[3/3] cxf-dosgi git commit: [DOSGI-245] Split cxf provider into rs
and ws provider
Posted by cs...@apache.org.
[DOSGI-245] Split cxf provider into rs and ws provider
Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/f0dea506
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/f0dea506
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/f0dea506
Branch: refs/heads/master
Commit: f0dea50617f70a08d5fe273f5468fb59b99d7455
Parents: ccf5a7a
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Jul 5 17:27:02 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Jul 5 17:27:02 2016 +0200
----------------------------------------------------------------------
common/pom.xml | 7 +-
.../cxf/dosgi/common/intent/IntentManager.java | 3 -
.../dosgi/common/intent/IntentManagerImpl.java | 141 ++----
.../cxf/dosgi/common/intent/IntentMap.java | 62 ---
.../dosgi/common/qos/IntentManagerImplTest.java | 281 ------------
.../cxf/dosgi/common/qos/IntentMapTest.java | 42 --
cxf-dsw/bnd.bnd | 3 -
cxf-dsw/pom.xml | 83 ----
.../dsw/handlers/CXFDistributionProvider.java | 222 ----------
.../AbstractPojoConfigurationTypeHandler.java | 151 -------
.../dsw/handlers/pojo/InterceptorSupport.java | 63 ---
.../pojo/PojoConfigurationTypeHandler.java | 174 --------
.../pojo/WsdlConfigurationTypeHandler.java | 162 -------
.../dosgi/dsw/handlers/pojo/WsdlSupport.java | 83 ----
.../rest/JaxRSPojoConfigurationTypeHandler.java | 263 -----------
.../cxf/dosgi/dsw/handlers/rest/JaxRSUtils.java | 122 -----
.../apache/cxf/dosgi/dsw/osgi/Constants.java | 84 ----
.../handlers/CXFDistributionProviderTest.java | 109 -----
.../WsdlConfigurationTypeHandlerTest.java | 67 ---
.../dsw/handlers/jaxws/MyJaxWsEchoService.java | 26 --
.../handlers/jaxws/MyJaxWsEchoServiceImpl.java | 27 --
.../pojo/PojoConfigurationTypeHandlerTest.java | 443 -------------------
.../dosgi/dsw/handlers/rest/JaxRSUtilsTest.java | 195 --------
.../handlers/simple/MySimpleEchoService.java | 23 -
.../simple/MySimpleEchoServiceImpl.java | 27 --
decorator/pom.xml | 2 +-
distribution/features/pom.xml | 2 +-
.../features/src/main/resources/features.xml | 23 +-
distribution/multi-bundle/pom.xml | 5 +-
.../src/main/xsl/filter_features.xslt | 3 +
distribution/pom.xml | 4 +-
distribution/sources/pom.xml | 4 +-
parent/pom.xml | 6 +-
pom.xml | 5 +-
provider-rs/bnd.bnd | 3 +
provider-rs/pom.xml | 61 +++
.../dosgi/dsw/handlers/rest/RsConstants.java | 36 ++
.../cxf/dosgi/dsw/handlers/rest/RsProvider.java | 229 ++++++++++
provider-ws/bnd.bnd | 3 +
provider-ws/pom.xml | 61 +++
.../cxf/dosgi/dsw/handlers/ws/WsConstants.java | 46 ++
.../cxf/dosgi/dsw/handlers/ws/WsProvider.java | 244 ++++++++++
.../cxf/dosgi/dsw/handlers/ws/WsdlSupport.java | 82 ++++
.../dsw/handlers/jaxws/MyJaxWsEchoService.java | 26 ++
.../handlers/jaxws/MyJaxWsEchoServiceImpl.java | 27 ++
.../handlers/simple/MySimpleEchoService.java | 23 +
.../simple/MySimpleEchoServiceImpl.java | 27 ++
.../ws/PojoConfigurationTypeHandlerTest.java | 415 +++++++++++++++++
samples/ds/client/pom.xml | 2 +-
samples/ds/impl/pom.xml | 2 +-
samples/ds/interface/pom.xml | 2 +-
samples/ds/pom.xml | 4 +-
samples/greeter/client/pom.xml | 2 +-
samples/greeter/impl/pom.xml | 2 +-
samples/greeter/interface/pom.xml | 2 +-
.../dosgi/samples/greeter/GreeterService.java | 1 -
samples/greeter/pom.xml | 2 +-
samples/greeter_rest/client/pom.xml | 2 +-
samples/greeter_rest/impl/pom.xml | 2 +-
samples/greeter_rest/interface/pom.xml | 2 +-
samples/greeter_rest/pom.xml | 2 +-
samples/pom.xml | 2 +-
samples/security_filter/pom.xml | 2 +-
systests2/multi-bundle/pom.xml | 2 +-
.../systests2/multi/AbstractDosgiTest.java | 7 +-
.../dosgi/systests2/multi/TestCustomIntent.java | 5 +-
.../systests2/multi/TestExportRestService.java | 3 +-
.../systests2/multi/TestExportService.java | 1 +
.../multi/rest/TranslateActivator.java | 1 -
systests2/pom.xml | 4 +-
70 files changed, 1386 insertions(+), 2868 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/common/pom.xml
----------------------------------------------------------------------
diff --git a/common/pom.xml b/common/pom.xml
index 952f2c1..8e7e136 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.apache.cxf.dosgi</groupId>
<artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
+ <version>2.0-SNAPSHOT</version>
<relativePath>../parent/pom.xml</relativePath>
</parent>
@@ -48,11 +48,6 @@
<version>${cxf.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_${servlet.version}_spec</artifactId>
<version>1.0</version>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java b/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java
index 32eedab..baa0b0c 100644
--- a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManager.java
@@ -25,9 +25,6 @@ import org.apache.cxf.endpoint.AbstractEndpointFactory;
import org.apache.cxf.feature.Feature;
public interface IntentManager {
- @Deprecated
- String EXPORTED_INTENTS_OLD = "osgi.remote.requires.intents";
-
String INTENT_NAME_PROP = "org.apache.cxf.dosgi.IntentName";
String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory, Map<String, Object> props);
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManagerImpl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManagerImpl.java b/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManagerImpl.java
index 3bbfaab..4cb23fd 100644
--- a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManagerImpl.java
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentManagerImpl.java
@@ -23,7 +23,6 @@ import static org.osgi.service.component.annotations.ReferenceCardinality.MULTIP
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -32,14 +31,10 @@ import java.util.Set;
import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
import org.apache.cxf.binding.BindingConfiguration;
-import org.apache.cxf.binding.soap.Soap11;
-import org.apache.cxf.binding.soap.Soap12;
-import org.apache.cxf.binding.soap.SoapBindingConfiguration;
-import org.apache.cxf.binding.soap.SoapVersion;
+import org.apache.cxf.databinding.DataBinding;
import org.apache.cxf.dosgi.common.util.OsgiUtils;
import org.apache.cxf.endpoint.AbstractEndpointFactory;
import org.apache.cxf.feature.Feature;
-import org.apache.cxf.feature.LoggingFeature;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferencePolicy;
@@ -52,39 +47,13 @@ import org.slf4j.LoggerFactory;
public class IntentManagerImpl implements IntentManager {
static final Logger LOG = LoggerFactory.getLogger(IntentManagerImpl.class);
- private static final String PROVIDED_INTENT_VALUE = "PROVIDED";
private static final int DEFAULT_INTENT_TIMEOUT = 30000;
- private final IntentMap intentMap;
+ private final Map<String, Object> intentMap;
private final long maxIntentWaitTime = DEFAULT_INTENT_TIMEOUT;
public IntentManagerImpl() {
- this(new IntentMap(create()));
- }
-
- public IntentManagerImpl(IntentMap intentMap) {
- this.intentMap = intentMap;
- }
-
- public static Map<String, Object> create() {
- Map<String, Object> defaults = new HashMap<String, Object>();
- defaults.put("logging", getLoggingFeature());
- Object soap11 = getSoapBinding(Soap11.getInstance());
- defaults.put("SOAP", soap11);
- defaults.put("SOAP.1_1", soap11);
- defaults.put("SOAP.1_2", getSoapBinding(Soap12.getInstance()));
- defaults.put("HTTP", "PROVIDED");
- return defaults;
- }
-
- private static Object getLoggingFeature() {
- return new LoggingFeature();
- }
-
- private static Object getSoapBinding(SoapVersion soapVersion) {
- SoapBindingConfiguration soapBindingConfig = new SoapBindingConfiguration();
- soapBindingConfig.setVersion(soapVersion);
- return soapBindingConfig;
+ this.intentMap = new HashMap<String, Object>();
}
@Reference //
@@ -94,56 +63,46 @@ public class IntentManagerImpl implements IntentManager {
target = "(" + IntentManager.INTENT_NAME_PROP + "=*)", //
policyOption = ReferencePolicyOption.GREEDY
)
- public void addIntent(Object intent, Map<String, ?> props) {
+ public synchronized void addIntent(Object intent, Map<String, ?> props) {
String intentName = (String)props.get(INTENT_NAME_PROP);
LOG.info("Adding custom intent " + intentName);
intentMap.put(intentName, intent);
}
- public void removeIntent(Object intent, Map<String, ?> props) {
+ public synchronized void removeIntent(Object intent, Map<String, ?> props) {
String intentName = (String)props.get(INTENT_NAME_PROP);
intentMap.remove(intentName);
}
- public String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory,
+ public synchronized String[] applyIntents(List<Feature> features, AbstractEndpointFactory factory,
Map<String, Object> props)
throws IntentUnsatisfiedException {
+ Set<String> requiredIntents = IntentManagerImpl.getRequestedIntents(props);
+ List<String> missingIntents = getMissingIntents(requiredIntents);
+ if (!missingIntents.isEmpty()) {
+ throw new IntentUnsatisfiedException(missingIntents.iterator().next());
+ }
Set<String> requestedIntents = IntentManagerImpl.getRequestedIntents(props);
Set<String> appliedIntents = new HashSet<String>();
- appliedIntents.addAll(reverseLookup(intentMap, PROVIDED_INTENT_VALUE));
- boolean bindingApplied = false;
for (String intentName : requestedIntents) {
- bindingApplied |= processIntent(features, factory, intentName, intentMap.get(intentName));
+ processIntent(features, factory, intentName, intentMap.get(intentName));
appliedIntents.add(intentName);
}
- if (!bindingApplied) {
- String defaultBindingName = "SOAP";
- processIntent(features, factory, defaultBindingName, intentMap.get(defaultBindingName));
- appliedIntents.add(defaultBindingName);
- }
- appliedIntents.addAll(addSynonymIntents(appliedIntents, intentMap));
return appliedIntents.toArray(new String[appliedIntents.size()]);
}
private static Set<String> getRequestedIntents(Map<String, Object> sd) {
+ Set<String> allIntents = new HashSet<String>();
Collection<String> intents = OsgiUtils
.getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS));
- Collection<String> intents2 = OsgiUtils
- .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA));
- @SuppressWarnings("deprecation")
- Collection<String> oldIntents = OsgiUtils
- .getMultiValueProperty(sd.get(IntentManager.EXPORTED_INTENTS_OLD));
- Set<String> allIntents = new HashSet<String>();
if (intents != null) {
allIntents.addAll(parseIntents(intents));
}
+ Collection<String> intents2 = OsgiUtils
+ .getMultiValueProperty(sd.get(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA));
if (intents2 != null) {
allIntents.addAll(parseIntents(intents2));
}
- if (oldIntents != null) {
- allIntents.addAll(parseIntents(oldIntents));
- }
-
return allIntents;
}
@@ -158,10 +117,11 @@ public class IntentManagerImpl implements IntentManager {
private boolean processIntent(List<Feature> features, AbstractEndpointFactory factory, String intentName,
Object intent)
throws IntentUnsatisfiedException {
- if (intent instanceof String) {
- if (PROVIDED_INTENT_VALUE.equalsIgnoreCase((String)intent)) {
- return false;
- }
+ if (intent instanceof DataBinding) {
+ DataBinding dataBinding = (DataBinding) intent;
+ LOG.info("Applying intent: " + intentName + " via data binding: " + dataBinding);
+ factory.setDataBinding(dataBinding);
+ return false;
} else if (intent instanceof BindingConfiguration) {
BindingConfiguration bindingCfg = (BindingConfiguration)intent;
LOG.info("Applying intent: " + intentName + " via binding config: " + bindingCfg);
@@ -176,58 +136,21 @@ public class IntentManagerImpl implements IntentManager {
LOG.info("No mapping for intent: " + intentName);
throw new IntentUnsatisfiedException(intentName);
}
- return false;
}
- private static Collection<String> addSynonymIntents(Collection<String> appliedIntents, IntentMap map) {
- // E.g. SOAP and SOAP.1_1 are synonyms
- List<Object> values = new ArrayList<Object>();
- for (String key : appliedIntents) {
- values.add(map.get(key));
- }
- return reverseLookup(map, values);
- }
-
- private static Collection<String> reverseLookup(IntentMap im, Object obj) {
- return reverseLookup(im, Collections.singleton(obj));
- }
-
- /**
- * Retrieves all keys whose mapped values are found in the given collection.
- *
- * @param im an intent map
- * @param values a collection of potential values
- * @return all keys whose mapped values are found in the given collection
- */
- private static Collection<String> reverseLookup(IntentMap im, Collection<?> values) {
- Set<String> intentsFound = new HashSet<String>();
- for (Map.Entry<String, Object> entry : im.entrySet()) {
- if (values.contains(entry.getValue())) {
- intentsFound.add(entry.getKey());
- }
- }
- return intentsFound;
- }
-
- public void assertAllIntentsSupported(Map<String, Object> serviceProperties) {
+ public synchronized void assertAllIntentsSupported(Map<String, Object> serviceProperties) {
long endTime = System.currentTimeMillis() + maxIntentWaitTime;
Set<String> requiredIntents = IntentManagerImpl.getRequestedIntents(serviceProperties);
- List<String> unsupportedIntents = new ArrayList<String>();
+
+ List<String> unsupportedIntents;
do {
- unsupportedIntents.clear();
- for (String ri : requiredIntents) {
- if (!intentMap.containsKey(ri)) {
- unsupportedIntents.add(ri);
- }
- }
+ unsupportedIntents = getMissingIntents(requiredIntents);
long remainingSeconds = (endTime - System.currentTimeMillis()) / 1000;
if (!unsupportedIntents.isEmpty() && remainingSeconds > 0) {
- LOG.debug("Waiting for custom intents " + unsupportedIntents + " timeout in "
+ LOG.info("Waiting for custom intents " + unsupportedIntents + " timeout in "
+ remainingSeconds);
try {
- synchronized (intentMap) {
- intentMap.wait(1000);
- }
+ wait(1000);
} catch (InterruptedException e) {
LOG.warn(e.getMessage(), e);
}
@@ -239,4 +162,16 @@ public class IntentManagerImpl implements IntentManager {
+ "intents are not supported by this RSA: " + unsupportedIntents);
}
}
+
+ private synchronized List<String> getMissingIntents(Set<String> requiredIntents) {
+ List<String> unsupportedIntents = new ArrayList<String>();
+ unsupportedIntents.clear();
+ for (String ri : requiredIntents) {
+ if (!intentMap.containsKey(ri)) {
+ unsupportedIntents.add(ri);
+ }
+ }
+ return unsupportedIntents;
+ }
+
}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentMap.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentMap.java b/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentMap.java
deleted file mode 100644
index 9539c95..0000000
--- a/common/src/main/java/org/apache/cxf/dosgi/common/intent/IntentMap.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.common.intent;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Maps intent names to intent objects
- * An intent object can be a Feature, a BindingConfiguration or a String
- *
- * Also supports a default intent map. Custom intents can override the defaults
- */
-public class IntentMap extends ConcurrentHashMap<String, Object> {
-
- private static final long serialVersionUID = 2606460607920520767L;
- private Map<String, Object> defaultMap;
-
- public IntentMap() {
- this(new HashMap<String, Object>());
- }
-
- public IntentMap(Map<String, Object> defaultMap) {
- this.defaultMap = defaultMap;
- putAll(defaultMap);
- }
-
- @Override
- public Object put(String key, Object value) {
- Object result = super.put(key, value);
- synchronized (this) {
- notifyAll();
- }
- return result;
- }
-
- @Override
- public Object remove(Object key) {
- Object old = super.remove(key);
- if (defaultMap.containsKey(key)) {
- put((String)key, defaultMap.get(key));
- }
- return old;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/common/src/test/java/org/apache/cxf/dosgi/common/qos/IntentManagerImplTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/qos/IntentManagerImplTest.java b/common/src/test/java/org/apache/cxf/dosgi/common/qos/IntentManagerImplTest.java
deleted file mode 100644
index 15fe952..0000000
--- a/common/src/test/java/org/apache/cxf/dosgi/common/qos/IntentManagerImplTest.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.common.qos;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
-import org.apache.cxf.binding.BindingConfiguration;
-import org.apache.cxf.dosgi.common.intent.IntentManager;
-import org.apache.cxf.dosgi.common.intent.IntentManagerImpl;
-import org.apache.cxf.dosgi.common.intent.IntentMap;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.feature.Feature;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class IntentManagerImplTest extends Assert {
-
- @Test
- public void testIntents() throws Exception {
- Map<String, Object> intents = new HashMap<String, Object>();
- intents.put("A", new TestFeature("A"));
- intents.put("SOAP", new TestFeature("SOAP"));
- final IntentMap intentMap = new IntentMap(intents);
-
- IMocksControl control = EasyMock.createNiceControl();
- List<Feature> features = new ArrayList<Feature>();
- AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
- control.replay();
-
- IntentManager intentManager = new IntentManagerImpl(intentMap);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put("osgi.remote.requires.intents", "A");
-
- List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props));
- assertEquals(Arrays.asList("A", "SOAP"), effectiveIntents);
- }
-
- @Test
- public void testMultiIntents() {
- final IntentMap intentMap = new IntentMap(IntentManagerImpl.create());
- intentMap.put("confidentiality.message", new TestFeature("confidentiality.message"));
- intentMap.put("transactionality", new TestFeature("transactionality"));
-
- IMocksControl control = EasyMock.createNiceControl();
- List<Feature> features = new ArrayList<Feature>();
- AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
- control.replay();
-
- IntentManager intentManager = new IntentManagerImpl(intentMap);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put("osgi.remote.requires.intents", "transactionality confidentiality.message");
-
- List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props));
- assertTrue(effectiveIntents.contains("transactionality"));
- assertTrue(effectiveIntents.contains("confidentiality.message"));
- }
-
- @Test
- public void testFailedIntent() {
- Map<String, Object> intents = new HashMap<String, Object>();
- intents.put("A", new TestFeature("A"));
- final IntentMap intentMap = new IntentMap(intents);
-
- IMocksControl control = EasyMock.createNiceControl();
- List<Feature> features = new ArrayList<Feature>();
- AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
- control.replay();
-
- IntentManager intentManager = new IntentManagerImpl(intentMap);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put("osgi.remote.requires.intents", "A B");
- // ServiceEndpointDescription sd =
- // new ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props);
-
- try {
- intentManager.applyIntents(features, factory, props);
- Assert.fail("applyIntents() should have thrown an exception as there was an unsatisfiable intent");
- } catch (IntentUnsatisfiedException iue) {
- assertEquals("B", iue.getIntent());
- }
- }
-
- @Test
- public void testInferIntents() {
- Map<String, Object> intents = new HashMap<String, Object>();
- intents.put("SOAP", new TestFeature("SOAP"));
- intents.put("Prov", "PROVIDED");
- AbstractFeature feat1 = new TestFeature("feat1");
- intents.put("A", feat1);
- intents.put("A_alt", feat1);
- intents.put("B", new TestFeature("B"));
- final IntentMap intentMap = new IntentMap(intents);
-
- IMocksControl control = EasyMock.createNiceControl();
- List<Feature> features = new ArrayList<Feature>();
- AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
- control.replay();
-
- IntentManager intentManager = new IntentManagerImpl(intentMap);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put("osgi.remote.requires.intents", "A");
- // ServiceEndpointDescription sd =
- // new ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props);
-
- List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props));
- assertEquals(4, effectiveIntents.size());
- assertTrue(effectiveIntents.contains("Prov"));
- assertTrue(effectiveIntents.contains("A"));
- assertTrue(effectiveIntents.contains("A_alt"));
- }
-
- @Test
- public void testDefaultBindingIntent() {
- IMocksControl control = EasyMock.createNiceControl();
-
- Map<String, Object> intents = new HashMap<String, Object>();
- BindingConfiguration feat1 = control.createMock(BindingConfiguration.class);
- intents.put("A", new AbstractFeature() {
- });
- intents.put("SOAP", feat1);
- intents.put("SOAP.1_1", feat1);
- intents.put("SOAP.1_2", control.createMock(BindingConfiguration.class));
- final IntentMap intentMap = new IntentMap(intents);
-
- List<Feature> features = new ArrayList<Feature>();
- AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
- control.replay();
- IntentManager intentManager = new IntentManagerImpl(intentMap);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put("osgi.remote.requires.intents", "A");
- // ServiceEndpointDescription sd =
- // new ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props);
-
- List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props));
- assertEquals(3, effectiveIntents.size());
- assertTrue(effectiveIntents.contains("A"));
- assertTrue(effectiveIntents.contains("SOAP"));
- assertTrue(effectiveIntents.contains("SOAP.1_1"));
- }
-
- @Test
- public void testExplicitBindingIntent() {
- IMocksControl control = EasyMock.createNiceControl();
-
- Map<String, Object> intents = new HashMap<String, Object>();
- BindingConfiguration feat1 = control.createMock(BindingConfiguration.class);
- intents.put("A", new AbstractFeature() {
- });
- intents.put("SOAP", feat1);
- intents.put("SOAP.1_1", feat1);
- intents.put("SOAP.1_2", control.createMock(BindingConfiguration.class));
- final IntentMap intentMap = new IntentMap(intents);
-
- List<Feature> features = new ArrayList<Feature>();
- AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
- control.replay();
-
- IntentManager intentManager = new IntentManagerImpl(intentMap);
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put("osgi.remote.requires.intents", "A SOAP.1_2");
- // ServiceEndpointDescription sd =
- // new ServiceEndpointDescriptionImpl(Arrays.asList(String.class.getName()), props);
-
- List<String> effectiveIntents = Arrays.asList(intentManager.applyIntents(features, factory, props));
- assertEquals(2, effectiveIntents.size());
- assertTrue(effectiveIntents.contains("A"));
- assertTrue(effectiveIntents.contains("SOAP.1_2"));
- }
-
- public void testInheritMasterIntentMapDefault() {
- List<String> features = runTestInheritMasterIntentMap("A B");
-
- assertEquals(2, features.size());
- assertTrue(features.contains("appFeatureA"));
- assertTrue(features.contains("masterFeatureB"));
- }
-
- public void testInheritMasterIntentMap() {
- List<String> features = runTestInheritMasterIntentMap("A B");
-
- assertEquals(2, features.size());
- assertTrue(features.contains("appFeatureA"));
- assertTrue(features.contains("masterFeatureB"));
- }
-
- private List<String> runTestInheritMasterIntentMap(String requestedIntents) {
- Map<String, Object> masterIntents = new HashMap<String, Object>();
- masterIntents.put("A", new TestFeature("masterFeatureA"));
- masterIntents.put("B", new TestFeature("masterFeatureB"));
- final IntentMap intentMap = new IntentMap(masterIntents);
- intentMap.put("A", new TestFeature("appFeatureA"));
-
- IMocksControl control = EasyMock.createNiceControl();
- List<Feature> features = new ArrayList<Feature>();
- AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
- control.replay();
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put("osgi.remote.requires.intents", requestedIntents);
-
- IntentManagerImpl intentManager = new IntentManagerImpl(intentMap);
- intentManager.applyIntents(features, factory, props);
-
- List<String> featureNames = new ArrayList<String>();
- for (Feature f : features) {
- featureNames.add(f.toString());
- }
- return featureNames;
- }
-
- @Test
- public void testProvidedIntents() {
- Map<String, Object> masterIntents = new HashMap<String, Object>();
- masterIntents.put("SOAP", "SOAP");
- masterIntents.put("A", "Provided");
- masterIntents.put("B", "PROVIDED");
- final IntentMap intentMap = new IntentMap(masterIntents);
-
- IMocksControl control = EasyMock.createNiceControl();
- List<Feature> features = new ArrayList<Feature>();
- AbstractEndpointFactory factory = control.createMock(AbstractEndpointFactory.class);
- control.replay();
-
- Map<String, Object> props = new HashMap<String, Object>();
- props.put("osgi.remote.requires.intents", "B A");
-
- IntentManager intentManager = new IntentManagerImpl(intentMap);
-
- Set<String> effectiveIntents = new HashSet<String>(Arrays.asList(intentManager.applyIntents(features,
- factory,
- props)));
- Set<String> expectedIntents = new HashSet<String>(Arrays.asList(new String[] {"A", "B", "SOAP"}));
- assertEquals(expectedIntents, effectiveIntents);
- }
-
- private static final class TestFeature extends AbstractFeature {
-
- private final String name;
-
- private TestFeature(String n) {
- name = n;
- }
-
- @Override
- public String toString() {
- return name;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/common/src/test/java/org/apache/cxf/dosgi/common/qos/IntentMapTest.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/cxf/dosgi/common/qos/IntentMapTest.java b/common/src/test/java/org/apache/cxf/dosgi/common/qos/IntentMapTest.java
deleted file mode 100644
index 1bda059..0000000
--- a/common/src/test/java/org/apache/cxf/dosgi/common/qos/IntentMapTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.common.qos;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.cxf.dosgi.common.intent.IntentMap;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class IntentMapTest {
-
- @Test
- public void inheritanceTest() {
- Map<String, Object> defaultMap = new HashMap<String, Object>();
- defaultMap.put("key1", "defaultValue");
- IntentMap intentMap = new IntentMap(defaultMap);
- Assert.assertEquals("defaultValue", intentMap.get("key1"));
- intentMap.put("key1", "overridden");
- Assert.assertEquals("overridden", intentMap.get("key1"));
- Object curValue = intentMap.remove("key1");
- Assert.assertEquals("overridden", curValue);
- Assert.assertEquals("defaultValue", intentMap.get("key1"));
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/bnd.bnd
----------------------------------------------------------------------
diff --git a/cxf-dsw/bnd.bnd b/cxf-dsw/bnd.bnd
deleted file mode 100644
index 99f067a..0000000
--- a/cxf-dsw/bnd.bnd
+++ /dev/null
@@ -1,3 +0,0 @@
-Import-Package: javax.servlet;version='[2,4)', javax.servlet.http;version='[2,4)', *
-
-Private-Package: org.apache.cxf.dosgi.dsw.*
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/pom.xml
----------------------------------------------------------------------
diff --git a/cxf-dsw/pom.xml b/cxf-dsw/pom.xml
deleted file mode 100644
index d3f54aa..0000000
--- a/cxf-dsw/pom.xml
+++ /dev/null
@@ -1,83 +0,0 @@
-<?xml version='1.0' encoding='UTF-8' ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>cxf-dosgi-ri-dsw-cxf</artifactId>
- <packaging>bundle</packaging>
- <name>CXF dOSGi Distribution provider</name>
-
- <parent>
- <groupId>org.apache.cxf.dosgi</groupId>
- <artifactId>cxf-dosgi-ri-parent</artifactId>
- <version>1.9-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
-
- <properties>
- <topDirectoryLocation>..</topDirectoryLocation>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.cxf.dosgi</groupId>
- <artifactId>cxf-dosgi-ri-common</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-core</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-frontend-jaxrs</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-client</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-databinding-aegis</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-extension-providers</artifactId>
- <version>${cxf.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_${servlet.version}_spec</artifactId>
- <version>1.0</version>
- </dependency>
-
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
deleted file mode 100644
index 287c4f1..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/CXFDistributionProvider.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers;
-
-import static org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_CONFIGS_SUPPORTED;
-import static org.osgi.service.remoteserviceadmin.RemoteConstants.REMOTE_INTENTS_SUPPORTED;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.aries.rsa.spi.DistributionProvider;
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
-import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
-import org.apache.cxf.dosgi.common.intent.IntentManager;
-import org.apache.cxf.dosgi.common.util.OsgiUtils;
-import org.apache.cxf.dosgi.common.util.StringPlus;
-import org.apache.cxf.dosgi.dsw.handlers.pojo.PojoConfigurationTypeHandler;
-import org.apache.cxf.dosgi.dsw.handlers.pojo.WsdlConfigurationTypeHandler;
-import org.apache.cxf.dosgi.dsw.handlers.rest.JaxRSPojoConfigurationTypeHandler;
-import org.apache.cxf.dosgi.dsw.osgi.Constants;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Reference;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-@Component(configurationPid = "cxf-dsw", property = //
-{//
- REMOTE_CONFIGS_SUPPORTED + "=" + Constants.WS_CONFIG_TYPE,
- REMOTE_CONFIGS_SUPPORTED + "=" + Constants.WSDL_CONFIG_TYPE,
- REMOTE_CONFIGS_SUPPORTED + "=" + Constants.RS_CONFIG_TYPE,
- REMOTE_CONFIGS_SUPPORTED + "=" + Constants.WS_CONFIG_TYPE_OLD,
- REMOTE_INTENTS_SUPPORTED + "="
-})
-public class CXFDistributionProvider implements DistributionProvider {
- public static final String[] SUPPORTED_CONFIGS = new String[] //
- {//
- Constants.WS_CONFIG_TYPE, Constants.WSDL_CONFIG_TYPE, Constants.RS_CONFIG_TYPE,
- Constants.WS_CONFIG_TYPE_OLD
- };
-
- protected static final String DEFAULT_CONFIGURATION_TYPE = Constants.WS_CONFIG_TYPE;
- private static final Logger LOG = LoggerFactory.getLogger(CXFDistributionProvider.class);
-
-
- private IntentManager intentManager;
- private PojoConfigurationTypeHandler pojoConfigurationTypeHandler;
- private JaxRSPojoConfigurationTypeHandler jaxRsPojoConfigurationTypeHandler;
- private WsdlConfigurationTypeHandler wsdlConfigurationTypeHandler;
- private Set<String> configTypesSet;
- private HttpServiceManager httpServiceManager;
-
- public CXFDistributionProvider() {
- configTypesSet = new HashSet<>(Arrays.asList(SUPPORTED_CONFIGS));
- }
-
- @Reference
- public void setHttpServiceManager(HttpServiceManager httpServiceManager) {
- this.httpServiceManager = httpServiceManager;
- }
-
- @Reference
- public void setIntentManager(IntentManager intentManager) {
- this.intentManager = intentManager;
- }
-
- @Activate
- public synchronized void activate(ComponentContext compContext) {
- Dictionary<String, Object> config = compContext.getProperties();
- init(compContext.getBundleContext(), config);
- // String[] supportedIntents = intentMap.keySet().toArray(new String[] {});
- // props.put(Constants.REMOTE_INTENTS_SUPPORTED, supportedIntents);
- }
-
- void init(BundleContext bc, Dictionary<String, Object> config) {
- // Disable the fast infoset as it's not compatible (yet) with OSGi
- System.setProperty("org.apache.cxf.nofastinfoset", "true");
- LOG.debug("RemoteServiceAdmin Implementation is starting up with {}", config);
- System.setProperty("org.apache.cxf.nofastinfoset", "true");
- this.pojoConfigurationTypeHandler = new PojoConfigurationTypeHandler(bc, intentManager, httpServiceManager);
- this.jaxRsPojoConfigurationTypeHandler = new JaxRSPojoConfigurationTypeHandler(bc,
- intentManager,
- httpServiceManager);
- this.wsdlConfigurationTypeHandler = new WsdlConfigurationTypeHandler(bc, intentManager, httpServiceManager);
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public Endpoint exportService(Object serviceO,
- BundleContext serviceContext,
- Map<String, Object> effectiveProperties,
- Class[] exportedInterfaces) {
- List<String> configurationTypes = determineConfigurationTypes(effectiveProperties);
- DistributionProvider handler = getHandler(configurationTypes, effectiveProperties);
- return handler != null ? handler.exportService(serviceO, serviceContext,
- effectiveProperties, exportedInterfaces) : null;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public Object importEndpoint(ClassLoader consumerLoader, BundleContext consumerContext,
- Class[] iClass, EndpointDescription endpoint)
- throws IntentUnsatisfiedException {
- List<String> configurationTypes = determineConfigTypesForImport(endpoint);
- DistributionProvider handler = getHandler(configurationTypes, endpoint.getProperties());
- return handler != null ? handler.importEndpoint(consumerLoader, consumerContext, iClass, endpoint) : null;
- }
-
- DistributionProvider getHandler(List<String> configurationTypes,
- 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)) {
- boolean jaxrs = isJaxrsRequested(configurationTypes, serviceProperties);
- return jaxrs ? jaxRsPojoConfigurationTypeHandler : pojoConfigurationTypeHandler;
- } else if (configurationTypes.contains(Constants.WSDL_CONFIG_TYPE)) {
- return wsdlConfigurationTypeHandler;
- }
- LOG.info("None of the configuration types in " + configurationTypes + " is supported.");
- return null;
- }
-
- private boolean isJaxrsRequested(Collection<String> types, Map<String, Object> serviceProperties) {
- if (types == null) {
- return false;
- }
-
- if (types.contains(Constants.RS_CONFIG_TYPE)) {
- Collection<String> intentsProperty
- = OsgiUtils.getMultiValueProperty(serviceProperties.get(RemoteConstants.SERVICE_EXPORTED_INTENTS));
- boolean hasHttpIntent = false;
- boolean hasSoapIntent = false;
- if (intentsProperty != null) {
- for (String intent : intentsProperty) {
- if (intent.contains("SOAP")) {
- hasSoapIntent = true;
- break;
- }
-
- if (intent.contains("HTTP")) {
- hasHttpIntent = true;
- }
- }
- }
- if ((hasHttpIntent && !hasSoapIntent) || intentsProperty == null) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * determine which configuration types should be used / if the requested are
- * supported
- */
- List<String> determineConfigurationTypes(Map<String, Object> serviceProperties) {
- String[] requestedConfigurationTypes = StringPlus.normalize(serviceProperties
- .get(RemoteConstants.SERVICE_EXPORTED_CONFIGS));
- if (requestedConfigurationTypes == null || requestedConfigurationTypes.length == 0) {
- return Collections.singletonList(DEFAULT_CONFIGURATION_TYPE);
- }
-
- List<String> configurationTypes = new ArrayList<String>();
- for (String rct : requestedConfigurationTypes) {
- if (configTypesSet.contains(rct)) {
- configurationTypes.add(rct);
- }
- }
- LOG.info("Configuration types selected for export: {}.", configurationTypes);
- return configurationTypes;
- }
-
- private List<String> determineConfigTypesForImport(EndpointDescription endpoint) {
- List<String> remoteConfigurationTypes = endpoint.getConfigurationTypes();
-
- List<String> usableConfigurationTypes = new ArrayList<String>();
- for (String ct : SUPPORTED_CONFIGS) {
- if (remoteConfigurationTypes.contains(ct)) {
- usableConfigurationTypes.add(ct);
- }
- }
-
- LOG.info("Ignoring endpoint {} as it has no compatible configuration types: {}.",
- endpoint.getId(), remoteConfigurationTypes);
- return usableConfigurationTypes;
- }
-
- public String[] getSupportedTypes() {
- return SUPPORTED_CONFIGS;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/AbstractPojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/AbstractPojoConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/AbstractPojoConfigurationTypeHandler.java
deleted file mode 100644
index 363b843..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/AbstractPojoConfigurationTypeHandler.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.pojo;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.aries.rsa.spi.DistributionProvider;
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.cxf.Bus;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
-import org.apache.cxf.dosgi.common.intent.IntentManager;
-import org.apache.cxf.dosgi.common.util.OsgiUtils;
-import org.apache.cxf.dosgi.common.util.ServerWrapper;
-import org.apache.cxf.dosgi.common.util.StringPlus;
-import org.apache.cxf.dosgi.dsw.osgi.Constants;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-
-public abstract class AbstractPojoConfigurationTypeHandler implements DistributionProvider {
- protected BundleContext bundleContext;
- protected IntentManager intentManager;
- protected HttpServiceManager httpServiceManager;
-
- public AbstractPojoConfigurationTypeHandler(BundleContext dswBC, IntentManager intentManager,
- HttpServiceManager httpServiceManager) {
- this.bundleContext = dswBC;
- this.intentManager = intentManager;
- this.httpServiceManager = httpServiceManager;
- }
-
- protected EndpointDescription createEndpointDesc(Map<String, Object> props,
- String[] importedConfigs,
- String address,
- String[] intents) {
- props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, importedConfigs);
- for (String configurationType : importedConfigs) {
- if (Constants.WS_CONFIG_TYPE.equals(configurationType)) {
- props.put(Constants.WS_ADDRESS_PROPERTY, address);
- } else if (Constants.WS_CONFIG_TYPE_OLD.equals(configurationType)) {
- props.put(Constants.WS_ADDRESS_PROPERTY_OLD, address);
- props.put(Constants.WS_ADDRESS_PROPERTY, address);
- }
- }
- String[] sIntents = StringPlus.normalize(props.get(RemoteConstants.SERVICE_INTENTS));
- String[] allIntents = mergeArrays(intents, sIntents);
- props.put(RemoteConstants.SERVICE_INTENTS, allIntents);
- props.put(RemoteConstants.ENDPOINT_ID, address);
- return new EndpointDescription(props);
- }
-
- public static String[] mergeArrays(String[] a1, String[] a2) {
- if (a1 == null) {
- return a2;
- }
- if (a2 == null) {
- return a1;
- }
-
- List<String> list = new ArrayList<String>(a1.length + a2.length);
- Collections.addAll(list, a1);
- for (String s : a2) {
- if (!list.contains(s)) {
- list.add(s);
- }
- }
-
- return list.toArray(new String[list.size()]);
- }
-
- protected String getClientAddress(Map<String, Object> sd) {
- return OsgiUtils.getFirstNonEmptyStringProperty(sd, RemoteConstants.ENDPOINT_ID,
- Constants.WS_ADDRESS_PROPERTY,
- Constants.WS_ADDRESS_PROPERTY_OLD,
- Constants.RS_ADDRESS_PROPERTY);
- }
-
- protected String getServerAddress(Map<String, Object> sd, Class<?> iClass) {
- String address = getClientAddress(sd);
- return address == null ? httpServiceManager.getDefaultAddress(iClass) : address;
- }
-
- public String getServletContextRoot(Map<String, Object> sd) {
- return OsgiUtils.getFirstNonEmptyStringProperty(sd,
- Constants.WS_HTTP_SERVICE_CONTEXT,
- Constants.WS_HTTP_SERVICE_CONTEXT_OLD,
- Constants.WSDL_HTTP_SERVICE_CONTEXT,
- Constants.RS_HTTP_SERVICE_CONTEXT);
- }
-
- protected Bus createBus(Long sid, BundleContext callingContext, String contextRoot) {
- Bus bus = BusFactory.newInstance().createBus();
- if (contextRoot != null) {
- httpServiceManager.registerServlet(bus, contextRoot, callingContext, sid);
- }
- return bus;
- }
-
- protected Endpoint createServerFromFactory(ServerFactoryBean factory, EndpointDescription epd) {
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(ServerFactoryBean.class.getClassLoader());
- Server server = factory.create();
- return new ServerWrapper(epd, server);
- } finally {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
- }
-
- protected static void addWsInterceptorsFeaturesProps(AbstractEndpointFactory factory, BundleContext callingContext,
- Map<String, Object> sd) {
- InterceptorSupport.addInterceptors(factory, callingContext, sd, Constants.WS_IN_INTERCEPTORS_PROP_KEY);
- InterceptorSupport.addInterceptors(factory, callingContext, sd, Constants.WS_OUT_INTERCEPTORS_PROP_KEY);
- InterceptorSupport.addInterceptors(factory, callingContext, sd, Constants.WS_OUT_FAULT_INTERCEPTORS_PROP_KEY);
- InterceptorSupport.addInterceptors(factory, callingContext, sd, Constants.WS_IN_FAULT_INTERCEPTORS_PROP_KEY);
- InterceptorSupport.addFeatures(factory, callingContext, sd, Constants.WS_FEATURES_PROP_KEY);
- addContextProperties(factory, sd, Constants.WS_CONTEXT_PROPS_PROP_KEY);
- }
-
- private static void addContextProperties(AbstractEndpointFactory factory, Map<String, Object> sd, String propName) {
- @SuppressWarnings("unchecked")
- Map<String, Object> props = (Map<String, Object>)sd.get(propName);
- if (props != null) {
- factory.getProperties(true).putAll(props);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/InterceptorSupport.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/InterceptorSupport.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/InterceptorSupport.java
deleted file mode 100644
index 1965157..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/InterceptorSupport.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.pojo;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.dosgi.common.util.ClassUtils;
-import org.apache.cxf.endpoint.AbstractEndpointFactory;
-import org.apache.cxf.feature.AbstractFeature;
-import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.interceptor.Interceptor;
-import org.osgi.framework.BundleContext;
-
-public final class InterceptorSupport {
- private InterceptorSupport() {
- }
-
- public static void addInterceptors(AbstractEndpointFactory factory, BundleContext callingContext,
- Map<String, Object> sd, String propName) {
- List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName);
- boolean in = propName.contains("in.interceptors");
- boolean out = propName.contains("out.interceptors");
- boolean inFault = propName.contains("in.fault.interceptors");
- boolean outFault = propName.contains("out.fault.interceptors");
- for (Object provider : providers) {
- Interceptor<?> interceptor = (Interceptor<?>) provider;
- if (in) {
- factory.getInInterceptors().add(interceptor);
- } else if (out) {
- factory.getOutInterceptors().add(interceptor);
- } else if (inFault) {
- factory.getInFaultInterceptors().add(interceptor);
- } else if (outFault) {
- factory.getOutFaultInterceptors().add(interceptor);
- }
- }
- }
-
- public static void addFeatures(AbstractEndpointFactory factory, BundleContext callingContext,
- Map<String, Object> sd, String propName) {
- List<Object> providers = ClassUtils.loadProviderClasses(callingContext, sd, propName);
- if (!providers.isEmpty()) {
- factory.getFeatures().addAll(CastUtils.cast(providers, AbstractFeature.class));
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandler.java
deleted file mode 100644
index 2a57c91..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/PojoConfigurationTypeHandler.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.pojo;
-
-import java.util.Map;
-
-import javax.jws.WebService;
-
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.aries.rsa.spi.IntentUnsatisfiedException;
-import org.apache.cxf.Bus;
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
-import org.apache.cxf.dosgi.common.intent.IntentManager;
-import org.apache.cxf.dosgi.common.proxy.ProxyFactory;
-import org.apache.cxf.dosgi.dsw.osgi.Constants;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
-import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.jaxb.JAXBDataBinding;
-import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
-import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class PojoConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
-
- private static final Logger LOG = LoggerFactory.getLogger(PojoConfigurationTypeHandler.class);
-
- public PojoConfigurationTypeHandler(BundleContext dswBC,
- IntentManager intentManager,
- HttpServiceManager httpServiceManager) {
- super(dswBC, intentManager, httpServiceManager);
- }
-
- public String[] getSupportedTypes() {
- return new String[] {Constants.WS_CONFIG_TYPE, Constants.WS_CONFIG_TYPE_OLD};
- }
-
- @SuppressWarnings("rawtypes")
- public Object importEndpoint(ClassLoader consumerLoader,
- BundleContext consumerContext,
- Class[] interfaces,
- EndpointDescription endpoint) throws IntentUnsatisfiedException {
- Class<?> iClass = interfaces[0];
- Map<String, Object> sd = endpoint.getProperties();
- String address = getClientAddress(sd);
- if (address == null) {
- LOG.warn("Remote address is unavailable");
- // TODO: fire Event
- return null;
- }
-
- LOG.info("Creating a " + iClass.getName() + " client, endpoint address is " + address);
-
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- ClientProxyFactoryBean factory = createClientProxyFactoryBean(sd, iClass);
- factory.getServiceFactory().setDataBinding(getDataBinding(sd, iClass));
- factory.setServiceClass(iClass);
- factory.setAddress(address);
- addWsInterceptorsFeaturesProps(factory.getClientFactoryBean(), consumerContext, sd);
- WsdlSupport.setWsdlProperties(factory.getClientFactoryBean(), bundleContext, sd, false);
-
- intentManager.applyIntents(factory.getFeatures(), factory.getClientFactoryBean(), sd);
-
- Thread.currentThread().setContextClassLoader(ClientProxyFactoryBean.class.getClassLoader());
- return ProxyFactory.create(factory.create(), iClass);
- } catch (Exception e) {
- LOG.warn("proxy creation failed", e);
- } finally {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
- return null;
- }
-
- @SuppressWarnings("rawtypes")
- public Endpoint exportService(Object serviceO,
- BundleContext serviceContext,
- Map<String, Object> endpointProps,
- Class[] exportedInterfaces) throws IntentUnsatisfiedException {
- Class<?> iClass = exportedInterfaces[0];
- String address = getPojoAddress(endpointProps, iClass);
- ServerFactoryBean factory = createServerFactoryBean(endpointProps, iClass);
- factory.setDataBinding(getDataBinding(endpointProps, iClass));
- String contextRoot = getServletContextRoot(endpointProps);
-
- final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
- Bus bus = createBus(sid, serviceContext, contextRoot);
- factory.setBus(bus);
- factory.setServiceClass(iClass);
- factory.setAddress(address);
-
- factory.setServiceBean(serviceO);
- addWsInterceptorsFeaturesProps(factory, serviceContext, endpointProps);
- WsdlSupport.setWsdlProperties(factory, serviceContext, endpointProps, false);
- String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, endpointProps);
-
- String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
- EndpointDescription epd = createEndpointDesc(endpointProps,
- new String[]{Constants.WS_CONFIG_TYPE},
- completeEndpointAddress, intents);
- return createServerFromFactory(factory, epd);
- }
-
- private String getPojoAddress(Map<String, Object> sd, Class<?> iClass) {
- String address = getClientAddress(sd);
- if (address != null) {
- return address;
- }
-
- // If the property is not of type string this will cause an ClassCastException which
- // will be propagated to the ExportRegistration exception property.
- Object port = sd.get(Constants.WS_PORT_PROPERTY);
- if (port == null) {
- port = "9000";
- }
-
- address = "http://localhost:" + port + "/" + iClass.getName().replace('.', '/');
- LOG.info("Using a default address: " + address);
- return address;
- }
-
- private DataBinding getDataBinding(Map<String, Object> sd, Class<?> iClass) {
- Object dataBindingBeanProp = sd.get(Constants.WS_DATABINDING_BEAN_PROP_KEY);
- if (dataBindingBeanProp instanceof DataBinding) {
- return (DataBinding)dataBindingBeanProp;
- }
- return isJAXB(sd, iClass) ? new JAXBDataBinding() : new AegisDatabinding();
- }
-
- private boolean isJAXB(Map<String, Object> sd, Class<?> iClass) {
- String dataBindingName = (String)sd.get(Constants.WS_DATABINDING_PROP_KEY);
- return (iClass.getAnnotation(WebService.class) != null
- || Constants.WS_DATA_BINDING_JAXB.equals(dataBindingName))
- && !Constants.WS_DATA_BINDING_AEGIS.equals(dataBindingName);
- }
-
- // Isolated so that it can be substituted for testing
- protected ClientProxyFactoryBean createClientProxyFactoryBean(Map<String, Object> sd, Class<?> iClass) {
- return isJAXWS(sd, iClass) ? new JaxWsProxyFactoryBean() : new ClientProxyFactoryBean();
- }
-
- // Isolated so that it can be substituted for testing
- protected ServerFactoryBean createServerFactoryBean(Map<String, Object> sd, Class<?> iClass) {
- return isJAXWS(sd, iClass) ? new JaxWsServerFactoryBean() : new ServerFactoryBean();
- }
-
- private boolean isJAXWS(Map<String, Object> sd, Class<?> iClass) {
- String frontEnd = (String)sd.get(Constants.WS_FRONTEND_PROP_KEY);
- return (iClass.getAnnotation(WebService.class) != null
- || Constants.WS_FRONTEND_JAXWS.equals(frontEnd))
- && !Constants.WS_FRONTEND_SIMPLE.equals(frontEnd);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlConfigurationTypeHandler.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlConfigurationTypeHandler.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlConfigurationTypeHandler.java
deleted file mode 100644
index d3bca3e..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlConfigurationTypeHandler.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.pojo;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-
-import org.apache.aries.rsa.spi.Endpoint;
-import org.apache.cxf.Bus;
-import org.apache.cxf.common.util.PackageUtils;
-import org.apache.cxf.databinding.DataBinding;
-import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
-import org.apache.cxf.dosgi.common.intent.IntentManager;
-import org.apache.cxf.dosgi.common.proxy.ProxyFactory;
-import org.apache.cxf.dosgi.common.util.OsgiUtils;
-import org.apache.cxf.dosgi.dsw.osgi.Constants;
-import org.apache.cxf.jaxb.JAXBDataBinding;
-import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.remoteserviceadmin.EndpointDescription;
-import org.osgi.service.remoteserviceadmin.RemoteConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class WsdlConfigurationTypeHandler extends AbstractPojoConfigurationTypeHandler {
-
- private static final Logger LOG = LoggerFactory.getLogger(WsdlConfigurationTypeHandler.class);
-
- public WsdlConfigurationTypeHandler(BundleContext dswBC,
- IntentManager intentManager,
- HttpServiceManager httpServiceManager) {
- super(dswBC, intentManager, httpServiceManager);
- }
-
- public String[] getSupportedTypes() {
- return new String[] {Constants.WSDL_CONFIG_TYPE};
- }
-
- @SuppressWarnings("rawtypes")
- public Object importEndpoint(ClassLoader consumerLoader,
- BundleContext consumerContext,
- Class[] interfaces,
- EndpointDescription endpoint) {
- Class<?> iClass = interfaces[0];
- String wsdlAddressProp = getWsdlAddress(endpoint, iClass);
- if (wsdlAddressProp == null) {
- LOG.warn("WSDL address is unavailable");
- return null;
- }
-
- URL wsdlAddress;
- try {
- wsdlAddress = new URL(wsdlAddressProp);
- } catch (MalformedURLException ex) {
- LOG.warn("WSDL address is malformed");
- return null;
- }
-
- LOG.info("Creating a " + endpoint.getInterfaces().toArray()[0] + " client, wsdl address is "
- + OsgiUtils.getProperty(endpoint, Constants.WSDL_CONFIG_PREFIX));
-
- String serviceNs = OsgiUtils.getProperty(endpoint, Constants.WSDL_SERVICE_NAMESPACE);
- if (serviceNs == null) {
- serviceNs = PackageUtils.getNamespace(PackageUtils.getPackageName(iClass));
- }
- String serviceName = OsgiUtils.getProperty(endpoint, Constants.WSDL_SERVICE_NAME);
- if (serviceName == null) {
- serviceName = iClass.getSimpleName();
- }
- QName serviceQname = WsdlSupport.getServiceQName(iClass, endpoint.getProperties(),
- Constants.WSDL_SERVICE_NAMESPACE,
- Constants.WSDL_SERVICE_NAME);
- QName portQname = WsdlSupport.getPortQName(serviceQname.getNamespaceURI(),
- endpoint.getProperties(), Constants.WSDL_PORT_NAME);
- Service service = createWebService(wsdlAddress, serviceQname);
- Object port = portQname == null ? service.getPort(iClass) : service.getPort(portQname, iClass);
- Object proxy = ProxyFactory.create(port, iClass);
- // MARC: FIXME!!!! getDistributionProvider().addRemoteService(serviceReference);
- return proxy;
- }
-
- // Isolated so that it can be overridden for test purposes.
- Service createWebService(URL wsdlAddress, QName serviceQname) {
- return Service.create(wsdlAddress, serviceQname);
- }
-
- @SuppressWarnings("rawtypes")
- public Endpoint exportService(Object serviceO,
- BundleContext serviceContext,
- Map<String, Object> sd,
- Class[] exportedInterfaces) {
- Class<?> iClass = exportedInterfaces[0];
- String location = OsgiUtils.getProperty(sd, Constants.WSDL_LOCATION);
- if (location == null) {
- throw new RuntimeException("WSDL location property is unavailable");
- }
- URL wsdlURL = serviceContext.getBundle().getResource(location);
- if (wsdlURL == null) {
- throw new RuntimeException("WSDL resource at " + location + " is unavailable");
- }
-
- String address = getServerAddress(sd, iClass);
- String contextRoot = getServletContextRoot(sd);
- if (address == null && contextRoot == null) {
- throw new RuntimeException("Remote address is unavailable");
- }
-
- LOG.info("Creating a " + iClass.getName() + " endpoint from CXF PublishHook, address is " + address);
-
- DataBinding databinding = new JAXBDataBinding();
- JaxWsServerFactoryBean factory = new JaxWsServerFactoryBean();
- final Long sid = (Long) sd.get(RemoteConstants.ENDPOINT_SERVICE_ID);
- Bus bus = createBus(sid, serviceContext, contextRoot);
- factory.setBus(bus);
- factory.setServiceClass(iClass);
- factory.setAddress(address != null ? address : "/");
- factory.getServiceFactory().setDataBinding(databinding);
- factory.setServiceBean(serviceO);
-
- addWsInterceptorsFeaturesProps(factory, serviceContext, sd);
-
- WsdlSupport.setWsdlProperties(factory, serviceContext, sd, true);
-
- String[] intents = intentManager.applyIntents(factory.getFeatures(), factory, sd);
-
- EndpointDescription epd = createEndpointDesc(sd,
- new String[]{Constants.WS_CONFIG_TYPE},
- address, intents);
- return createServerFromFactory(factory, epd);
- }
-
- private String getWsdlAddress(EndpointDescription endpoint, Class<?> iClass) {
- String address = OsgiUtils.getProperty(endpoint, Constants.WSDL_CONFIG_PREFIX);
- if (address == null) {
- address = httpServiceManager.getDefaultAddress(iClass);
- if (address != null) {
- address += "?wsdl";
- }
- }
- return address;
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/f0dea506/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlSupport.java
----------------------------------------------------------------------
diff --git a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlSupport.java b/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlSupport.java
deleted file mode 100644
index 2118b33..0000000
--- a/cxf-dsw/src/main/java/org/apache/cxf/dosgi/dsw/handlers/pojo/WsdlSupport.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.dosgi.dsw.handlers.pojo;
-
-import java.net.URL;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.apache.cxf.common.util.PackageUtils;
-import org.apache.cxf.dosgi.common.util.OsgiUtils;
-import org.apache.cxf.dosgi.dsw.osgi.Constants;
-import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
-import org.osgi.framework.BundleContext;
-
-public final class WsdlSupport {
-
- private WsdlSupport() {
- }
-
- public static void setWsdlProperties(AbstractWSDLBasedEndpointFactory factory, BundleContext context,
- Map<String, Object> sd,
- boolean wsdlType) {
- String location = OsgiUtils.getProperty(sd, wsdlType ? Constants.WSDL_LOCATION : Constants.WS_WSDL_LOCATION);
- if (location != null) {
- URL wsdlURL = context.getBundle().getResource(location);
- if (wsdlURL != null) {
- factory.setWsdlURL(wsdlURL.toString());
- }
- QName serviceName = getServiceQName(null, sd,
- wsdlType ? Constants.WSDL_SERVICE_NAMESPACE : Constants.WS_WSDL_SERVICE_NAMESPACE,
- wsdlType ? Constants.WSDL_SERVICE_NAME : Constants.WS_WSDL_SERVICE_NAME);
- if (serviceName != null) {
- factory.setServiceName(serviceName);
- QName portName = getPortQName(serviceName.getNamespaceURI(), sd,
- wsdlType ? Constants.WSDL_PORT_NAME : Constants.WS_WSDL_PORT_NAME);
- if (portName != null) {
- factory.setEndpointName(portName);
- }
- }
- }
- }
-
- protected static QName getServiceQName(Class<?> iClass, Map<String, Object> sd, String nsPropName,
- String namePropName) {
- String serviceNs = OsgiUtils.getProperty(sd, nsPropName);
- String serviceName = OsgiUtils.getProperty(sd, namePropName);
- if (iClass == null && (serviceNs == null || serviceName == null)) {
- return null;
- }
- if (serviceNs == null) {
- serviceNs = PackageUtils.getNamespace(PackageUtils.getPackageName(iClass));
- }
- if (serviceName == null) {
- serviceName = iClass.getSimpleName();
- }
- return new QName(serviceNs, serviceName);
- }
-
- protected static QName getPortQName(String ns, Map<String, Object> sd, String propName) {
- String portName = OsgiUtils.getProperty(sd, propName);
- if (portName == null) {
- return null;
- }
- return new QName(ns, portName);
- }
-}