You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2020/03/27 15:12:24 UTC
[camel] branch master updated: CAMEL-14804: camel-servlet-osgi -
Move osgi bits to camel-karaf
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new b953a01 CAMEL-14804: camel-servlet-osgi - Move osgi bits to camel-karaf
b953a01 is described below
commit b953a0109f57f332db46e9be1828125a680c3c85
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Mar 27 16:11:51 2020 +0100
CAMEL-14804: camel-servlet-osgi - Move osgi bits to camel-karaf
---
components/camel-servlet/pom.xml | 5 -
.../servlet/osgi/OsgiServletRegisterer.java | 111 ---------------------
.../component/servlet/osgiservletregisterer.xml | 2 +-
3 files changed, 1 insertion(+), 117 deletions(-)
diff --git a/components/camel-servlet/pom.xml b/components/camel-servlet/pom.xml
index e5f2daf..985c64b 100644
--- a/components/camel-servlet/pom.xml
+++ b/components/camel-servlet/pom.xml
@@ -64,11 +64,6 @@
<artifactId>camel-http-common</artifactId>
</dependency>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax-servlet-api-version}</version>
diff --git a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/osgi/OsgiServletRegisterer.java b/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/osgi/OsgiServletRegisterer.java
deleted file mode 100644
index 4323a70..0000000
--- a/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/osgi/OsgiServletRegisterer.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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.camel.component.servlet.osgi;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import javax.servlet.http.HttpServlet;
-
-import org.apache.camel.util.StringHelper;
-import org.osgi.service.http.HttpContext;
-import org.osgi.service.http.HttpService;
-
-/**
- * Register the given (CamelHttpTransport) Servlet with the OSGI
- * <a href="http://www.osgi.org/javadoc/r4v42/org/osgi/service/http/HttpService.html">
- * HttpService</a>
- *
- * See src/test/resources/osgiservletregisterer.xml
- */
-public class OsgiServletRegisterer {
-
- /**
- * The alias is the name in the URI namespace of the Http Service at which the registration will be mapped
- * An alias must begin with slash ('/') and must not end with slash ('/'), with the exception that an alias
- * of the form "/" is used to denote the root alias.
- */
- private String alias;
-
- /**
- * The servlet name.
- */
- private String servletName = "CamelServlet";
-
- /**
- * Servlet to be registered
- */
- private HttpServlet servlet;
-
- /**
- * HttpService to register with. Get this with osgi:reference in the blueprint file
- */
- private HttpService httpService;
-
- private HttpContext httpContext;
-
- private boolean alreadyRegistered;
-
- // The servlet will default have to match on uri prefix as some endpoints may do so
- private volatile boolean matchOnUriPrefix = true;
-
- public void setHttpService(HttpService httpService) {
- this.httpService = httpService;
- }
-
- public void setAlias(String alias) {
- this.alias = alias;
- }
-
- public void setServletName(String servletName) {
- this.servletName = servletName;
- }
-
- public void setServlet(HttpServlet servlet) {
- this.servlet = servlet;
- }
-
- public void setHttpContext(HttpContext httpContext) {
- this.httpContext = httpContext;
- }
-
- public void setMatchOnUriPrefix(boolean matchOnUriPrefix) {
- this.matchOnUriPrefix = matchOnUriPrefix;
- }
-
- public void register() throws Exception {
- StringHelper.notEmpty(alias, "alias", this);
- StringHelper.notEmpty(servletName, "servletName", this);
-
- HttpContext actualHttpContext = (httpContext == null)
- ? httpService.createDefaultHttpContext()
- : httpContext;
- final Dictionary<String, String> initParams = new Hashtable<>();
- initParams.put("matchOnUriPrefix", matchOnUriPrefix ? "true" : "false");
- initParams.put("servlet-name", servletName);
- httpService.registerServlet(alias, servlet, initParams, actualHttpContext);
- alreadyRegistered = true;
- }
-
- public void unregister() {
- if (alreadyRegistered) {
- httpService.unregister(alias);
- alreadyRegistered = false;
- }
- }
-
-}
diff --git a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/osgiservletregisterer.xml b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/osgiservletregisterer.xml
index b12c63d..f8836d6 100644
--- a/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/osgiservletregisterer.xml
+++ b/components/camel-servlet/src/test/resources/org/apache/camel/component/servlet/osgiservletregisterer.xml
@@ -27,7 +27,7 @@
<bean id="camelServlet" class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
- <bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
+ <bean class="org.apache.camel.component.osgi.OsgiServletRegisterer"
init-method="register"
destroy-method="unregister">
<property name="alias" value="alias" />