cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject cxf-dosgi git commit: [DOSGI-251] Allow to export services with less service properties
Date Mon, 07 Nov 2016 15:25:23 GMT
Repository: cxf-dosgi
Updated Branches:
  refs/heads/master 27ef4cb55 -> 0a4950cfe


[DOSGI-251] Allow to export services with less service properties


Project: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/commit/0a4950cf
Tree: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/tree/0a4950cf
Diff: http://git-wip-us.apache.org/repos/asf/cxf-dosgi/diff/0a4950cf

Branch: refs/heads/master
Commit: 0a4950cfe9e8a29cb25ce209b7a770eba1f826dc
Parents: 27ef4cb
Author: Christian Schneider <chris@die-schneider.net>
Authored: Mon Nov 7 16:25:10 2016 +0100
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Mon Nov 7 16:25:10 2016 +0100

----------------------------------------------------------------------
 .../cxf/dosgi/common/policy/Exporter.java       | 58 +++++++++++++++++++
 .../dosgi/itests/multi/AbstractDosgiTest.java   |  1 +
 .../dosgi/itests/multi/TestExportPolicy.java    | 61 ++++++++++++++++++++
 samples/rest/impl/pom.xml                       |  6 ++
 samples/soap/soap.bndrun                        | 21 ++++---
 5 files changed, 140 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0a4950cf/common/src/main/java/org/apache/cxf/dosgi/common/policy/Exporter.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/cxf/dosgi/common/policy/Exporter.java b/common/src/main/java/org/apache/cxf/dosgi/common/policy/Exporter.java
