Remove obsolete subproject. (FELIX-3044)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1156754 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http.jetty/LICENSE b/http.jetty/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/http.jetty/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed 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.
diff --git a/http.jetty/NOTICE b/http.jetty/NOTICE
deleted file mode 100644
index a300b7f..0000000
--- a/http.jetty/NOTICE
+++ /dev/null
@@ -1,27 +0,0 @@
-Apache Felix Jetty HTTP Service
-Copyright 2008-2009 The Apache Software Foundation
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed by
-Mortbay (http://mortbay.org)
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2007).
-Licensed under the Apache License 2.0.
-
-II. Used Software
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org).
-Copyright (c) OSGi Alliance (2000, 2007).
-Licensed under the Apache License 2.0.
-
-III. License Summary
-- Apache License 2.0
\ No newline at end of file
diff --git a/http.jetty/doc/changelog.txt b/http.jetty/doc/changelog.txt
deleted file mode 100644
index ca469e6..0000000
--- a/http.jetty/doc/changelog.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Version 1.0.1
--------------
- * [FELIX-1236] Jetty HTTP service is exporting incorrect version of the
- service package.
-
-Version 1.0.0
--------------
- * Initial release
diff --git a/http.jetty/pom.xml b/http.jetty/pom.xml
deleted file mode 100644
index 1066ac2..0000000
--- a/http.jetty/pom.xml
+++ /dev/null
@@ -1,134 +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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <groupId>org.apache.felix</groupId>
- <artifactId>felix-parent</artifactId>
- <version>1.2.0</version>
- <relativePath>../../pom/pom.xml</relativePath>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>Apache Felix HTTP Service Jetty</name>
- <version>1.1.1-SNAPSHOT</version>
- <artifactId>org.apache.felix.http.jetty</artifactId>
- <dependencies>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.0.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>1.0.0</version>
- <exclusions>
- <exclusion>
- <groupId>${pom.groupId}</groupId>
- <artifactId>javax.servlet</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <!--
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>servlet-api-2.5</artifactId>
- <version>6.1.14</version>
- </dependency>
- -->
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.1.24</version>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-util</artifactId>
- <version>6.1.24</version>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty-sslengine</artifactId>
- <version>6.1.24</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>Apache Felix HTTP Service Jetty</Bundle-Name>
- <Bundle-Description>
- An implementation of the OSGi HTTP Service
- using Jetty.
- </Bundle-Description>
- <Bundle-Activator>
- ${pom.artifactId}.Activator
- </Bundle-Activator>
- <Bundle-SymbolicName>
- ${pom.artifactId}
- </Bundle-SymbolicName>
- <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
- <Export-Package>
- org.osgi.service.http,
- javax.servlet;javax.servlet.http;version=2.5
- </Export-Package>
- <Private-Package>
- org.apache.felix.http.jetty,
- org.mortbay.*;-split-package:=merge-first
- </Private-Package>
- <Import-Package>
- javax.net.ssl; javax.security.cert;
- javax.xml.parsers; org.xml.sax;
- org.xml.sax.helpers;
- org.slf4j;resolution:=optional, *
- </Import-Package>
- <Export-Service>
- org.osgi.service.http.HttpService
- </Export-Service>
- <Include-Resource>
- META-INF/LICENCE=LICENSE,
- META-INF/NOTICE=NOTICE
- </Include-Resource>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rat-maven-plugin</artifactId>
- <configuration>
- <excludeSubProjects>false</excludeSubProjects>
- <useEclipseDefaultExcludes>true</useEclipseDefaultExcludes>
- <useMavenDefaultExcludes>true</useMavenDefaultExcludes>
- <excludes>
- <param>doc/*</param>
- <param>maven-eclipse.xml</param>
- <param>.checkstyle</param>
- <param>.externalToolBuilders/*</param>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/http.jetty/src/main/java/org/apache/felix/http/jetty/Activator.java b/http.jetty/src/main/java/org/apache/felix/http/jetty/Activator.java
deleted file mode 100644
index 91bf091..0000000
--- a/http.jetty/src/main/java/org/apache/felix/http/jetty/Activator.java
+++ /dev/null
@@ -1,566 +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.felix.http.jetty;
-
-import java.util.Dictionary;
-import java.util.Properties;
-
-import org.mortbay.component.LifeCycle;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.bio.SocketConnector;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.security.HashUserRealm;
-import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.OsgiServletHandler;
-import org.mortbay.jetty.servlet.SessionHandler;
-import org.mortbay.log.Log;
-import org.mortbay.log.StdErrLog;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceFactory;
-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.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-
-/**
- * Basic implementation of OSGi HTTP service 1.1.
- *
- * TODO:
- *
- * - fuller suite of testing and compatibility tests
- *
- * - only exposed params are those defined in the OSGi spec. Jetty is
- * very tunable via params, some of which it may be useful to expose
- *
- * - no cacheing is performed on delivered resources. Although not part
- * of the OSGi spec, it also isn't precluded and would enhance
- * performance in a high usage environment. Jetty's ResourceHandler
- * class could be a model for this.
- *
- * - scanning the Jetty ResourceHandler class it's clear that there are
- * many other sophisticated areas to do with resource handling such
- * as checking date and range fields in the http headers. It's not clear
- * whether any of these play a part in the OSGi service - the spec
- * just describes "returning the contents of the URL to the client" which
- * doesn't state what other HTTP handling might be compliant or desirable
- */
-public class Activator implements BundleActivator, ManagedService, Runnable {
- private static final Properties EMPTY_PROPS = new Properties();
-
- public static final boolean DEFAULT_HTTP_ENABLE = true;
- public static final boolean DEFAULT_HTTPS_ENABLE = false;
- public static final boolean DEFAULT_USE_NIO = true;
- public static final int DEFAULT_HTTPS_PORT = 443;
- public static final int DEFAULT_HTTP_PORT = 80;
- public static final String DEFAULT_SSL_PROVIDER = "org.mortbay.http.SunJsseListener";
- public static final String DEFAULT_HTTPS_CLIENT_CERT = "none";
-
- /** Felix specific property to override the SSL provider. */
- public static final String FELIX_SSL_PROVIDER = "org.apache.felix.https.provider";
- public static final String OSCAR_SSL_PROVIDER = "org.ungoverned.osgi.bundle.https.provider";
-
- /** Felix specific property to override the keystore key password. */
- public static final String FELIX_KEYSTORE_KEY_PASSWORD = "org.apache.felix.https.keystore.key.password";
- public static final String OSCAR_KEYSTORE_KEY_PASSWORD = "org.ungoverned.osgi.bundle.https.key.password";
-
- /** Felix specific property to override the keystore file location. */
- public static final String FELIX_KEYSTORE = "org.apache.felix.https.keystore";
- public static final String OSCAR_KEYSTORE = "org.ungoverned.osgi.bundle.https.keystore";
-
- /** Felix specific property to override the keystore password. */
- public static final String FELIX_KEYSTORE_PASSWORD = "org.apache.felix.https.keystore.password";
- public static final String OSCAR_KEYSTORE_PASSWORD = "org.ungoverned.osgi.bundle.https.password";
-
- /** Standard OSGi port property for HTTP service */
- public static final String HTTP_PORT = "org.osgi.service.http.port";
-
- /** Standard OSGi port property for HTTPS service */
- public static final String HTTPS_PORT = "org.osgi.service.http.port.secure";
-
- /** Felix specific property to enable debug messages */
- public static final String FELIX_HTTP_DEBUG = "org.apache.felix.http.debug";
- public static final String HTTP_DEBUG = "org.apache.felix.http.jetty.debug";
-
- /** Felix specific property to determine the
- name of the service property to set with the http port used. If not supplied
- then the HTTP_PORT property name will be used for the service property */
- public static final String HTTP_SVCPROP_PORT = "org.apache.felix.http.svcprop.port";
-
- /** Felix specific property to determine the
- name of the service property to set with the https port used. If not supplied
- then the HTTPS_PORT property name will be used for the service property */
- public static final String HTTPS_SVCPROP_PORT = "org.apache.felix.http.svcprop.port.secure";
-
- /** Felix specific property to control whether NIO will be used. If not supplied
- then will default to true. */
- public static final String HTTP_NIO = "org.apache.felix.http.nio";
-
- /** Felix specific property to control whether to enable HTTPS. */
- public static final String FELIX_HTTPS_ENABLE = "org.apache.felix.https.enable";
- public static final String OSCAR_HTTPS_ENABLE = "org.ungoverned.osgi.bundle.https.enable";
-
- /** Felix specific property to control whether to enable HTTP. */
- public static final String FELIX_HTTP_ENABLE = "org.apache.felix.http.enable";
-
- /** Felix specific property to control whether to want or require HTTPS client certificates. Valid values are "none", "wants", "needs". Default is "none". */
- public static final String FELIX_HTTPS_CLIENT_CERT = "org.apache.felix.https.clientcertificate";
-
- /** Felix specific property to override the truststore file location. */
- public static final String FELIX_TRUSTSTORE = "org.apache.felix.https.truststore";
-
- /** Felix specific property to override the truststore password. */
- public static final String FELIX_TRUSTSTORE_PASSWORD = "org.apache.felix.https.truststore.password";
-
- /** PID for configuration of the HTTP service. */
- protected static final String PID = "org.apache.felix.http";
-
- protected static boolean debug = false;
- private static ServiceTracker m_logTracker = null;
-
- private BundleContext m_bundleContext = null;
- private ServiceRegistration m_svcReg = null;
- private HttpServiceFactory m_httpServ = null;
- private Server m_server = null;
- private OsgiServletHandler m_hdlr = null;
-
- private int m_httpPort;
- private int m_httpsPort;
- private boolean m_useNIO;
- private String m_sslProvider;
- private String m_httpsPortProperty;
- private String m_keystore;
- private String m_passwd;
- private String m_keyPasswd;
- private boolean m_useHttps;
- private String m_httpPortProperty;
- private String m_truststore;
- private String m_trustpasswd;
-
- private Properties m_svcProperties = new Properties();
- private boolean m_useHttp;
- private String m_clientcert;
- private ServiceRegistration m_configSvcReg;
- private volatile boolean m_running;
- private volatile Thread m_thread;
-
- public void start(BundleContext bundleContext) throws BundleException {
- m_bundleContext = bundleContext;
-
- m_logTracker = new ServiceTracker( bundleContext, LogService.class.getName(), null );
- m_logTracker.open();
-
- setConfiguration(EMPTY_PROPS);
-
- m_running = true;
- m_thread = new Thread(this, "Jetty HTTP Service Launcher");
- m_thread.start();
-
- m_configSvcReg = m_bundleContext.registerService(ManagedService.class.getName(), this, new Properties() {{ put(Constants.SERVICE_PID, PID); }} );
- }
-
- public void stop(BundleContext bundleContext) throws BundleException {
- if (m_configSvcReg != null) {
- m_configSvcReg.unregister();
- }
-
- m_running = false;
- m_thread.interrupt();
- try {
- m_thread.join(3000);
- }
- catch (InterruptedException e) {
- // not much we can do here
- }
-
- m_logTracker.close();
- }
-
- private void startJetty() {
- try {
- initializeJetty();
- }
- catch (Exception ex) {
- log(LogService.LOG_ERROR, "Exception while initializing Jetty.", ex);
- return;
- }
-
- m_httpServ = new HttpServiceFactory();
- m_svcReg = m_bundleContext.registerService( HttpService.class.getName(), m_httpServ, m_svcProperties );
- // OSGi spec states the properties should not be changed after registration,
- // so create new copy for later clone for updates
- m_svcProperties = new Properties(m_svcProperties);
- }
-
- private void stopJetty() {
- if (m_svcReg != null) {
- m_svcReg.unregister();
- // null the registration, because the listener assumes a non-null registration is valid
- m_svcReg = null;
- }
-
- try {
- m_server.stop();
- }
- catch (Exception e) {
- log(LogService.LOG_ERROR, "Exception while stopping Jetty.", e);
- }
- }
-
- /**
- * The main loop for running Jetty. We run Jetty in its own thread now because we need to
- * modify this thread's context classloader. The main loop starts Jetty and then waits until
- * it is interrupted. Then it stops Jetty, and either quits or restarts (depending on the
- * reason why the thread was interrupted, because the bundle was stopped or the configuration
- * was updated).
- */
- public void run() {
- // org.mortbay.util.Loader needs this (used for JDK 1.4 log classes)
- Thread.currentThread().setContextClassLoader( this.getClass().getClassLoader() );
-
- while (m_running) {
- // start jetty
- initializeJettyLogger();
- startJetty();
-
- // wait
- synchronized (this) {
- try {
- wait();
- }
- catch (InterruptedException e) {
- // we will definitely be interrupted
- }
- }
-
- // stop jetty
- stopJetty();
- destroyJettyLogger();
- }
- }
-
-
- public void updated(Dictionary props) throws ConfigurationException {
- if (props == null) {
- // fall back to default configuration
- setConfiguration(EMPTY_PROPS);
- }
- else {
- // let's see what we've got
- setConfiguration(props);
- }
- // notify the thread that the configuration was updated, causing Jetty to
- // restart
- if (m_thread != null) {
- m_thread.interrupt();
- }
- }
-
- private void setConfiguration(Dictionary props) {
- debug = getBooleanProperty(props, FELIX_HTTP_DEBUG, getBooleanProperty(props, HTTP_DEBUG, false));
-
- // get default HTTP and HTTPS ports as per the OSGi spec
- m_httpPort = getIntProperty(props, HTTP_PORT, DEFAULT_HTTP_PORT);
- m_httpsPort = getIntProperty(props, HTTPS_PORT, DEFAULT_HTTPS_PORT);
- // collect other properties, default to legacy names only if new ones are not available
- m_useNIO = getBooleanProperty(props, HTTP_NIO, DEFAULT_USE_NIO);
- m_sslProvider = getStringProperty(props, FELIX_SSL_PROVIDER, getStringProperty(props, OSCAR_SSL_PROVIDER, DEFAULT_SSL_PROVIDER));
- m_httpsPortProperty = getStringProperty(props, HTTPS_SVCPROP_PORT, HTTPS_PORT);
- m_keystore = getStringProperty(props, FELIX_KEYSTORE, m_bundleContext.getProperty(OSCAR_KEYSTORE));
- m_passwd = getStringProperty(props, FELIX_KEYSTORE_PASSWORD, m_bundleContext.getProperty(OSCAR_KEYSTORE_PASSWORD));
- m_keyPasswd = getStringProperty(props, FELIX_KEYSTORE_KEY_PASSWORD, m_bundleContext.getProperty(OSCAR_KEYSTORE_KEY_PASSWORD));
- m_useHttps = getBooleanProperty(props, FELIX_HTTPS_ENABLE, getBooleanProperty(props, OSCAR_HTTPS_ENABLE, DEFAULT_HTTPS_ENABLE));
- m_httpPortProperty = getStringProperty(props, HTTP_SVCPROP_PORT, HTTP_PORT);
- m_useHttp = getBooleanProperty(props, FELIX_HTTP_ENABLE, DEFAULT_HTTP_ENABLE);
- m_truststore = getStringProperty(props, FELIX_TRUSTSTORE, null);
- m_trustpasswd = getStringProperty(props, FELIX_TRUSTSTORE_PASSWORD, null);
- m_clientcert = getStringProperty(props, FELIX_HTTPS_CLIENT_CERT, DEFAULT_HTTPS_CLIENT_CERT);
- }
-
- private String getProperty(Dictionary props, String name) {
- String result = (String) props.get(name);
- if (result == null) {
- result = m_bundleContext.getProperty(name);
- }
- return result;
- }
-
- private int getIntProperty(Dictionary props, String name, int dflt_val) {
- int retval = dflt_val;
- try {
- retval = Integer.parseInt(getProperty(props, name));
- }
- catch (Exception e) {
- retval = dflt_val;
- }
- return retval;
- }
-
- private boolean getBooleanProperty(Dictionary props, String name, boolean dflt_val) {
- boolean retval = dflt_val;
- String strval = getProperty(props, name);
- if (strval != null) {
- retval = (strval.toLowerCase().equals("true") || strval.toLowerCase().equals("yes"));
- }
- return retval;
- }
-
- private String getStringProperty(Dictionary props, String name, String dflt_val) {
- String retval = dflt_val;
- String strval = getProperty(props, name);
- if (strval != null) {
- retval = strval;
- }
- return retval;
- }
-
- protected void initializeJettyLogger() {
- String oldProperty = System.getProperty( "org.mortbay.log.class" );
- System.setProperty( "org.mortbay.log.class", LogServiceLog.class.getName() );
-
- if (!(Log.getLog() instanceof LogServiceLog)) {
- Log.setLog( new LogServiceLog() );
- }
-
- Log.getLog().setDebugEnabled( debug );
-
- if (oldProperty != null) {
- System.setProperty( "org.mortbay.log.class", oldProperty );
- }
- }
-
- private void destroyJettyLogger() {
- // replace non-LogService logger for jetty
- Log.setLog( new StdErrLog() );
- }
-
- protected void initializeJetty() throws Exception
- {
- //TODO: Maybe create a separate "JettyServer" object here?
- // Realm
- HashUserRealm realm = new HashUserRealm( "OSGi HTTP Service Realm" );
-
- // Create server
- m_server = new Server();
- m_server.addUserRealm( realm );
-
- if (m_useHttp)
- {
- initializeHTTP();
- }
-
- if (m_useHttps)
- {
- initializeHTTPS();
- }
-
- // setup the Jetty web application context shared by all Http services
- m_hdlr = new OsgiServletHandler();
-
- Context hdlrContext = new Context( m_server, new SessionHandler(), null, m_hdlr, null );
- hdlrContext.setClassLoader( getClass().getClassLoader() );
- hdlrContext.setContextPath( "/" );
- debug( " adding handler context : " + hdlrContext );
-
- try
- {
- hdlrContext.start();
- }
- catch ( Exception e )
- {
- // make sure we unwind the adding process
- log( LogService.LOG_ERROR, "Exception Starting Jetty Handler Context", e );
- }
-
- m_server.start();
- }
-
- private void initializeHTTP() {
- Connector connector = m_useNIO ?
- (Connector) new SelectChannelConnector() : (Connector) new SocketConnector();
- connector.addLifeCycleListener(
- new ConnectorListener(m_httpPortProperty)
- );
-
- connector.setPort( m_httpPort );
- connector.setMaxIdleTime( 60000 );
- m_server.addConnector( connector );
- }
-
- //TODO: Just a basic implementation to give us a working HTTPS port. A better
- // long-term solution may be to separate out the SSL provider handling,
- // keystore, passwords etc. into it's own pluggable service
- protected void initializeHTTPS() throws Exception
- {
- if (m_useNIO) {
- SelectChannelConnector s_listener = (SelectChannelConnector) Class.forName("org.mortbay.jetty.security.SslSelectChannelConnector").newInstance();
- s_listener.addLifeCycleListener(new ConnectorListener(m_httpsPortProperty));
- s_listener.setPort(m_httpsPort);
- s_listener.setMaxIdleTime(60000);
- if (m_keystore != null) {
- s_listener.getClass().getMethod("setKeystore", new Class[] {String.class}).invoke(s_listener, new Object[] { m_keystore });
- }
- if (m_passwd != null) {
- System.setProperty("jetty.ssl.password" /* SslSelectChannelConnector.PASSWORD_PROPERTY */ , m_passwd);
- s_listener.getClass().getMethod("setPassword", new Class[] {String.class}).invoke(s_listener, new Object[] { m_passwd });
- }
- if (m_keyPasswd != null) {
- System.setProperty("jetty.ssl.keypassword" /* SslSelectChannelConnector.KEYPASSWORD_PROPERTY */, m_keyPasswd);
- s_listener.getClass().getMethod("setKeyPassword", new Class[] {String.class}).invoke(s_listener, new Object[] { m_keyPasswd });
- }
- if (m_truststore != null) {
- s_listener.getClass().getMethod("setTruststore", new Class[] {String.class}).invoke(s_listener, new Object[] { m_truststore });
- }
- if (m_trustpasswd != null) {
- s_listener.getClass().getMethod("setTrustPassword", new Class[] {String.class}).invoke(s_listener, new Object[] { m_trustpasswd });
- }
- if ("wants".equals(m_clientcert)) {
- s_listener.getClass().getMethod("setWantClientAuth", new Class[] { Boolean.TYPE }).invoke(s_listener, new Object[] { Boolean.TRUE });
- }
- else if ("needs".equals(m_clientcert)) {
- s_listener.getClass().getMethod("setNeedClientAuth", new Class[] { Boolean.TYPE }).invoke(s_listener, new Object[] { Boolean.TRUE });
- }
- m_server.addConnector(s_listener);
- }
- else {
- SslSocketConnector s_listener = new SslSocketConnector();
- s_listener.addLifeCycleListener(new ConnectorListener(m_httpsPortProperty));
- s_listener.setPort(m_httpsPort);
- s_listener.setMaxIdleTime(60000);
- if (m_keystore != null) {
- s_listener.setKeystore(m_keystore);
- }
- if (m_passwd != null) {
- System.setProperty(SslSocketConnector.PASSWORD_PROPERTY, m_passwd);
- s_listener.setPassword(m_passwd);
- }
- if (m_keyPasswd != null) {
- System.setProperty(SslSocketConnector.KEYPASSWORD_PROPERTY, m_keyPasswd);
- s_listener.setKeyPassword(m_keyPasswd);
- }
- if (m_truststore != null) {
- s_listener.setTruststore(m_truststore);
- }
- if (m_trustpasswd != null) {
- s_listener.setTrustPassword(m_trustpasswd);
- }
- if ("wants".equals(m_clientcert)) {
- s_listener.setWantClientAuth(true);
- s_listener.getClass().getMethod("setWantClientAuth", new Class[] {Boolean.class}).invoke(s_listener, new Object[] { Boolean.TRUE });
- }
- else if ("needs".equals(m_clientcert)) {
- s_listener.setNeedClientAuth(true);
- }
- m_server.addConnector(s_listener);
- }
- }
-
- public static void debug( String txt )
- {
- if ( debug )
- {
- log( LogService.LOG_DEBUG, ">>Felix HTTP: " + txt, null );
- }
- }
-
- public static void log( int level, String message, Throwable throwable )
- {
- LogService log = ( LogService ) m_logTracker.getService();
- if ( log != null )
- {
- log.log( level, message, throwable );
- }
- else
- {
- System.out.println( message );
- if ( throwable != null )
- {
- throwable.printStackTrace( System.out );
- }
- }
- }
-
- // Inner class to provide basic service factory functionality
- public class HttpServiceFactory implements ServiceFactory
- {
- public HttpServiceFactory()
- {
- // Initialize the statics for the service implementation.
- HttpServiceImpl.initializeStatics();
- }
-
- public Object getService( Bundle bundle, ServiceRegistration registration )
- {
- Object srv = new HttpServiceImpl( bundle, m_server, m_hdlr );
- debug( "** http service get:" + bundle + ", service: " + srv );
- return srv;
- }
-
- public void ungetService( Bundle bundle, ServiceRegistration registration, Object service )
- {
- debug( "** http service unget:" + bundle + ", service: " + service );
- ( ( HttpServiceImpl ) service ).unregisterAll();
- }
- }
-
- // Innner class to listen for connector startup and register service
- // properties for actual ports used. Possible connections may have deferred
- // startup, so this should ensure "port" is retrieved once available
- public class ConnectorListener implements LifeCycle.Listener
- {
- String m_svcPropName;
-
- public ConnectorListener(String svcPropName)
- {
- m_svcPropName = svcPropName;
- }
-
- public void lifeCycleFailure(LifeCycle event, Throwable cause) {}
-
- public void lifeCycleStarted(LifeCycle event)
- {
- Connector conn = (Connector) event;
- int actualPort = conn.getLocalPort();
-
- debug( "** http set service prop:" + m_svcPropName + ", value: " + actualPort );
-
- m_svcProperties.setProperty(m_svcPropName, String.valueOf(actualPort));
-
- if (m_svcReg != null)
- {
- m_svcReg.setProperties(m_svcProperties);
- m_svcProperties = new Properties(m_svcProperties);
- }
- }
-
- public void lifeCycleStarting(LifeCycle event) {}
-
- public void lifeCycleStopped(LifeCycle event) {}
-
- public void lifeCycleStopping(LifeCycle event) {}
- }
-}
\ No newline at end of file
diff --git a/http.jetty/src/main/java/org/apache/felix/http/jetty/DefaultContextImpl.java b/http.jetty/src/main/java/org/apache/felix/http/jetty/DefaultContextImpl.java
deleted file mode 100644
index ab832c4..0000000
--- a/http.jetty/src/main/java/org/apache/felix/http/jetty/DefaultContextImpl.java
+++ /dev/null
@@ -1,82 +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.felix.http.jetty;
-
-
-import java.net.URL;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.osgi.framework.Bundle;
-import org.osgi.service.http.HttpContext;
-
-
-/**
- * Implementation of default HttpContext as per OSGi specification.
- *
- * Notes
- *
- * - no current inclusion/support for permissions
- * - security allows all request. Spec leaves security handling to be
- * implementation specific, but does outline some suggested handling.
- * Deeper than my understanding of HTTP at this stage, so left for now.
- */
-public class DefaultContextImpl implements HttpContext
-{
- private Bundle m_bundle;
-
-
- public DefaultContextImpl( Bundle bundle )
- {
- m_bundle = bundle;
- }
-
-
- public String getMimeType( String name )
- {
- return null;
- }
-
-
- public URL getResource( String name )
- {
- //TODO: need to grant "org.osgi.framework.AdminPermission" when
- // permissions are included.
- Activator.debug( "getResource for:" + name );
-
- //TODO: temp measure for name. Bundle classloading doesn't seem to find
- // resources which have a leading "/". This code should be removed
- // if the bundle classloader is changed to allow a leading "/"
- if ( name.startsWith( "/" ) )
- {
- name = name.substring( 1 );
- }
-
- return m_bundle.getResource( name );
- }
-
-
- public boolean handleSecurity( HttpServletRequest request, HttpServletResponse response )
- {
- //TODO: need to look into what's appropriate for default security
- // handling. Default to all requests to be serviced for now.
- return true;
- }
-}
\ No newline at end of file
diff --git a/http.jetty/src/main/java/org/apache/felix/http/jetty/HttpServiceImpl.java b/http.jetty/src/main/java/org/apache/felix/http/jetty/HttpServiceImpl.java
deleted file mode 100644
index 2943703..0000000
--- a/http.jetty/src/main/java/org/apache/felix/http/jetty/HttpServiceImpl.java
+++ /dev/null
@@ -1,274 +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.felix.http.jetty;
-
-
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.OsgiResourceHolder;
-import org.mortbay.jetty.servlet.OsgiServletHandler;
-import org.mortbay.jetty.servlet.SessionHandler;
-import org.osgi.framework.Bundle;
-import org.osgi.service.http.HttpContext;
-import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
-import org.osgi.service.log.LogService;
-
-
-public class HttpServiceImpl implements HttpService
-{
- /** global namesspace of all aliases that have been registered */
- private static Map m_aliasNamespace = null;
-
- /** local list of aliases registered by the bundle holding this service */
- private Set m_localAliasSet = null;
-
- /** Bundle which "got" this service instance from the service factory */
- private Bundle m_bundle = null;
- private Server m_server = null;
- private OsgiServletHandler m_serverServletHandler = null;
-
-
- public HttpServiceImpl( Bundle bundle, Server server, OsgiServletHandler serverServletHandler )
- {
- m_bundle = bundle;
- m_server = server;
- m_serverServletHandler = serverServletHandler;
- m_localAliasSet = new HashSet();
-
- if ( m_aliasNamespace == null )
- {
- m_aliasNamespace = new HashMap();
- }
- }
-
-
- /**
- * Initializes static variables.
- **/
- public static void initializeStatics()
- {
- if ( m_aliasNamespace != null )
- {
- m_aliasNamespace.clear();
- }
- ServletContextGroup.initializeStatics();
- }
-
-
- public HttpContext createDefaultHttpContext()
- {
- return new DefaultContextImpl( m_bundle );
- }
-
-
- public void registerServlet( String alias, Servlet servlet, Dictionary params, HttpContext osgiHttpContext )
- throws ServletException, NamespaceException
- {
- Activator.debug( "http register servlet :" + m_bundle + ", alias: " + alias );
-
- if ( !aliasValid( alias ) )
- {
- throw new IllegalArgumentException( "malformed alias" );
- }
-
- if ( ServletContextGroup.isServletRegistered( servlet ) )
- {
- throw new ServletException( "servlet already registered" );
- }
-
- // add alias with null details, and record servlet instance details
- addAlias( alias, null );
-
- //make sure alias is unique, and create
- ServletContextGroup grp = null;
-
- if ( osgiHttpContext == null )
- {
- osgiHttpContext = createDefaultHttpContext();
- }
-
- // servlets using same context must get same handler to ensure
- // they share a common ServletContext
- Activator.debug( "looking for context: " + osgiHttpContext );
- grp = ServletContextGroup.getServletContextGroup( m_serverServletHandler, osgiHttpContext );
-
- grp.addServlet( servlet, alias, params );
-
- // update alias namespace with reference to group object for later
- // unregistering
- updateAlias( alias, grp );
-
- // maybe should remove alias/servlet entries if exceptions?
- }
-
-
- public void registerResources( String alias, String name, HttpContext osgiHttpContext ) throws NamespaceException
- {
- Activator.debug( "** http register resource :" + m_bundle + ", alias: " + alias );
-
- if ( !aliasValid( alias ) )
- {
- throw new IllegalArgumentException( "malformed alias: " + alias);
- }
-
- if ( !nameValid( name ) )
- {
- throw new IllegalArgumentException( "malformed name: " + name);
- }
-
- // add alias with null details
- addAlias( alias, null );
-
- //make sure alias is unique, and create
- Context hdlrContext = null;
-
- if ( osgiHttpContext == null )
- {
- osgiHttpContext = createDefaultHttpContext();
- }
-
- // servlets using same context must get same handler to ensure
- // they share a common ServletContext
- Activator.debug( "looking for context: " + osgiHttpContext );
- ServletContextGroup grp = ServletContextGroup.getServletContextGroup( m_serverServletHandler, osgiHttpContext );
-
- grp.addResource( alias, name );
-
- // update alias namespace with reference to group object for later
- // unregistering
- updateAlias( alias, grp );
-
- // maybe should remove alias/servlet entries if exceptions?
- }
-
-
- public void unregister( String alias )
- {
- doUnregister( alias, true );
- }
-
-
- protected void unregisterAll()
- {
- // note that this is a forced unregister, so we shouldn't call destroy
- // on any servlets
- // unregister each alias for the bundle - copy list since it will
- // change
- String[] all = ( String[] ) m_localAliasSet.toArray( new String[0] );
- for ( int ix = 0; ix < all.length; ix++ )
- {
- doUnregister( all[ix], false );
- }
- }
-
-
- protected void doUnregister( String alias, boolean forced )
- {
- Activator.debug( "** http unregister servlet :" + m_bundle + ", alias: " + alias + ",forced:" + forced );
- ServletContextGroup grp = removeAlias( alias );
- if ( grp != null )
- {
- grp.remove( alias, forced );
- }
- }
-
-
- protected void addAlias( String alias, Object obj ) throws NamespaceException
- {
- synchronized ( m_aliasNamespace )
- {
- if ( m_aliasNamespace.containsKey( alias ) )
- {
- throw new NamespaceException( "alias already registered" );
- }
-
- m_aliasNamespace.put( alias, obj );
- m_localAliasSet.add( alias );
- }
- }
-
-
- protected ServletContextGroup removeAlias( String alias )
- {
- synchronized ( m_aliasNamespace )
- {
- // remove alias, don't worry if doesn't exist
- Object obj = m_aliasNamespace.remove( alias );
- m_localAliasSet.remove( alias );
- return ( ServletContextGroup ) obj;
- }
- }
-
-
- protected void updateAlias( String alias, Object obj )
- {
- synchronized ( m_aliasNamespace )
- {
- // only update if already present
- if ( m_aliasNamespace.containsKey( alias ) )
- {
- m_aliasNamespace.put( alias, obj );
- }
- }
- }
-
-
- protected boolean aliasValid( String alias )
- {
- if (alias == null)
- {
- return false;
- }
-
- if (!alias.equals( "/" ) && ( !alias.startsWith( "/" ) || alias.endsWith( "/" ) ) )
- {
- return false;
- }
-
- return true;
- }
-
-
- protected boolean nameValid( String name )
- {
- if (name == null)
- {
- return false;
- }
-
- if (name.endsWith( "/" ))
- {
- return false;
- }
-
- return true;
- }
-}
\ No newline at end of file
diff --git a/http.jetty/src/main/java/org/apache/felix/http/jetty/LogServiceLog.java b/http.jetty/src/main/java/org/apache/felix/http/jetty/LogServiceLog.java
deleted file mode 100644
index f439a30..0000000
--- a/http.jetty/src/main/java/org/apache/felix/http/jetty/LogServiceLog.java
+++ /dev/null
@@ -1,128 +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.felix.http.jetty;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.mortbay.log.Logger;
-import org.osgi.service.log.LogService;
-
-
-public class LogServiceLog implements Logger
-{
- private static Map loggers = new HashMap();
-
- private final String m_name;
-
- private boolean m_debugEnabled;
-
-
- public LogServiceLog()
- {
- this( "org.mortbay.log" );
- }
-
-
- public LogServiceLog( String name )
- {
- this.m_name = name;
- }
-
-
- public Logger getLogger( String name )
- {
- Logger logger = ( Logger ) loggers.get( name );
- if ( logger == null )
- {
- logger = new LogServiceLog( name );
- logger.setDebugEnabled( isDebugEnabled() );
- loggers.put( name, logger );
- }
- return logger;
- }
-
-
- public boolean isDebugEnabled()
- {
- return m_debugEnabled;
- }
-
-
- public void setDebugEnabled( boolean enabled )
- {
- this.m_debugEnabled = enabled;
- }
-
-
- public void debug( String msg, Throwable throwable )
- {
- log( LogService.LOG_DEBUG, msg, throwable );
- }
-
-
- public void debug( String msg, Object arg0, Object arg1 )
- {
- log( LogService.LOG_DEBUG, format( msg, arg0, arg1 ), null );
- }
-
-
- public void info( String msg, Object arg0, Object arg1 )
- {
- log( LogService.LOG_INFO, format( msg, arg0, arg1 ), null );
- }
-
-
- public void warn( String msg, Throwable throwable )
- {
- log( LogService.LOG_WARNING, msg, throwable );
- }
-
-
- public void warn( String msg, Object arg0, Object arg1 )
- {
- log( LogService.LOG_WARNING, format( msg, arg0, arg1 ), null );
- }
-
-
- public String toString()
- {
- return m_name;
- }
-
-
- private String format( String msg, Object arg0, Object arg1 )
- {
- int i0 = msg.indexOf( "{}" );
- int i1 = i0 < 0 ? -1 : msg.indexOf( "{}", i0 + 2 );
-
- if ( arg1 != null && i1 >= 0 )
- msg = msg.substring( 0, i1 ) + arg1 + msg.substring( i1 + 2 );
- if ( arg0 != null && i0 >= 0 )
- msg = msg.substring( 0, i0 ) + arg0 + msg.substring( i0 + 2 );
- return msg;
- }
-
-
- private void log( int level, String message, Throwable throwable )
- {
- Activator.log( level, m_name + ":" + message, throwable );
- }
-}
diff --git a/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java b/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java
deleted file mode 100644
index 0a44ee4..0000000
--- a/http.jetty/src/main/java/org/apache/felix/http/jetty/ServletContextGroup.java
+++ /dev/null
@@ -1,371 +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.felix.http.jetty;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-
-import javax.servlet.RequestDispatcher;
-import javax.servlet.Servlet;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
-import org.mortbay.jetty.servlet.OsgiResourceHolder;
-import org.mortbay.jetty.servlet.OsgiServletHandler;
-import org.mortbay.jetty.servlet.OsgiServletHolder;
-import org.mortbay.jetty.servlet.ServletHolder;
-import org.osgi.service.http.HttpContext;
-
-
-public class ServletContextGroup implements ServletContext
-{
- /** global pool of all OSGi HttpContext that have been created */
- private static Map m_contextMap = new HashMap();
-
- /** global set of all servlet instances that have been registered */
- private static Set m_servletSet = new HashSet();
-
- private OsgiServletHandler m_hdlr = null;
- private HttpContext m_osgiHttpContext = null;
- private Hashtable m_attributes = null;
-
-
- static void initializeStatics()
- {
- m_contextMap.clear();
- m_servletSet.clear();
- }
-
-
- static ServletContextGroup getServletContextGroup( OsgiServletHandler hdlr, HttpContext osgiHttpContext )
- {
-
- ServletContextGroup grp = ( ServletContextGroup ) m_contextMap.get( osgiHttpContext );
- if ( grp == null )
- {
- grp = new ServletContextGroup( hdlr, osgiHttpContext );
- m_contextMap.put( osgiHttpContext, grp );
- }
-
- return grp;
- }
-
-
- static boolean isServletRegistered( Servlet servlet )
- {
- return m_servletSet.contains( servlet );
- }
-
-
- private ServletContextGroup( OsgiServletHandler hdlr, HttpContext osgiHttpContext )
- {
- init( hdlr, osgiHttpContext );
- }
-
-
- private void init( OsgiServletHandler hdlr, HttpContext osgiHttpContext )
- {
- m_hdlr = hdlr;
- m_osgiHttpContext = osgiHttpContext;
-
- m_attributes = new Hashtable();
-
- m_contextMap.put( m_osgiHttpContext, this );
- }
-
-
- private void destroy()
- {
- m_contextMap.remove( m_osgiHttpContext );
- }
-
-
- public HttpContext getOsgiHttpContext()
- {
- return m_osgiHttpContext;
- }
-
-
- void addServlet( Servlet servlet, String alias, Dictionary params )
- {
- String wAlias = aliasWildcard( alias );
- ServletHolder holder = new OsgiServletHolder( m_hdlr, servlet, wAlias, this, params );
- m_hdlr.addOsgiServletHolder( wAlias, holder );
- Activator.debug( " adding servlet instance: " + servlet );
- m_servletSet.add( servlet );
- }
-
-
- void addResource( String alias, String path )
- {
- String wAlias = aliasWildcard( alias );
- ServletHolder holder = new OsgiResourceHolder( m_hdlr, alias, path, this );
- m_hdlr.addOsgiServletHolder( wAlias, holder );
- Activator.debug( " adding resources for " + wAlias + " at: " + path );
- }
-
-
- void remove( String alias, boolean destroy )
- {
- String wAlias = aliasWildcard( alias );
- ServletHolder holder = m_hdlr.removeOsgiServletHolder( wAlias );
-
- if ( holder != null )
- {
- try
- {
- Servlet servlet = holder.getServlet();
- if ( servlet != null )
- {
- Activator.debug( " removing servlet instance: " + servlet );
- m_servletSet.remove( servlet );
-
- if ( destroy )
- {
- servlet.destroy();
- }
-
- if ( m_servletSet.isEmpty() )
- {
- destroy();
- }
- }
- }
- catch ( ServletException se )
- {
- // may only be thrown if servlet in holder is null
- }
- }
- }
-
-
- private String aliasWildcard( String alias )
- {
- // add wilcard filter at the end of the alias to allow servlet to
- // get requests which include sub-paths
- return "/".equals( alias ) ? "/*" : alias + "/*";
- }
-
-
- // ServletContext interface for OSGi servlets
-
- public ServletContext getContext( String contextName )
- {
- return m_hdlr.getServletContext().getContext( contextName );
- }
-
-
- public int getMajorVersion()
- {
- return m_hdlr.getServletContext().getMajorVersion();
- }
-
-
- public int getMinorVersion()
- {
- return m_hdlr.getServletContext().getMinorVersion();
- }
-
-
- public String getContextPath()
- {
- return m_hdlr.getServletContext().getContextPath();
- }
-
-
- public String getMimeType( String file )
- {
- String type = m_osgiHttpContext.getMimeType( file );
- if ( type != null )
- {
- return type;
- }
-
- return m_hdlr.getServletContext().getMimeType( file );
- }
-
-
- public String getRealPath( String path )
- {
- // resources are contained in the bundle and thus are not
- // available as normal files in the platform filesystem
- return null;
- }
-
-
- public URL getResource( String path )
- {
- return m_osgiHttpContext.getResource( path );
- }
-
-
- public InputStream getResourceAsStream( String path )
- {
- URL res = getResource( path );
- if ( res != null )
- {
- try
- {
- return res.openStream();
- }
- catch ( IOException ignore )
- {
- // might want to log, but actually don't care here
- }
- }
-
- return null;
- }
-
-
- public Set getResourcePaths( String path )
- {
- // This is not implemented yet, might want to access the bundle entries
- return null;
- }
-
-
- public RequestDispatcher getRequestDispatcher( String uri )
- {
- return m_hdlr.getServletContext().getRequestDispatcher( uri );
- }
-
-
- public RequestDispatcher getNamedDispatcher( String name )
- {
- if ( getMinorVersion() >= 2 )
- {
- return m_hdlr.getServletContext().getNamedDispatcher( name );
- }
-
- return null;
- }
-
-
- public String getServerInfo()
- {
- return m_hdlr.getServletContext().getServerInfo();
- }
-
-
- public String getServletContextName()
- {
- if ( getMinorVersion() >= 3 )
- {
- return m_hdlr.getServletContext().getServletContextName();
- }
-
- return null;
- }
-
-
- public Servlet getServlet( String servletName ) throws ServletException
- {
- return m_hdlr.getServletContext().getServlet( servletName );
- }
-
-
- public Enumeration getServletNames()
- {
- return m_hdlr.getServletContext().getServletNames();
- }
-
-
- public String getInitParameter( String name )
- {
- if ( getMinorVersion() >= 2 )
- {
- return m_hdlr.getServletContext().getInitParameter( name );
- }
-
- return null;
- }
-
-
- public Enumeration getInitParameterNames()
- {
- if ( getMinorVersion() >= 2 )
- {
- return m_hdlr.getServletContext().getInitParameterNames();
- }
-
- return Collections.enumeration( Collections.EMPTY_LIST );
- }
-
-
- /* (non-Javadoc)
- * @see javax.servlet.ServletContext#getServlets()
- */
- public Enumeration getServlets()
- {
- return m_hdlr.getServletContext().getServlets();
- }
-
-
- public void log( Exception exception, String message )
- {
- m_hdlr.getServletContext().log( exception, message );
- }
-
-
- public void log( String message, Throwable throwable )
- {
- m_hdlr.getServletContext().log( message, throwable );
- }
-
-
- public void log( String message )
- {
- m_hdlr.getServletContext().log( message );
- }
-
-
- public void setAttribute( String name, Object value )
- {
- m_attributes.put( name, value );
- }
-
-
- public Object getAttribute( String name )
- {
- return m_attributes.get( name );
- }
-
-
- public Enumeration getAttributeNames()
- {
- return m_attributes.keys();
- }
-
-
- public void removeAttribute( String name )
- {
- m_attributes.remove( name );
- }
-}
\ No newline at end of file
diff --git a/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiResourceHolder.java b/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiResourceHolder.java
deleted file mode 100644
index 5efcbf6..0000000
--- a/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiResourceHolder.java
+++ /dev/null
@@ -1,333 +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.mortbay.jetty.servlet;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.File;
-import java.net.URL;
-import java.net.URLConnection;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.felix.http.jetty.Activator;
-import org.apache.felix.http.jetty.ServletContextGroup;
-import org.mortbay.jetty.HttpConnection;
-import org.mortbay.jetty.HttpMethods;
-import org.mortbay.jetty.Request;
-import org.osgi.service.http.HttpContext;
-import org.osgi.service.log.LogService;
-
-
-public class OsgiResourceHolder extends ServletHolder
-{
- private ServletContextGroup m_servletContextGroup;
- private HttpContext m_osgiHttpContext;
- private AccessControlContext m_acc;
- private String m_path;
-
-
- public OsgiResourceHolder( ServletHandler handler, String name, String path, ServletContextGroup servletContextGroup )
- {
- super();
-
- setServletHandler( handler );
- setName( name );
-
- m_servletContextGroup = servletContextGroup;
- m_osgiHttpContext = servletContextGroup.getOsgiHttpContext();
- m_path = path;
- if (m_path == null)
- {
- m_path = "";
- }
-
- if ( System.getSecurityManager() != null )
- {
- m_acc = AccessController.getContext();
- }
- }
-
-
- public synchronized Servlet getServlet()
- {
- return null;
- }
-
-
- // override "Holder" method to prevent instantiation
- public synchronized Object newInstance()
- {
- return null;
- }
-
-
- public void handle( ServletRequest sRequest, ServletResponse sResponse ) throws ServletException, IOException
- {
- HttpServletRequest request = ( HttpServletRequest ) sRequest;
- HttpServletResponse response = ( HttpServletResponse ) sResponse;
-
- // get the relative path (assume empty path if there is no path info)
- // (FELIX-503)
- String target = request.getPathInfo();
- if (target == null)
- {
- target = "";
- }
-
- if (!target.startsWith("/"))
- {
- target += "/" + target;
- }
-
- Activator.debug( "handle for name:" + m_path + " (path=" + target + ")" );
-
- if ( !m_osgiHttpContext.handleSecurity( request, response ) )
- {
- return;
- }
-
- // Create resource based name and see if we can resolve it
- String resName = m_path + target;
- Activator.debug( "** looking for: " + resName );
- URL url = m_osgiHttpContext.getResource( resName );
-
- if ( url == null )
- {
- Request base_request = sRequest instanceof Request ? ( Request ) sRequest : HttpConnection
- .getCurrentConnection().getRequest();
- base_request.setHandled( false );
- return;
- }
-
- Activator.debug( "serving up:" + resName );
-
- String method = request.getMethod();
- if ( method.equals( HttpMethods.GET ) || method.equals( HttpMethods.POST ) || method.equals( HttpMethods.HEAD ) )
- {
- handleGet( request, response, url, resName );
- }
- else
- {
- try
- {
- response.sendError( HttpServletResponse.SC_NOT_IMPLEMENTED );
- }
- catch ( Exception e )
- {/*TODO: include error logging*/
- }
- }
- }
-
-
- public void handleGet( HttpServletRequest request, final HttpServletResponse response, final URL url, String resName )
- throws IOException
- {
- String encoding = m_osgiHttpContext.getMimeType( resName );
-
- if ( encoding == null )
- {
- encoding = m_servletContextGroup.getMimeType( resName );
- }
-
- if ( encoding == null )
- {
- encoding = m_servletContextGroup.getMimeType( ".default" );
- }
-
- //TODO: not sure why this is needed, but sometimes get "IllegalState"
- // errors if not included
- response.setContentType( encoding );
-
- long lastModified = getLastModified(url);
-
- if (lastModified != 0)
- {
- response.setDateHeader("Last-Modified", lastModified);
- }
-
- if (!resourceModified(lastModified, request.getDateHeader("If-Modified-Since")))
- {
- response.setStatus(response.SC_NOT_MODIFIED);
- }
- else
- {
- // make sure we access the resource inside the bundle's access control
- // context if supplied
- if ( m_acc != null )
- {
- try
- {
- AccessController.doPrivileged( new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- copyResourceBytes( url, response );
- return null;
- }
- }, m_acc );
- }
- catch ( PrivilegedActionException ex )
- {
- IOException ioe = ( IOException ) ex.getException();
- throw ioe;
- }
- }
- else
- {
- copyResourceBytes( url, response );
- }
-
- //TODO: set other http fields e.g. __LastModified, __ContentLength
- }
- }
-
-
- private void copyResourceBytes( URL url, HttpServletResponse response ) throws IOException
- {
- OutputStream os = null;
- InputStream is = null;
-
- try
- {
- os = response.getOutputStream();
- is = url.openStream();
-
- int len = 0;
- byte[] buf = new byte[1024];
- int n = 0;
-
- while ( ( n = is.read( buf, 0, buf.length ) ) >= 0 )
- {
- os.write( buf, 0, n );
- len += n;
- }
-
- try
- {
- response.setContentLength( len );
- }
- catch ( IllegalStateException ex )
- {
- Activator.log( LogService.LOG_ERROR, "OsgiResourceHandler", ex );
- }
- }
- finally
- {
- if ( is != null )
- {
- is.close();
- }
- if ( os != null )
- {
- os.close();
- }
- }
- }
-
-
- // override "Holder" method to prevent attempt to load
- // the servlet class.
- public void doStart() throws Exception
- {
- }
-
-
- // override "Holder" method to prevent destroy, which is only called
- // when a bundle manually unregisters
- public void doStop()
- {
- }
-
-
- /**
- * Gets the last modified value for file modification detection.
- * Aids in "conditional get" and intermediate proxy/node cacheing.
- *
- * Approach used follows that used by Sun for JNLP handling to workaround an
- * apparent issue where file URLs do not correctly return a last modified time.
- *
- */
- protected long getLastModified (URL resUrl)
- {
- long lastModified = 0;
-
- try
- {
- // Get last modified time
- URLConnection conn = resUrl.openConnection();
- lastModified = conn.getLastModified();
- }
- catch (Exception e)
- {
- // do nothing
- }
-
- if (lastModified == 0)
- {
- // Arguably a bug in the JRE will not set the lastModified for file URLs, and
- // always return 0. This is a workaround for that problem.
- String filepath = resUrl.getPath();
-
- if (filepath != null)
- {
- File f = new File(filepath);
- if (f.exists())
- {
- lastModified = f.lastModified();
- }
- }
- }
-
- Activator.debug( "url: " + resUrl + ", lastModified:" + lastModified);
-
- return lastModified;
- }
-
-
- protected boolean resourceModified(long resTimestamp, long modSince)
- {
- boolean retval = false;
-
- // Have to normalise timestamps as HTTP times have last 3 digits as zero
- modSince /= 1000;
- resTimestamp /= 1000;
-
- // Timestamp check to see if modified - resTimestamp 0 check is for
- // safety in case we didn't manage to get a timestamp for the resource
- if (resTimestamp == 0 || modSince == -1 || resTimestamp > modSince)
- {
- retval = true;
- }
-
- return retval;
- }
-
-}
diff --git a/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiServletHandler.java b/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiServletHandler.java
deleted file mode 100644
index beaae87..0000000
--- a/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiServletHandler.java
+++ /dev/null
@@ -1,120 +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.mortbay.jetty.servlet;
-
-
-import java.io.IOException;
-import java.net.URL;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.felix.http.jetty.Activator;
-import org.mortbay.util.LazyList;
-import org.osgi.service.log.LogService;
-
-
-public class OsgiServletHandler extends ServletHandler
-{
- // allow external adding of osgi servlet holder
- public void addOsgiServletHolder( String pathSpec, ServletHolder holder )
- {
- super.addServletWithMapping( holder, pathSpec );
- }
-
-
- public ServletHolder removeOsgiServletHolder( String pathSpec )
- {
- ServletMapping oldMapping = null;
- ServletMapping[] mappings = getServletMappings();
- for ( int i = 0; i < mappings.length && oldMapping == null; i++ )
- {
- String[] pathSpecs = mappings[i].getPathSpecs();
- for ( int j = 0; j < pathSpecs.length && oldMapping == null; j++ )
- {
- if ( pathSpec.equals( pathSpecs[j] ) )
- {
- oldMapping = mappings[i];
- }
- }
- }
-
- if ( oldMapping == null )
- {
- return null;
- }
-
- ServletHolder[] holders = getServlets();
- if ( holders != null )
- {
- holders = ( ServletHolder[] ) holders.clone();
- }
-
- ServletHolder oldHolder = null;
- for ( int i = 0; i < holders.length; i++ )
- {
- if ( oldMapping.getServletName().equals( holders[i].getName() ) )
- {
- oldHolder = holders[i];
- }
- }
- if ( oldHolder == null )
- {
- return null;
- }
-
- try
- {
- setServlets( ( ServletHolder[] ) LazyList.removeFromArray( holders, oldHolder ) );
- setServletMappings( ( ServletMapping[] ) LazyList.removeFromArray( mappings, oldMapping ) );
-
- if (oldHolder.isStarted() && isStopped()) {
- oldHolder.stop();
- }
-
- return ( ServletHolder ) oldHolder;
- }
- catch ( Exception e )
- {
- setServlets( holders );
- if ( e instanceof RuntimeException )
- throw ( RuntimeException ) e;
- throw new RuntimeException( e );
- }
- }
-
-
- // override standard handler behaviour to return resource from OSGi
- // HttpContext
- public URL getResource( String uriInContext )
- {
- Activator.debug( "OSGI ServletHandler getResource:" + uriInContext );
- return null;
- }
-
-
- public void handle( String target, HttpServletRequest request, HttpServletResponse response, int type )
- throws IOException, ServletException
- {
- Activator.debug( "dispatch path = " + target );
- super.handle( target, request, response, type );
- }
-
-}
diff --git a/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiServletHolder.java b/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiServletHolder.java
deleted file mode 100644
index 07b5aa1..0000000
--- a/http.jetty/src/main/java/org/mortbay/jetty/servlet/OsgiServletHolder.java
+++ /dev/null
@@ -1,178 +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.mortbay.jetty.servlet;
-
-
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Enumeration;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.UnavailableException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.felix.http.jetty.ServletContextGroup;
-import org.osgi.service.http.HttpContext;
-
-
-public class OsgiServletHolder extends ServletHolder
-{
- private Servlet m_servlet;
- private ServletContextGroup m_servletContextGroup;
- private ServletConfig m_config;
-
-
- public OsgiServletHolder( ServletHandler handler, Servlet servlet, String name,
- ServletContextGroup servletContextGroup, Dictionary params )
- {
- super(servlet);
- setServletHandler( handler );
- setName( name );
-
- m_servlet = servlet;
- m_servletContextGroup = servletContextGroup;
-
- // Seemed safer to copy params into parent holder, rather than override
- // the getInitxxx methods.
- if ( params != null )
- {
- Enumeration e = params.keys();
- while ( e.hasMoreElements() )
- {
- Object key = e.nextElement();
- setInitParameter( String.valueOf( key ), String.valueOf( params.get( key ) ) );
- }
- }
- }
-
-
- public synchronized Servlet getServlet()
- {
- return m_servlet;
- }
-
-
- public Servlet getOsgiServlet()
- {
- return m_servlet;
- }
-
-
- // override "Holder" method to prevent instantiation
- public synchronized Object newInstance()
- {
- return getOsgiServlet();
- }
-
-
- public void handle( ServletRequest request, ServletResponse response ) throws ServletException,
- UnavailableException, IOException
- {
- if ( m_servletContextGroup.getOsgiHttpContext().handleSecurity( ( HttpServletRequest ) request,
- ( HttpServletResponse ) response ) )
- {
- // wrap request to get auth type and remote user
- request = new HttpServiceHttpServletRequest( ( HttpServletRequest ) request );
-
- // service request
- super.handle( request, response );
- }
- else
- {
- //TODO: any other error/auth handling we should do in here?
-
- // response.flushBuffer() if available
- try
- {
- response.getClass().getDeclaredMethod( "flushBuffer", null ).invoke( response, null );
- }
- catch ( Exception ex )
- {
- // else ignore
- ex.printStackTrace();
- }
- }
- }
-
-
- // override "Holder" method to prevent attempt to load
- // the servlet class.
- public void doStart() throws Exception
- {
- _class = m_servlet.getClass();
-
- m_config = new Config()
- {
- public ServletContext getServletContext()
- {
- return m_servletContextGroup;
- }
- };
-
- m_servlet.init( m_config );
- }
-
-
- // override "Holder" method to prevent destroy, which is only called
- // when a bundle manually unregisters
- public void doStop()
- {
- }
-
- // Simple wrapper class returning the authentication type and remote user
- // from the respective request attribute as specificed by the HttpService
- // spec (step 4 in Section 102.7, Authentication)
- private static class HttpServiceHttpServletRequest extends HttpServletRequestWrapper {
-
- HttpServiceHttpServletRequest(HttpServletRequest request) {
- super(request);
- }
-
- public String getAuthType()
- {
- // use the auth type attribute; should not be null, but
- // better check and use wrapped result if missing
- Object name = getAttribute( HttpContext.AUTHENTICATION_TYPE );
- if (name != null) {
- return name.toString();
- }
-
- return super.getAuthType();
- }
-
- public String getRemoteUser()
- {
- // use the remote user attribute; should not be null, but
- // better check and use wrapped result if missing
- Object name = getAttribute( HttpContext.REMOTE_USER );
- if (name != null) {
- return name.toString();
- }
-
- return super.getRemoteUser();
- }
- }
-}
diff --git a/pom.xml b/pom.xml
index 7d419c8..fd4ca8b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,7 +108,6 @@
<module>log</module>
<module>eventadmin</module>
<module>http</module>
- <!--module>http.jetty</module-->
<module>upnp</module>
<module>scr</module>
<module>configadmin</module>