[DOSGI-251] Allow to export services with less service properties
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);
+        }
+    }
+
+}
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 @@
                          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)
         );
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);
+    }
+    
+
+}
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>
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