new file mode 100644
index 0000000..bf2578c
--- /dev/null
+++ b/common/src/main/java/org/apache/cxf/dosgi/common/policy/Exporter.java
@@ -0,0 +1,58 @@
+/**
+ * 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.policy;
+
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS;
+import static org.osgi.service.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_INTERFACES;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.rsa.spi.ExportPolicy;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.annotations.Component;
+
+@Component //
+(//
+    immediate = true, //
+    property = "name=cxf" //
+)
+public class Exporter implements ExportPolicy {
+
+    @Override
+    public Map<String, String> additionalParameters(ServiceReference<?> sref)
{
+        Map<String, String> params = new HashMap<>();
+        if (sref.getProperty("org.apache.cxf.rs.address") != null) {
+            setDefault(sref, params, SERVICE_EXPORTED_INTERFACES, "*");
+            setDefault(sref, params, SERVICE_EXPORTED_CONFIGS, "org.apache.cxf.rs");
+        }
+        if (sref.getProperty("org.apache.cxf.ws.address") != null) {
+            setDefault(sref, params, SERVICE_EXPORTED_INTERFACES, "*");
+            setDefault(sref, params, SERVICE_EXPORTED_CONFIGS, "org.apache.cxf.ws");
+        }
+        return params;
+    }
+
+    private void setDefault(ServiceReference<?> sref, Map<String, String> params,
String key, String value) {
+        if (sref.getProperty(key) == null) {
+            params.put(key, value);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0a4950cf/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java
----------------------------------------------------------------------
diff --git a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java
b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java
index 16264bd..0887cb6 100644
--- a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java
+++ b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/AbstractDosgiTest.java
@@ -289,6 +289,7 @@ public class AbstractDosgiTest {
                          systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
//
                          systemProperty("pax.exam.osgi.unresolved.fail").value("true"), //
                          systemProperty("org.apache.cxf.stax.allowInsecureParser").value("true"),
//
+                         systemProperty("rsa.export.policy.filter").value("(name=cxf)"),
//
                          configLogging(),
                          frameworkStartLevel(100)
         );

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0a4950cf/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestExportPolicy.java
----------------------------------------------------------------------
diff --git a/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestExportPolicy.java
b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestExportPolicy.java
new file mode 100644
index 0000000..8f4f136
--- /dev/null
+++ b/itests/multi-bundle/src/test/java/org/apache/cxf/dosgi/itests/multi/TestExportPolicy.java
@@ -0,0 +1,61 @@
+/**
+ * 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.itests.multi;
+
+import javax.inject.Inject;
+
+import org.apache.aries.rsa.spi.ExportPolicy;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.util.Filter;
+
+/**
+ * Deploys the sample SOAP service and zookeeper discovery.
+ * Then checks the service can be called via plain CXF and is announced in zookeeper
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class TestExportPolicy extends AbstractDosgiTest {
+    
+    @Inject
+    @Filter("(name=cxf)")
+    ExportPolicy policy;
+    
+    @Configuration
+    public static Option[] configure() throws Exception {
+        return new Option[] //
+        {//
+         basicTestOptions(), //
+         //debug(),
+        };
+    }
+
+    @Test
+    public void testPolicyPresent() throws Exception {
+        Assert.assertNotNull(policy);
+    }
+    
+
+}

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0a4950cf/samples/rest/impl/pom.xml
----------------------------------------------------------------------
diff --git a/samples/rest/impl/pom.xml b/samples/rest/impl/pom.xml
index 250cfa5..1d586d7 100644
--- a/samples/rest/impl/pom.xml
+++ b/samples/rest/impl/pom.xml
@@ -33,6 +33,12 @@
             <artifactId>cxf-dosgi-samples-rest-api</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+        	<groupId>org.apache.aries.rsa</groupId>
+        	<artifactId>org.apache.aries.rsa.spi</artifactId>
+        	<version>1.9.0</version>
+        	<type>bundle</type>
+        </dependency>
     </dependencies>
 
 </project>

http://git-wip-us.apache.org/repos/asf/cxf-dosgi/blob/0a4950cf/samples/soap/soap.bndrun
----------------------------------------------------------------------
diff --git a/samples/soap/soap.bndrun b/samples/soap/soap.bndrun
index 75acd17..5ef5063 100644
--- a/samples/soap/soap.bndrun
+++ b/samples/soap/soap.bndrun
@@ -9,6 +9,7 @@
 
 -runproperties: \
 	org.ops4j.pax.logging.DefaultServiceLog.level=INFO,\
+	rsa.export.policy.filter="(name=rest)",\
 	org.apache.felix.http.jettyEnabled=true,\
 	org.osgi.framework.bootdelegation=com.sun.*,\
 	org.osgi.framework.system.packages.extra='sun.misc,javax.xml.bind.annotation;version=2.2.1,javax.xml.bind;version=2.2.1'
@@ -31,15 +32,14 @@
 	osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
 	osgi.identity;filter:='(osgi.identity=org.ops4j.pax.logging.pax-logging-service)',\
 	osgi.identity;filter:='(osgi.identity=org.objectweb.asm.all)',\
-	osgi.identity;filter:='(osgi.identity=org.apache.cxf.dosgi.samples.cxf-dosgi-samples-soap-impl)',\
 	osgi.identity;filter:='(osgi.identity=org.apache.felix.http.jetty)',\
 	osgi.identity;filter:='(osgi.identity=org.apache.cxf.dosgi.cxf-dosgi-provider-ws)',\
 	osgi.identity;filter:='(osgi.identity=org.apache.aries.rsa.topology-manager)',\
 	osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
-	osgi.identity;filter:='(osgi.identity=org.apache.aries.rsa.discovery.command)'
+	osgi.identity;filter:='(&(osgi.identity=org.apache.aries.rsa.discovery.command)(version>=1.9.0))',\
+	osgi.identity;filter:='(osgi.identity=org.apache.cxf.dosgi.samples.cxf-dosgi-samples-rest-impl)',\
+	osgi.identity;filter:='(osgi.identity=org.apache.cxf.dosgi.cxf-dosgi-provider-rs)'
 -runbundles: \
-	org.apache.cxf.dosgi.samples.cxf-dosgi-samples-soap-api;version='[2.0.0,2.0.1)',\
-	org.apache.cxf.dosgi.samples.cxf-dosgi-samples-soap-impl;version='[2.0.0,2.0.1)',\
 	org.apache.felix.configadmin;version='[1.8.8,1.8.9)',\
 	org.apache.felix.fileinstall;version='[3.5.2,3.5.3)',\
 	org.objectweb.asm.all;version='[5.0.4,5.0.5)',\
@@ -58,8 +58,6 @@
 	org.apache.cxf.cxf-rt-frontend-simple;version='[3.1.7,3.1.8)',\
 	org.apache.cxf.cxf-rt-transports-http;version='[3.1.7,3.1.8)',\
 	org.apache.cxf.cxf-rt-wsdl;version='[3.1.7,3.1.8)',\
-	org.apache.cxf.dosgi.cxf-dosgi-common;version='[2.0.0,2.0.1)',\
-	org.apache.cxf.dosgi.cxf-dosgi-provider-ws;version='[2.0.0,2.0.1)',\
 	org.apache.servicemix.bundles.wsdl4j;version='[1.6.3,1.6.4)',\
 	org.apache.ws.xmlschema.core;version='[2.2.1,2.2.2)',\
 	org.apache.aries.rsa.core;version='[1.9.0,1.9.1)',\
@@ -70,4 +68,13 @@
 	org.apache.felix.scr;version='[2.0.4,2.0.5)',\
 	org.apache.felix.gogo.runtime;version='[0.10.0,0.10.1)',\
 	org.apache.aries.rsa.discovery.command;version='[1.9.0,1.9.1)',\
-	org.fusesource.jansi;version='[1.13.0,1.13.1)'
\ No newline at end of file
+	org.fusesource.jansi;version='[1.13.0,1.13.1)',\
+	javax.annotation-api;version='[1.2.0,1.2.1)',\
+	org.apache.servicemix.specs.jsr339-api-2.0.1;version='[2.6.0,2.6.1)',\
+	org.apache.cxf.cxf-rt-frontend-jaxrs;version='[3.1.7,3.1.8)',\
+	org.apache.cxf.cxf-rt-rs-client;version='[3.1.7,3.1.8)',\
+	org.apache.cxf.dosgi.cxf-dosgi-common;version='[2.1.0,2.1.1)',\
+	org.apache.cxf.dosgi.cxf-dosgi-provider-rs;version='[2.1.0,2.1.1)',\
+	org.apache.cxf.dosgi.cxf-dosgi-provider-ws;version='[2.1.0,2.1.1)',\
+	org.apache.cxf.dosgi.samples.cxf-dosgi-samples-rest-api;version='[2.1.0,2.1.1)',\
+	org.apache.cxf.dosgi.samples.cxf-dosgi-samples-rest-impl;version='[2.1.0,2.1.1)'
\ No newline at end of file


Mime
View raw message