Repository: cxf
Updated Branches:
  refs/heads/master 716f3a148 -> 71ced4709


CXF-6135 Do not directly depend in http feature. Make servlet API non optional 
and deploy by default


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

Branch: refs/heads/master
Commit: 71ced4709dedf62264a4bb630aaf4780cb94ce48
Parents: 716f3a1
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Fri Dec 5 10:26:43 2014 +0100
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Fri Dec 5 10:26:43 2014 +0100

----------------------------------------------------------------------
 .../features/src/main/resources/features.xml    |  2 +-
 rt/transports/http/pom.xml                      |  1 -
 .../http/osgi/HTTPTransportActivator.java       | 44 ++----------
 .../http/osgi/HttpServiceTrackerCust.java       | 73 ++++++++++++++++++++
 4 files changed, 79 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/71ced470/osgi/karaf/features/src/main/resources/features.xml
----------------------------------------------------------------------
diff --git a/osgi/karaf/features/src/main/resources/features.xml 
b/osgi/karaf/features/src/main/resources/features.xml
index 7174b36..8724f17 100644
--- a/osgi/karaf/features/src/main/resources/features.xml
+++ b/osgi/karaf/features/src/main/resources/features.xml
@@ -128,7 +128,7 @@
     </feature>
     <feature name="cxf-http" version="${project.version}" resolver="(obr)">
         <feature version="${project.version}">cxf-core</feature>
-        <feature version="[2,5)">http</feature>
+        <bundle 
start-level="40">mvn:${cxf.servlet-api.group}/${cxf.servlet-api.artifact}/${cxf.servlet-api.version}</bundle>
         <bundle 
start-level="40">mvn:org.apache.cxf/cxf-rt-transports-http/${project.version}</bundle>
     </feature>
     <feature name="cxf-http-jetty" version="${project.version}" 
resolver="(obr)">

http://git-wip-us.apache.org/repos/asf/cxf/blob/71ced470/rt/transports/http/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http/pom.xml b/rt/transports/http/pom.xml
index 56f68b0..4f3cfde 100644
--- a/rt/transports/http/pom.xml
+++ b/rt/transports/http/pom.xml
@@ -101,7 +101,6 @@
             <groupId>${cxf.servlet-api.group}</groupId>
             <artifactId>${cxf.servlet-api.artifact}</artifactId>
             <scope>provided</scope>
-            <optional>true</optional>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.blueprint</groupId>

http://git-wip-us.apache.org/repos/asf/cxf/blob/71ced470/rt/transports/http/src/main/java/org/apache/cxf/transport/http/osgi/HTTPTransportActivator.java
----------------------------------------------------------------------
diff --git 
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/osgi/HTTPTransportActivator.java
 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/osgi/HTTPTransportActivator.java
index 7116759..6060b6a 100644
--- 
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/osgi/HTTPTransportActivator.java
+++ 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/osgi/HTTPTransportActivator.java
@@ -21,8 +21,6 @@ package org.apache.cxf.transport.http.osgi;
 
 import java.util.Properties;
 
-import javax.servlet.Servlet;
-
 import org.apache.cxf.bus.blueprint.BlueprintNameSpaceHandlerFactory;
 import org.apache.cxf.bus.blueprint.NamespaceHandlerRegisterer;
 import org.apache.cxf.common.util.PropertyUtils;
@@ -31,23 +29,16 @@ import 
org.apache.cxf.transport.http.DestinationRegistryImpl;
 import org.apache.cxf.transport.http.HTTPConduitConfigurer;
 import org.apache.cxf.transport.http.HTTPTransportFactory;
 import org.apache.cxf.transport.http.blueprint.HttpBPHandler;
-import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
 import org.osgi.service.cm.ManagedServiceFactory;
 import org.osgi.service.http.HttpService;
 import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
