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 + } +}
