Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5DE7C10B7B for ; Fri, 5 Dec 2014 09:26:52 +0000 (UTC) Received: (qmail 58781 invoked by uid 500); 5 Dec 2014 09:26:52 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 58721 invoked by uid 500); 5 Dec 2014 09:26:52 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 58712 invoked by uid 99); 5 Dec 2014 09:26:52 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2014 09:26:52 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 847648BD414; Fri, 5 Dec 2014 09:26:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: cschneider@apache.org To: commits@cxf.apache.org Message-Id: <69322ca5d81c45ccb8a5e1e7da660322@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: CXF-6135 Do not directly depend in http feature. Make servlet API non optional and deploy by default Date: Fri, 5 Dec 2014 09:26:51 +0000 (UTC) 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 Authored: Fri Dec 5 10:26:43 2014 +0100 Committer: Christian Schneider 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 @@ cxf-core - http + mvn:${cxf.servlet-api.group}/${cxf.servlet-api.artifact}/${cxf.servlet-api.version} mvn:org.apache.cxf/cxf-rt-transports-http/${project.version} 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 @@ ${cxf.servlet-api.group} ${cxf.servlet-api.artifact} provided - true org.apache.aries.blueprint 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