-public class HTTPTransportActivator 
-    implements BundleActivator {
-    private static final String CXF_CONFIG_PID = "org.apache.cxf.osgi";
-    private static final String DISABLE_DEFAULT_HTTP_TRANSPORT = 
CXF_CONFIG_PID + ".http.transport.disable";
+public class HTTPTransportActivator implements BundleActivator {
+    private static final String DISABLE_DEFAULT_HTTP_TRANSPORT = 
"org.apache.cxf.osgi.http.transport.disable";
     private ServiceTracker httpServiceTracker;
     
     public void start(final BundleContext context) throws Exception {
@@ -67,34 +58,9 @@ public class HTTPTransportActivator
         
         DestinationRegistry destinationRegistry = new 
DestinationRegistryImpl();
         HTTPTransportFactory transportFactory = new 
HTTPTransportFactory(destinationRegistry);
-        final Servlet servlet = new CXFNonSpringServlet(destinationRegistry , 
false);
-        httpServiceTracker = new ServiceTracker(context, 
HttpService.class.getName(), new ServiceTrackerCustomizer() {
-            
-            private ServiceRegistration servletPublisherReg;
-            private ServletExporter servletExporter;
-
-            @Override
-            public void removedService(ServiceReference reference, Object 
service) {
-                servletPublisherReg.unregister();
-                try {
-                    servletExporter.updated(null);
-                } catch (ConfigurationException e) {
-                    // Ignore
-                }
-            }
-            
-            @Override
-            public void modifiedService(ServiceReference reference, Object 
service) {
-            }
-            
-            @Override
-            public Object addingService(ServiceReference reference) {
-                HttpService httpService = 
(HttpService)context.getService(reference);
-                servletExporter = new ServletExporter(servlet, httpService);
-                servletPublisherReg = registerService(context, 
ManagedService.class, servletExporter, CXF_CONFIG_PID);
-                return null;
-            }
-        });
+        
+        HttpServiceTrackerCust customizer = new 
HttpServiceTrackerCust(destinationRegistry, context);
+        httpServiceTracker = new ServiceTracker(context, 
HttpService.class.getName(), customizer);
         httpServiceTracker.open();
 
         context.registerService(DestinationRegistry.class.getName(), 
destinationRegistry, null);

http://git-wip-us.apache.org/repos/asf/cxf/blob/71ced470/rt/transports/http/src/main/java/org/apache/cxf/transport/http/osgi/HttpServiceTrackerCust.java
----------------------------------------------------------------------
diff --git 
a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/osgi/HttpServiceTrackerCust.java
 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/osgi/HttpServiceTrackerCust.java
new file mode 100644
index 0000000..b51a389
--- /dev/null
+++ 
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/osgi/HttpServiceTrackerCust.java
@@ -0,0 +1,73 @@
+/**
+ * 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.transport.http.osgi;
+
+import java.util.Properties;
+
+import javax.servlet.Servlet;
+
+import org.apache.cxf.transport.http.DestinationRegistry;
+import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.http.HttpService;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+final class HttpServiceTrackerCust implements ServiceTrackerCustomizer {
+    private static final String CXF_CONFIG_PID = "org.apache.cxf.osgi";
+    private final DestinationRegistry destinationRegistry;
+    private final BundleContext context;
+    private ServiceRegistration servletPublisherReg;
+    private ServletExporter servletExporter;
+
+    HttpServiceTrackerCust(DestinationRegistry destinationRegistry, 
BundleContext context) {
+        this.destinationRegistry = destinationRegistry;
+        this.context = context;
+    }
+
+    @Override
+    public void removedService(ServiceReference reference, Object service) {
+        servletPublisherReg.unregister();
+        try {
+            servletExporter.updated(null);
+        } catch (ConfigurationException e) {
+            // Ignore
+        }
+    }
+
+    @Override
+    public void modifiedService(ServiceReference reference, Object service) {
+    }
+
+    @Override
+    public Object addingService(ServiceReference reference) {
+        HttpService httpService = (HttpService)context.getService(reference);
+        Servlet servlet = new CXFNonSpringServlet(destinationRegistry , false);
+        servletExporter = new ServletExporter(servlet, httpService);
+        Properties servProps = new Properties();
+        servProps.put(Constants.SERVICE_PID,  CXF_CONFIG_PID);
+        servletPublisherReg = 
context.registerService(ManagedService.class.getName(),
+                                                      servletExporter, 
servProps);
+        return null;
+    }
+}
\ No newline at end of file

Reply via email to