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 2017/04/10 10:21:34 UTC
cxf-dosgi git commit: [DOSGI-262] Adding IntentsProvider interface
for inline creation of intents
Repository: cxf-dosgi
Updated Branches:
refs/heads/master ce82b08e8 -> 29ba65206
[DOSGI-262] Adding IntentsProvider interface for inline creation of intents
Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/29ba6520
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/29ba6520
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/29ba6520
Branch: refs/heads/master
Commit: 29ba65206423796312a9da0dd6344296ab6390d5
Parents: ce82b08
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Mon Apr 10 12:17:17 2017 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Mon Apr 10 12:21:19 2017 +0200
----------------------------------------------------------------------
.../cxf/dosgi/common/api/IntentsProvider.java | 28 ++++++++++++++++++++
.../org/apache/cxf/dosgi/common/api/packageinfo | 19 +++++++++++++
.../cxf/dosgi/common/intent/IntentManager.java | 1 +
.../common/intent/impl/IntentManagerImpl.java | 9 +++++++
.../cxf/dosgi/dsw/handlers/rest/RsProvider.java | 2 ++
.../cxf/dosgi/dsw/handlers/ws/WsProvider.java | 6 +++++
.../ws/PojoConfigurationTypeHandlerTest.java | 15 +++++++----
7 files changed, 75 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/29ba6520/common/src/main/java/org/apache/cxf/dosgi/common/api/IntentsProvider.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/api/IntentsProvider.java b/common/src/main/java/org/apache/cxf/dosgi/common/api/IntentsProvider.java
new file mode 100644
index 0000000..3fe1226
--- /dev/null
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/api/IntentsProvider.java
@@ -0,0 +1,28 @@
+/**
+ * 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.api;
+
+import java.util.List;
+
+/**
+ * Returns a list of CXF extension objects that can define the same things a intents
+ */
+public interface IntentsProvider {
+ List<?> getIntents();
+}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/29ba6520/common/src/main/java/org/apache/cxf/dosgi/common/api/packageinfo
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/api/packageinfo b/common/src/main/java/org/apache/cxf/dosgi/common/api/packageinfo
new file mode 100644
index 0000000..c72722a
--- /dev/null
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/api/packageinfo
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+version 1.0.0
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/29ba6520/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 deeae0a..de7a5fa 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
@@ -36,4 +36,5 @@ public interface IntentManager {
<T> T getIntent(Class<? extends T> type, List<Object> intents);
+ List<Object> getIntentsFromService(Object serviceBean);
}
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/29ba6520/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java b/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
index 596f427..10e4a05 100644
--- a/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/intent/impl/IntentManagerImpl.java
@@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
+import org.apache.cxf.dosgi.common.api.IntentsProvider;
import org.apache.cxf.dosgi.common.intent.IntentManager;
import org.apache.cxf.dosgi.common.util.PropertyHelper;
import org.osgi.framework.BundleContext;
@@ -191,6 +192,14 @@ public class IntentManagerImpl implements IntentManager {
return allIntents;
}
+ public List<Object> getIntentsFromService(Object serviceBean) {
+ List<Object> intents = new ArrayList<>();
+ if (serviceBean instanceof IntentsProvider) {
+ intents.addAll(((IntentsProvider)serviceBean).getIntents());
+ }
+ return intents;
+ }
+
public Set<String> getImported(Map<String, Object> sd) {
Collection<String> intents = PropertyHelper.getMultiValueProperty(sd.get(RemoteConstants.SERVICE_INTENTS));
return new HashSet<String>(intents);
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/29ba6520/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
----------------------------------------------------------------------
diff --git a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
index 4f32c5a..1ba2dde 100644
--- a/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
+++ b/provider-rs/src/main/java/org/apache/cxf/dosgi/dsw/handlers/rest/RsProvider.java
@@ -134,6 +134,8 @@ public class RsProvider extends BaseDistributionProvider implements Distribution
final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
Set<String> intentNames = intentManager.getExported(endpointProps);
List<Object> intents = intentManager.getRequiredIntents(intentNames);
+ intents.addAll(intentManager.getIntentsFromService(serviceBean));
+
Bus bus = createBus(sid, callingContext, contextRoot, endpointProps);
LOG.info("Creating JAXRS endpoint for " + iClass.getName() + " with address " + address);
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/29ba6520/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
index 99e64d4..0c953c4 100644
--- a/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
+++ b/provider-ws/src/main/java/org/apache/cxf/dosgi/dsw/handlers/ws/WsProvider.java
@@ -36,6 +36,7 @@ import org.apache.cxf.aegis.databinding.AegisDatabinding;
import org.apache.cxf.binding.BindingConfiguration;
import org.apache.cxf.binding.soap.SoapBindingConfiguration;
import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.dosgi.common.api.IntentsProvider;
import org.apache.cxf.dosgi.common.endpoint.ServerEndpoint;
import org.apache.cxf.dosgi.common.handlers.BaseDistributionProvider;
import org.apache.cxf.dosgi.common.httpservice.HttpServiceManager;
@@ -119,6 +120,7 @@ public class WsProvider extends BaseDistributionProvider implements Distribution
private void applyIntents(Map<String, Object> sd, ClientProxyFactoryBean factory) {
Set<String> intentNames = intentManager.getImported(sd);
List<Object> intents = intentManager.getRequiredIntents(intentNames);
+
List<Feature> features = intentManager.getIntents(Feature.class, intents);
factory.setFeatures(features);
DataBinding dataBinding = intentManager.getIntent(DataBinding.class, intents);
@@ -167,6 +169,7 @@ public class WsProvider extends BaseDistributionProvider implements Distribution
final Long sid = (Long) endpointProps.get(RemoteConstants.ENDPOINT_SERVICE_ID);
Set<String> intentNames = intentManager.getExported(endpointProps);
List<Object> intents = intentManager.getRequiredIntents(intentNames);
+ intents.addAll(intentManager.getIntentsFromService(serviceO));
Bus bus = createBus(sid, serviceContext, contextRoot, endpointProps);
factory.setDataBinding(getDataBinding(endpointProps, iClass));
factory.setBindingConfig(new SoapBindingConfiguration());
@@ -176,6 +179,9 @@ public class WsProvider extends BaseDistributionProvider implements Distribution
factory.setAddress(address);
addContextProperties(factory, endpointProps, WsConstants.WS_CONTEXT_PROPS_PROP_KEY);
WsdlSupport.setWsdlProperties(factory, serviceContext, endpointProps);
+ if (serviceO instanceof IntentsProvider) {
+ intents.addAll(((IntentsProvider)serviceO).getIntents());
+ }
applyIntents(intents, factory);
String completeEndpointAddress = httpServiceManager.getAbsoluteAddress(contextRoot, address);
http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/29ba6520/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ws/PojoConfigurationTypeHandlerTest.java
----------------------------------------------------------------------
diff --git a/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ws/PojoConfigurationTypeHandlerTest.java b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ws/PojoConfigurationTypeHandlerTest.java
index acbb992..46859ba 100644
--- a/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ws/PojoConfigurationTypeHandlerTest.java
+++ b/provider-ws/src/test/java/org/apache/cxf/dosgi/dsw/handlers/ws/PojoConfigurationTypeHandlerTest.java
@@ -34,6 +34,7 @@ import org.apache.cxf.dosgi.common.intent.IntentManager;
import org.apache.cxf.dosgi.common.intent.impl.IntentManagerImpl;
import org.apache.cxf.dosgi.dsw.handlers.jaxws.MyJaxWsEchoService;
import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoService;
+import org.apache.cxf.dosgi.dsw.handlers.simple.MySimpleEchoServiceImpl;
import org.apache.cxf.endpoint.EndpointImpl;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.frontend.ClientFactoryBean;
@@ -200,8 +201,7 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
.andReturn(expectedUUID);
EasyMock.replay(dswContext);
- IntentManager intentManager = EasyMock.createNiceMock(IntentManager.class);
- EasyMock.replay(intentManager);
+ IntentManager intentManager = new IntentManagerImpl();
WsProvider handler = new WsProvider() {
@Override
@@ -212,8 +212,12 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
handler.setIntentManager(intentManager);
handler.setHttpServiceManager(dummyHttpServiceManager());
handler.activate(dswContext);
- Runnable myService = EasyMock.createMock(Runnable.class);
- EasyMock.replay(myService);
+ Runnable myService = new Runnable() {
+
+ @Override
+ public void run() {
+ }
+ };
BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
EasyMock.replay(bundleContext);
@@ -378,7 +382,8 @@ public class PojoConfigurationTypeHandlerTest extends TestCase {
BundleContext serviceBC = c.createMock(BundleContext.class);
c.replay();
Class<?>[] ifaces = new Class[] {MySimpleEchoService.class};
- ServerEndpoint serverWrapper = (ServerEndpoint)handler.exportService(null, serviceBC, sd, ifaces);
+ MySimpleEchoServiceImpl service = new MySimpleEchoServiceImpl();
+ ServerEndpoint serverWrapper = (ServerEndpoint)handler.exportService(service, serviceBC, sd, ifaces);
c.verify();
org.apache.cxf.endpoint.Endpoint ep = serverWrapper.getServer().getEndpoint();