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:14 UTC
[3/3] cxf-dosgi git commit: [DOSGI-245] Split cxf provider into rs
and ws provider
[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);
- }
-}