You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by sr...@apache.org on 2009/09/14 11:59:16 UTC

svn commit: r814549 [3/4] - in /felix/trunk/http: ./ api/ api/src/ api/src/main/ api/src/main/java/ api/src/main/java/org/ api/src/main/java/org/apache/ api/src/main/java/org/apache/felix/ api/src/main/java/org/apache/felix/http/ api/src/main/java/org/...

Added: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java (added)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,189 @@
+/*
+ * 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.internal;
+
+import org.osgi.framework.BundleContext;
+import java.util.Dictionary;
+import java.util.Properties;
+
+public final class JettyConfig
+{
+    /** Standard OSGi port property for HTTP service */
+    private static final String HTTP_PORT = "org.osgi.service.http.port";
+
+    /** Standard OSGi port property for HTTPS service */
+    private static final String HTTPS_PORT = "org.osgi.service.http.port.secure";
+
+    /** Felix specific property to enable debug messages */
+    private static final String FELIX_HTTP_DEBUG = "org.apache.felix.http.debug";
+    private static final String HTTP_DEBUG = "org.apache.felix.http.jetty.debug";
+
+    /** Felix specific property to override the keystore file location. */
+    private static final String FELIX_KEYSTORE = "org.apache.felix.https.keystore";
+    private static final String OSCAR_KEYSTORE = "org.ungoverned.osgi.bundle.https.keystore";
+
+    /** Felix specific property to override the keystore password. */
+    private static final String FELIX_KEYSTORE_PASSWORD = "org.apache.felix.https.keystore.password";
+    private static final String OSCAR_KEYSTORE_PASSWORD = "org.ungoverned.osgi.bundle.https.password";
+
+    /** Felix specific property to override the keystore key password. */
+    private static final String FELIX_KEYSTORE_KEY_PASSWORD = "org.apache.felix.https.keystore.key.password";
+    private static final String OSCAR_KEYSTORE_KEY_PASSWORD = "org.ungoverned.osgi.bundle.https.key.password";
+
+    /** Felix specific property to control whether to enable HTTPS. */
+    private static final String FELIX_HTTPS_ENABLE = "org.apache.felix.https.enable";
+    private static final String  OSCAR_HTTPS_ENABLE   = "org.ungoverned.osgi.bundle.https.enable";
+
+    /** Felix specific property to control whether to enable HTTP. */
+    private static final String FELIX_HTTP_ENABLE = "org.apache.felix.http.enable";
+
+    /** Felix specific property to override the truststore file location. */
+    private static final String FELIX_TRUSTSTORE = "org.apache.felix.https.truststore";
+
+    /** Felix specific property to override the truststore password. */
+    private static final String FELIX_TRUSTSTORE_PASSWORD = "org.apache.felix.https.truststore.password";
+
+    /** Felix specific property to control whether to want or require HTTPS client certificates. Valid values are "none", "wants", "needs". Default is "none". */
+    private static final String FELIX_HTTPS_CLIENT_CERT = "org.apache.felix.https.clientcertificate";
+    
+    private final BundleContext context;
+    private boolean debug;
+    private int httpPort;
+    private int httpsPort;
+    private String keystore;
+    private String password;
+    private String keyPassword;
+    private boolean useHttps;
+    private String truststore;
+    private String trustPassword;
+    private boolean useHttp;
+    private String clientcert;
+
+    public JettyConfig(BundleContext context)
+    {
+        this.context = context;
+        reset();
+    }
+
+    public boolean isDebug()
+    {
+        return this.debug;
+    }
+
+    public boolean isUseHttp()
+    {
+        return this.useHttp;
+    }
+
+    public boolean isUseHttps()
+    {
+        return this.useHttps;
+    }
+
+    public int getHttpPort()
+    {
+        return this.httpPort;
+    }
+
+    public int getHttpsPort()
+    {
+        return this.httpsPort;
+    }
+
+    public String getKeystore()
+    {
+        return this.keystore;
+    }
+
+    public String getPassword()
+    {
+        return this.password;
+    }
+
+    public String getTruststore()
+    {
+        return this.truststore;
+    }
+
+    public String getTrustPassword()
+    {
+        return this.trustPassword;
+    }
+
+    public String getKeyPassword()
+    {
+        return this.keyPassword;
+    }
+
+    public String getClientcert()
+    {
+        return this.clientcert;
+    }
+
+    public void reset()
+    {
+        update(null);
+    }
+
+    public void update(Dictionary props)
+    {
+        if (props == null) {
+            props = new Properties();
+        }
+
+        this.debug = getBooleanProperty(props, FELIX_HTTP_DEBUG, getBooleanProperty(props, HTTP_DEBUG, false));
+        this.httpPort = getIntProperty(props, HTTP_PORT, 8080);
+        this.httpsPort = getIntProperty(props, HTTPS_PORT, 433);
+        this.keystore = getProperty(props, FELIX_KEYSTORE, this.context.getProperty(OSCAR_KEYSTORE));
+        this.password = getProperty(props, FELIX_KEYSTORE_PASSWORD, this.context.getProperty(OSCAR_KEYSTORE_PASSWORD));
+        this.keyPassword = getProperty(props, FELIX_KEYSTORE_KEY_PASSWORD, this.context.getProperty(OSCAR_KEYSTORE_KEY_PASSWORD));
+        this.useHttps = getBooleanProperty(props, FELIX_HTTPS_ENABLE, getBooleanProperty(props, OSCAR_HTTPS_ENABLE, false));
+        this.useHttp = getBooleanProperty(props, FELIX_HTTP_ENABLE, true);
+        this.truststore = getProperty(props, FELIX_TRUSTSTORE, null);
+        this.trustPassword = getProperty(props, FELIX_TRUSTSTORE_PASSWORD, null);
+        this.clientcert = getProperty(props, FELIX_HTTPS_CLIENT_CERT, "none");
+    }
+
+    private String getProperty(Dictionary props, String name, String defValue)
+    {
+        String value = (String)props.get(name);
+        if (value == null) {
+            value = this.context.getProperty(name);
+        }
+
+        return value != null ? value : defValue;
+    }
+
+    private boolean getBooleanProperty(Dictionary props, String name, boolean defValue)
+    {
+        String value = getProperty(props, name, null);
+        if (value != null) {
+            return (value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"));
+        }
+
+        return defValue;
+    }
+
+    private int getIntProperty(Dictionary props, String name, int defValue)
+    {
+        try {
+            return Integer.parseInt(getProperty(props, name, null));
+        } catch (Exception e) {
+            return defValue;
+        }
+    }
+}

Added: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java (added)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,111 @@
+/*
+ * 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.internal;
+
+import org.mortbay.log.Logger;
+import org.apache.felix.http.base.internal.util.SystemLogger;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public final class JettyLogger
+    implements Logger
+{
+    private final static Map<String, Logger> LOGGERS =
+        new HashMap<String, Logger>();
+
+    private final String name;
+    private boolean debugEnabled;
+
+    public JettyLogger()
+    {
+        this("org.mortbay.log");
+    }
+
+    public JettyLogger(String name)
+    {
+        this.name = name;
+    }
+
+    public org.mortbay.log.Logger getLogger(String name)
+    {
+        Logger logger = LOGGERS.get(name);
+        if (logger == null) {
+            logger = new JettyLogger(name);
+            logger.setDebugEnabled(isDebugEnabled());
+            LOGGERS.put(name, logger);
+        }
+
+        return logger;
+    }
+
+    public boolean isDebugEnabled()
+    {
+        return this.debugEnabled;
+    }
+
+    public void setDebugEnabled(boolean enabled)
+    {
+        this.debugEnabled = enabled;
+    }
+
+    public void debug(String msg, Throwable cause)
+    {
+        SystemLogger.get().debug(msg);
+    }
+
+    public void debug(String msg, Object arg0, Object arg1)
+    {
+        SystemLogger.get().debug(format(msg, arg0, arg1));
+    }
+
+    public void info(String msg, Object arg0, Object arg1)
+    {
+        SystemLogger.get().info(format(msg, arg0, arg1));
+    }
+
+    public void warn(String msg, Throwable cause)
+    {
+        SystemLogger.get().warning(msg, cause);
+    }
+
+    public void warn( String msg, Object arg0, Object arg1 )
+    {
+        SystemLogger.get().warning(format(msg, arg0, arg1), null);
+    }
+
+    public String toString()
+    {
+        return this.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;
+    }
+}

Added: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java (added)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,213 @@
+/*
+ * 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.internal;
+
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.mortbay.jetty.security.HashUserRealm;
+import org.mortbay.jetty.security.SslSelectChannelConnector;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.servlet.*;
+import org.mortbay.log.Log;
+import org.mortbay.log.StdErrLog;
+import org.apache.felix.http.base.internal.util.SystemLogger;
+import org.apache.felix.http.base.internal.DispatcherServlet;
+import java.util.Properties;
+import java.util.Dictionary;
+
+public final class JettyService
+    implements ManagedService, Runnable
+{
+    /** PID for configuration of the HTTP service. */
+    private static final String PID = "org.apache.felix.http";
+
+    private final JettyConfig config;
+    private final BundleContext context;
+    private boolean running;
+    private Thread thread;
+    private ServiceRegistration configServiceReg;
+    private Server server;
+    private DispatcherServlet dispatcher;
+
+    public JettyService(BundleContext context, DispatcherServlet dispatcher)
+    {
+        this.context = context;
+        this.config = new JettyConfig(this.context);
+        this.dispatcher = dispatcher;
+    }
+    
+    public void start()
+        throws Exception
+    {
+        this.running = true;
+        this.thread = new Thread(this, "Jetty HTTP Service");
+        this.thread.start();
+
+        Properties props = new Properties();
+        props.put(Constants.SERVICE_PID, PID);
+
+        this.configServiceReg = this.context.registerService(ManagedService.class.getName(), this, props);
+    }
+
+    public void stop()
+        throws Exception
+    {
+        if (this.configServiceReg != null) {
+            this.configServiceReg.unregister();
+        }
+
+        this.running = false;
+        this.thread.interrupt();
+
+        try {
+            this.thread.join(3000);
+        } catch (InterruptedException e) {
+            // Do nothing
+        }
+    }
+    
+    public void updated(Dictionary props)
+        throws ConfigurationException
+    {
+        this.config.update(props);
+        if (this.thread != null) {
+            this.thread.interrupt();
+        }
+    }
+
+    private void startJetty()
+    {
+        try {
+            initializeJetty();
+        } catch (Exception e) {
+            SystemLogger.get().error("Exception while initializing Jetty.", e);
+        }
+    }
+
+    private void stopJetty()
+    {
+        try {
+            this.server.stop();
+        } catch (Exception e) {
+            SystemLogger.get().error("Exception while stopping Jetty.", e);
+        }
+    }
+
+    protected void initializeJettyLogger()
+    {
+        Log.setLog(new JettyLogger());
+    }
+
+    private void destroyJettyLogger()
+    {
+        Log.setLog(new StdErrLog());
+    }
+
+    private void initializeJetty()
+        throws Exception
+    {
+        HashUserRealm realm = new HashUserRealm("OSGi HTTP Service Realm");
+        this.server = new Server();
+        this.server.addUserRealm(realm);
+
+        if (this.config.isUseHttp()) {
+            initializeHttp();
+        }
+
+        if (this.config.isUseHttps()) {
+            initializeHttps();
+        }
+
+        Context context = new Context(this.server, "/", Context.SESSIONS);
+        context.addServlet(new ServletHolder(this.dispatcher), "/*");
+
+        this.server.start();
+    }
+
+    private void initializeHttp()
+        throws Exception
+    {
+        Connector connector = new SelectChannelConnector();
+        connector.setPort(this.config.getHttpPort());
+        connector.setMaxIdleTime(60000);
+        this.server.addConnector(connector);
+    }
+
+    private void initializeHttps()
+        throws Exception
+    {
+        SslSelectChannelConnector connector = new SslSelectChannelConnector();
+        connector.setPort(this.config.getHttpsPort());
+        connector.setMaxIdleTime(60000);
+        
+        if (this.config.getKeystore() != null) {
+            connector.setKeystore(this.config.getKeystore());
+        }
+        
+        if (this.config.getPassword() != null) {
+            System.setProperty(SslSelectChannelConnector.PASSWORD_PROPERTY, this.config.getPassword());
+            connector.setPassword(this.config.getPassword());
+        }
+        
+        if (this.config.getKeyPassword() != null) {
+            System.setProperty(SslSelectChannelConnector.KEYPASSWORD_PROPERTY, this.config.getKeyPassword());
+            connector.setKeyPassword(this.config.getKeyPassword());
+        }
+        
+        if (this.config.getTruststore() != null) {
+            connector.setTruststore(this.config.getTruststore());
+        }
+        
+        if (this.config.getTrustPassword() != null) {
+            connector.setTrustPassword(this.config.getTrustPassword());
+        }
+        
+        if ("wants".equals(this.config.getClientcert())) {
+            connector.setWantClientAuth(true);
+        } else if ("needs".equals(this.config.getClientcert())) {
+            connector.setNeedClientAuth(true);
+        }
+
+        this.server.addConnector(connector);
+    }
+
+    public void run()
+    {
+        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+
+        while (this.running) {
+            initializeJettyLogger();
+            startJetty();
+
+            synchronized (this) {
+                try {
+                    wait();
+                } catch (InterruptedException e) {
+                    // we will definitely be interrupted
+                }
+            }
+
+            stopJetty();
+            destroyJettyLogger();
+        }
+    }
+}

Added: felix/trunk/http/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/pom.xml?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/pom.xml (added)
+++ felix/trunk/http/pom.xml Mon Sep 14 09:59:12 2009
@@ -0,0 +1,123 @@
+<!--
+    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">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>felix-parent</artifactId>
+        <version>1.2.0</version>
+    </parent>
+
+    <artifactId>org.apache.felix.http</artifactId>
+    <packaging>pom</packaging>
+    <name>Apache Felix Http</name>
+    <version>2.0.0-SNAPSHOT</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    </properties>
+
+    <build>
+            <plugins>
+                <plugin>
+                    <artifactId>maven-compiler-plugin</artifactId>
+                    <configuration>
+                        <source>1.5</source>
+                        <target>1.5</target>
+                        <compilerVersion>1.5</compilerVersion>
+                    </configuration>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.felix</groupId>
+                    <artifactId>maven-bundle-plugin</artifactId>
+                    <version>2.0.0</version>
+                    <extensions>true</extensions>
+                    <configuration>
+                        <instructions>
+                            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                            <Bundle-Version>${pom.version}</Bundle-Version>
+                        </instructions>
+                    </configuration>
+                </plugin>
+            </plugins>
+    </build>
+
+    <modules>
+        <module>api</module>
+        <module>base</module>
+        <module>bridge</module>
+        <module>jetty</module>
+        <module>proxy</module>
+        <module>whiteboard</module>
+        <module>bundle</module>
+        <module>samples/filter</module>
+        <module>samples/bridge</module>
+        <module>samples/whiteboard</module>
+    </modules>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.8.0</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>javax.servlet</groupId>
+                <artifactId>servlet-api</artifactId>
+                <version>2.5</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>org.osgi.core</artifactId>
+                <version>1.2.0</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>org.osgi.foundation</artifactId>
+                <version>1.2.0</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>org.osgi.compendium</artifactId>
+                <version>1.2.0</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>org.apache.felix</groupId>
+                        <artifactId>javax.servlet</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+</project>

Added: felix/trunk/http/proxy/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/proxy/pom.xml?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/proxy/pom.xml (added)
+++ felix/trunk/http/proxy/pom.xml Mon Sep 14 09:59:12 2009
@@ -0,0 +1,47 @@
+<!--
+    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">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.http</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <name>Apache Felix Http Proxy</name>
+    <artifactId>org.apache.felix.http.proxy</artifactId>
+    <packaging>jar</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+</project>

Added: felix/trunk/http/proxy/src/main/java/org/apache/felix/http/proxy/DispatcherTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/proxy/src/main/java/org/apache/felix/http/proxy/DispatcherTracker.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/proxy/src/main/java/org/apache/felix/http/proxy/DispatcherTracker.java (added)
+++ felix/trunk/http/proxy/src/main/java/org/apache/felix/http/proxy/DispatcherTracker.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,112 @@
+/*
+ * 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.proxy;
+
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Filter;
+import org.osgi.framework.Constants;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.ServletConfig;
+
+public final class DispatcherTracker
+    extends ServiceTracker
+{
+    private final static String DEFAULT_FILTER = "(http.felix.dispatcher=*)";
+
+    private final ServletConfig config;
+    private HttpServlet dispatcher;
+    
+    public DispatcherTracker(BundleContext context, String filter, ServletConfig config)
+        throws Exception
+    {
+        super(context, createFilter(context, filter), null);
+        this.config = config;
+    }
+
+    public HttpServlet getDispatcher()
+    {
+        return this.dispatcher;
+    }
+
+    @Override
+    public Object addingService(ServiceReference ref)
+    {
+        Object service = super.addingService(ref);
+        if (service instanceof HttpServlet) {
+            setDispatcher((HttpServlet)service);
+        }
+
+        return service;
+    }
+
+    @Override
+    public void removedService(ServiceReference ref, Object service)
+    {
+        if (service instanceof HttpServlet) {
+            setDispatcher(null);
+        }
+
+        super.removedService(ref, service);
+    }
+
+    private void log(String message, Throwable cause)
+    {
+        this.config.getServletContext().log(message, cause);
+    }
+
+    private void setDispatcher(HttpServlet dispatcher)
+    {
+        destroyDispatcher();
+        this.dispatcher = dispatcher;
+        initDispatcher();
+    }
+
+    private void destroyDispatcher()
+    {
+        if (this.dispatcher == null) {
+            return;
+        }
+
+        this.dispatcher.destroy();
+        this.dispatcher = null;
+    }
+
+    private void initDispatcher()
+    {
+        if (this.dispatcher == null) {
+            return;
+        }
+
+        try {
+            this.dispatcher.init(this.config);
+        } catch (Exception e) {
+            log("Failed to initialize dispatcher", e);
+        }
+    }
+
+    private static Filter createFilter(BundleContext context, String filter)
+        throws Exception
+    {
+        StringBuffer str = new StringBuffer();
+        str.append("(&(").append(Constants.OBJECTCLASS).append("=");
+        str.append(HttpServlet.class.getName()).append(")");
+        str.append(filter != null ? filter : DEFAULT_FILTER).append(")");
+        return context.createFilter(str.toString());
+    }
+}

Added: felix/trunk/http/proxy/src/main/java/org/apache/felix/http/proxy/ProxyServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/proxy/src/main/java/org/apache/felix/http/proxy/ProxyServlet.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/proxy/src/main/java/org/apache/felix/http/proxy/ProxyServlet.java (added)
+++ felix/trunk/http/proxy/src/main/java/org/apache/felix/http/proxy/ProxyServlet.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,84 @@
+/*
+ * 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.proxy;
+
+import org.osgi.framework.BundleContext;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import javax.servlet.ServletConfig;
+import java.io.IOException;
+
+public final class ProxyServlet
+    extends HttpServlet
+{
+    private DispatcherTracker tracker;
+
+    @Override
+    public void init(ServletConfig config)
+        throws ServletException
+    {
+        super.init(config);
+
+        try {
+            doInit();
+        } catch (ServletException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new ServletException(e);
+        }
+    }
+
+    private void doInit()
+        throws Exception
+    {
+        this.tracker = new DispatcherTracker(getBundleContext(), null, getServletConfig());
+        this.tracker.open();
+    }
+
+    @Override
+    protected void service(HttpServletRequest req, HttpServletResponse res)
+        throws ServletException, IOException
+    {
+        HttpServlet dispatcher = this.tracker.getDispatcher();
+        if (dispatcher != null) {
+            dispatcher.service(req, res);
+        } else {
+            res.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
+        }
+    }
+
+    @Override
+    public void destroy()
+    {
+        this.tracker.close();
+        super.destroy();
+    }
+
+    private BundleContext getBundleContext()
+        throws ServletException
+    {
+        Object context = getServletContext().getAttribute(BundleContext.class.getName());
+        if (context instanceof BundleContext) {
+            return (BundleContext)context;
+        }
+
+        throw new ServletException("Bundle context attribute [" + BundleContext.class.getName() +
+                "] not set in servlet context");
+    }
+}

Added: felix/trunk/http/samples/bridge/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/bridge/pom.xml?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/bridge/pom.xml (added)
+++ felix/trunk/http/samples/bridge/pom.xml Mon Sep 14 09:59:12 2009
@@ -0,0 +1,118 @@
+<!--
+    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">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.http</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <name>Apache Felix Http Samples - Bridge</name>
+    <artifactId>org.apache.felix.http.samples.bridge</artifactId>
+    <packaging>war</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.mortbay.jetty</groupId>
+                <artifactId>maven-jetty-plugin</artifactId>
+                <version>6.1.10</version>
+                <configuration>
+                    <contextPath>/</contextPath>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-bundles</id>
+                        <goals>
+                            <goal>copy</goal>
+                        </goals>
+                        <configuration>
+                            <artifactItems>
+                                <artifactItem>
+                                    <groupId>org.apache.felix</groupId>
+                                    <artifactId>org.apache.felix.http.bundle</artifactId>
+                                    <version>${pom.version}</version>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.apache.felix</groupId>
+                                    <artifactId>org.apache.felix.http.samples.filter</artifactId>
+                                    <version>${pom.version}</version>
+                                </artifactItem>
+                                <artifactItem>
+                                    <groupId>org.apache.felix</groupId>
+                                    <artifactId>org.apache.felix.webconsole</artifactId>
+                                    <version>1.2.8</version>
+                                </artifactItem>
+                            </artifactItems>
+                            <stripVersion>true</stripVersion>
+                            <outputDirectory>
+                                ${project.build.directory}/bundles
+                            </outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-war-plugin</artifactId>
+                <configuration>
+                    <webResources>
+                        <resource>
+                            <directory>
+                                ${project.build.directory}/bundles
+                            </directory>
+                            <targetPath>WEB-INF/bundles</targetPath>
+                        </resource>
+                    </webResources>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.framework</artifactId>
+            <version>1.8.1</version>
+        </dependency>
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>org.apache.felix.http.proxy</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+    </dependencies>
+
+</project>

Added: felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/FrameworkService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/FrameworkService.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/FrameworkService.java (added)
+++ felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/FrameworkService.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,93 @@
+/*
+ * 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.samples.bridge;
+
+import org.apache.felix.framework.Felix;
+import org.apache.felix.framework.util.FelixConstants;
+import javax.servlet.ServletContext;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Arrays;
+
+public final class FrameworkService
+{
+    private final ServletContext context;
+    private Felix felix;
+
+    public FrameworkService(ServletContext context)
+    {
+        this.context = context;
+    }
+
+    public void start()
+    {
+        try {
+            doStart();
+        } catch (Exception e) {
+            log("Failed to start framework", e);
+        }
+    }
+
+    public void stop()
+    {
+        try {
+            doStop();
+        } catch (Exception e) {
+            log("Error stopping framework", e);
+        }
+    }
+
+    private void doStart()
+        throws Exception
+    {
+        Felix tmp = new Felix(createConfig());
+        tmp.start();
+        this.felix = tmp;
+        log("OSGi framework started", null);
+    }
+
+    private void doStop()
+        throws Exception
+    {
+        if (this.felix != null) {
+            this.felix.stop();
+        }
+
+        log("OSGi framework stopped", null);
+    }
+
+    private Map<String, Object> createConfig()
+        throws Exception
+    {
+        Properties props = new Properties();
+        props.load(this.context.getResourceAsStream("/WEB-INF/framework.properties"));
+
+        HashMap<String, Object> map = new HashMap<String, Object>();
+        for (Object key : props.keySet()) {
+            map.put(key.toString(), props.get(key));
+        }
+        
+        map.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, Arrays.asList(new ProvisionActivator(this.context)));
+        return map;
+    }
+
+    private void log(String message, Throwable cause)
+    {
+        this.context.log(message, cause);
+    }
+}

Added: felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/ProvisionActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/ProvisionActivator.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/ProvisionActivator.java (added)
+++ felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/ProvisionActivator.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,75 @@
+/*
+ * 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.samples.bridge;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Bundle;
+import javax.servlet.ServletContext;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+public final class ProvisionActivator
+    implements BundleActivator
+{
+    private final ServletContext servletContext;
+
+    public ProvisionActivator(ServletContext servletContext)
+    {
+        this.servletContext = servletContext;
+    }
+
+    public void start(BundleContext context)
+        throws Exception
+    {
+        servletContext.setAttribute(BundleContext.class.getName(), context);
+
+        ArrayList<Bundle> installed = new ArrayList<Bundle>();
+        for (URL url : findBundles()) {
+            this.servletContext.log("Installing bundle [" + url + "]");
+            Bundle bundle = context.installBundle(url.toExternalForm());
+            installed.add(bundle);
+        }
+
+        for (Bundle bundle : installed) {
+            bundle.start();
+        }
+    }
+
+    public void stop(BundleContext context)
+        throws Exception
+    {
+    }
+
+    private List<URL> findBundles()
+        throws Exception
+    {
+        ArrayList<URL> list = new ArrayList<URL>();
+        for (Object o : this.servletContext.getResourcePaths("/WEB-INF/bundles/")) {
+            String name = (String)o;
+            if (name.endsWith(".jar")) {
+                URL url = this.servletContext.getResource(name);
+                if (url != null) {
+                    list.add(url);
+                }
+            }
+        }
+
+        return list;
+    }
+}

Added: felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/StartupListener.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/StartupListener.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/StartupListener.java (added)
+++ felix/trunk/http/samples/bridge/src/main/java/org/apache/felix/http/samples/bridge/StartupListener.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,37 @@
+/*
+ * 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.samples.bridge;
+
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+
+public final class StartupListener
+    implements ServletContextListener
+{
+    private FrameworkService service;
+
+    public void contextInitialized(ServletContextEvent event)
+    {
+        this.service = new FrameworkService(event.getServletContext());
+        this.service.start();
+    }
+
+    public void contextDestroyed(ServletContextEvent event)
+    {
+        this.service.stop();
+    }
+}

Added: felix/trunk/http/samples/bridge/src/main/webapp/WEB-INF/framework.properties
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/bridge/src/main/webapp/WEB-INF/framework.properties?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/bridge/src/main/webapp/WEB-INF/framework.properties (added)
+++ felix/trunk/http/samples/bridge/src/main/webapp/WEB-INF/framework.properties Mon Sep 14 09:59:12 2009
@@ -0,0 +1,162 @@
+org.osgi.framework.storage.clean = onFirstInit
+
+org.osgi.framework.system.packages = \
+   org.osgi.framework; version=1.4.0, \
+   org.osgi.framework.hooks.service, \
+   org.osgi.framework.launch, \
+   org.osgi.service.condpermadmin; version=1.0.0, \
+   org.osgi.service.packageadmin; version=1.2.0, \
+   org.osgi.service.permissionadmin; version=1.2.0, \
+   org.osgi.service.startlevel; version=1.1.0, \
+   org.osgi.service.url; version=1.0.0,\
+ org.osgi.service.application;version="1.0", \
+ org.osgi.service.cm;version="1.2", \
+ org.osgi.service.component;version="1.0", \
+ org.osgi.service.deploymentadmin;version="1.0", \
+ org.osgi.service.deploymentadmin.spi;uses:="org.osgi.service.deploymentadmin";version="1.0", \
+ org.osgi.service.device;version="1.1", \
+ org.osgi.service.event;version="1.1", \
+ org.osgi.service.http;version="1.2", \
+ org.osgi.service.io;version="1.0", \
+ org.osgi.service.log;version="1.3", \
+ org.osgi.service.metatype;version="1.1", \
+ org.osgi.service.monitor;version="1.0", \
+ org.osgi.service.prefs;version="1.1", \
+ org.osgi.service.provisioning;version="1.1", \
+ org.osgi.service.upnp;version="1.1", \
+ org.osgi.service.useradmin;version="1.1", \
+ org.osgi.service.wireadmin;version="1.0", \
+ info.dmtree.notification;version="1.0", \
+ info.dmtree.notification.spi;uses:="info.dmtree.notification";version="1.0", \
+ info.dmtree.registry;uses:="info.dmtree.notification";version="1.0", \
+ info.dmtree.security;version="1.0", \
+ info.dmtree.spi;version="1.0", \
+ org.osgi.util.gsm;version="1.0", \
+ org.osgi.util.measurement;version="1.0", \
+ org.osgi.util.mobile;version="1.0", \
+ org.osgi.util.position;uses:="org.osgi.util.measurement";version="1.0", \
+ org.osgi.util.tracker;version="1.3.3", \
+ org.osgi.util.xml;version="1.0",\
+ javax.accessibility,\
+ javax.activity,\
+ javax.crypto,\
+ javax.crypto.interfaces,\
+ javax.crypto.spec,\
+ javax.imageio,\
+ javax.imageio.event,\
+ javax.imageio.metadata,\
+ javax.imageio.plugins.bmp,\
+ javax.imageio.plugins.jpeg,\
+ javax.imageio.spi,\
+ javax.imageio.stream,\
+ javax.management,\
+ javax.management.loading,\
+ javax.management.modelmbean,\
+ javax.management.monitor,\
+ javax.management.openmbean,\
+ javax.management.relation,\
+ javax.management.remote,\
+ javax.management.remote.rmi,\
+ javax.management.timer,\
+ javax.naming,\
+ javax.naming.directory,\
+ javax.naming.event,\
+ javax.naming.ldap,\
+ javax.naming.spi,\
+ javax.net,\
+ javax.net.ssl,\
+ javax.print,\
+ javax.print.attribute,\
+ javax.print.attribute.standard,\
+ javax.print.event,\
+ javax.rmi,\
+ javax.rmi.CORBA,\
+ javax.rmi.ssl,\
+ javax.security.auth,\
+ javax.security.auth.callback,\
+ javax.security.auth.kerberos,\
+ javax.security.auth.login,\
+ javax.security.auth.spi,\
+ javax.security.auth.x500,\
+ javax.security.cert,\
+ javax.security.sasl,\
+ javax.sound.midi,\
+ javax.sound.midi.spi,\
+ javax.sound.sampled,\
+ javax.sound.sampled.spi,\
+ javax.sql,\
+ javax.sql.rowset,\
+ javax.sql.rowset.serial,\
+ javax.sql.rowset.spi,\
+ javax.swing,\
+ javax.swing.border,\
+ javax.swing.colorchooser,\
+ javax.swing.event,\
+ javax.swing.filechooser,\
+ javax.swing.plaf,\
+ javax.swing.plaf.basic,\
+ javax.swing.plaf.metal,\
+ javax.swing.plaf.multi,\
+ javax.swing.plaf.synth,\
+ javax.swing.table,\
+ javax.swing.text,\
+ javax.swing.text.html,\
+ javax.swing.text.html.parser,\
+ javax.swing.text.rtf,\
+ javax.swing.tree,\
+ javax.swing.undo,\
+ javax.transaction,\
+ javax.transaction.xa,\
+ javax.xml,\
+ javax.xml.datatype,\
+ javax.xml.namespace,\
+ javax.xml.parsers,\
+ javax.xml.transform,\
+ javax.xml.transform.dom,\
+ javax.xml.transform.sax,\
+ javax.xml.transform.stream,\
+ javax.xml.validation,\
+ javax.xml.xpath,\
+ org.ietf.jgss,\
+ org.omg.CORBA,\
+ org.omg.CORBA_2_3,\
+ org.omg.CORBA_2_3.portable,\
+ org.omg.CORBA.DynAnyPackage,\
+ org.omg.CORBA.ORBPackage,\
+ org.omg.CORBA.portable,\
+ org.omg.CORBA.TypeCodePackage,\
+ org.omg.CosNaming,\
+ org.omg.CosNaming.NamingContextExtPackage,\
+ org.omg.CosNaming.NamingContextPackage,\
+ org.omg.Dynamic,\
+ org.omg.DynamicAny,\
+ org.omg.DynamicAny.DynAnyFactoryPackage,\
+ org.omg.DynamicAny.DynAnyPackage,\
+ org.omg.IOP,\
+ org.omg.IOP.CodecFactoryPackage,\
+ org.omg.IOP.CodecPackage,\
+ org.omg.Messaging,\
+ org.omg.PortableInterceptor,\
+ org.omg.PortableInterceptor.ORBInitInfoPackage,\
+ org.omg.PortableServer,\
+ org.omg.PortableServer.CurrentPackage,\
+ org.omg.PortableServer.POAManagerPackage,\
+ org.omg.PortableServer.POAPackage,\
+ org.omg.PortableServer.portable,\
+ org.omg.PortableServer.ServantLocatorPackage,\
+ org.omg.SendingContext,\
+ org.omg.stub.java.rmi,\
+ org.w3c.dom,\
+ org.w3c.dom.bootstrap,\
+ org.w3c.dom.css,\
+ org.w3c.dom.events,\
+ org.w3c.dom.html,\
+ org.w3c.dom.ls,\
+ org.w3c.dom.ranges,\
+ org.w3c.dom.stylesheets,\
+ org.w3c.dom.traversal,\
+ org.w3c.dom.views,\
+ org.xml.sax,\
+ org.xml.sax.ext,\
+ org.xml.sax.helpers,\
+ javax.servlet;javax.servlet.http;version=2.5

Added: felix/trunk/http/samples/bridge/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/bridge/src/main/webapp/WEB-INF/web.xml?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/bridge/src/main/webapp/WEB-INF/web.xml (added)
+++ felix/trunk/http/samples/bridge/src/main/webapp/WEB-INF/web.xml Mon Sep 14 09:59:12 2009
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+    "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+
+    <listener>
+        <listener-class>org.apache.felix.http.samples.bridge.StartupListener</listener-class>
+    </listener>
+
+    <servlet>
+        <servlet-name>proxy</servlet-name>
+        <servlet-class>org.apache.felix.http.proxy.ProxyServlet</servlet-class>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>proxy</servlet-name>
+        <url-pattern>/*</url-pattern>
+    </servlet-mapping>
+
+</web-app>

Added: felix/trunk/http/samples/filter/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/filter/pom.xml?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/filter/pom.xml (added)
+++ felix/trunk/http/samples/filter/pom.xml Mon Sep 14 09:59:12 2009
@@ -0,0 +1,75 @@
+<!--
+    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">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.http</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <name>Apache Felix Http Samples - Filter</name>
+    <artifactId>org.apache.felix.http.samples.filter</artifactId>
+    <packaging>bundle</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>
+                            org.apache.felix.http.samples.filter.Activator
+                        </Bundle-Activator>
+                        <Private-Package>
+                            org.apache.felix.http.samples.filter.*
+                        </Private-Package>
+                        <Import-Package>
+                            *;resolution:=optional
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>org.apache.felix.http.api</artifactId>
+            <version>${pom.version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+</project>

Added: felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/Activator.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/Activator.java (added)
+++ felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/Activator.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,83 @@
+/*
+ * 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.samples.filter;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.apache.felix.http.api.ExtHttpService;
+
+public final class Activator
+    implements BundleActivator
+{
+    private ServiceTracker tracker;
+    private TestServlet servlet1 = new TestServlet("servlet1");
+    private TestServlet servlet2 = new TestServlet("servlet2");
+    private TestFilter filter1 = new TestFilter("filter1");
+    private TestFilter filter2 = new TestFilter("filter2");
+
+    public void start(BundleContext context)
+        throws Exception
+    {
+        this.tracker = new ServiceTracker(context, ExtHttpService.class.getName(), null)
+        {
+            @Override
+            public Object addingService(ServiceReference ref)
+            {
+                Object service =  super.addingService(ref);
+                serviceAdded((ExtHttpService)service);
+                return service;
+            }
+
+            @Override
+            public void removedService(ServiceReference ref, Object service)
+            {
+                serviceRemoved((ExtHttpService)service);
+                super.removedService(ref, service);
+            }
+        };
+
+        this.tracker.open();
+    }
+
+    public void stop(BundleContext context)
+        throws Exception
+    {
+        this.tracker.close();
+    }
+
+    private void serviceAdded(ExtHttpService service)
+    {
+        try {
+            service.registerServlet("/", this.servlet1, null, null);
+            service.registerServlet("/other", this.servlet2, null, null);
+            service.registerFilter(this.filter1, ".*", null, 0, null);
+            service.registerFilter(this.filter2, "/other/.*", null, 100, null);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void serviceRemoved(ExtHttpService service)
+    {
+        service.unregisterServlet(this.servlet1);
+        service.unregisterServlet(this.servlet2);
+        service.unregisterFilter(this.filter1);
+        service.unregisterFilter(this.filter2);
+    }
+}

Added: felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/TestFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/TestFilter.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/TestFilter.java (added)
+++ felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/TestFilter.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,54 @@
+/*
+ * 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.samples.filter;
+
+import javax.servlet.*;
+import java.io.IOException;
+
+public class TestFilter
+    implements Filter
+{
+    private final String name;
+
+    public TestFilter(String name)
+    {
+        this.name = name;
+    }
+    
+    public void init(FilterConfig config)
+        throws ServletException
+    {
+        doLog("Init with config [" + config + "]");
+    }
+
+    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
+        throws IOException, ServletException
+    {
+        doLog("Filter request [" + req + "]");
+        chain.doFilter(req, res);
+    }
+
+    public void destroy()
+    {
+        doLog("Destroyed filter");
+    }
+
+    private void doLog(String message)
+    {
+        System.out.println("## [" + this.name + "] " + message);
+    }
+}

Added: felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/TestServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/TestServlet.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/TestServlet.java (added)
+++ felix/trunk/http/samples/filter/src/main/java/org/apache/felix/http/samples/filter/TestServlet.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,67 @@
+/*
+ * 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.samples.filter;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class TestServlet
+    extends HttpServlet
+{
+    private final String name;
+
+    public TestServlet(String name)
+    {
+        this.name = name;
+    }
+    
+    @Override
+    public void init(ServletConfig config)
+        throws ServletException
+    {
+        doLog("Init with config [" + config + "]");
+        super.init(config);  
+    }
+
+    @Override
+    public void destroy()
+    {
+        doLog("Destroyed servlet");
+        super.destroy();
+    }
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse res)
+        throws ServletException, IOException
+    {
+        res.setContentType("text/plain");
+        PrintWriter out = res.getWriter();
+
+        out.println("Request = " + req);
+        out.println("PathInfo = " + req.getPathInfo());
+    }
+
+    private void doLog(String message)
+    {
+        System.out.println("## [" + this.name + "] " + message);
+    }
+}

Added: felix/trunk/http/samples/whiteboard/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/whiteboard/pom.xml?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/whiteboard/pom.xml (added)
+++ felix/trunk/http/samples/whiteboard/pom.xml Mon Sep 14 09:59:12 2009
@@ -0,0 +1,69 @@
+<!--
+    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">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.http</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <name>Apache Felix Http Samples - Whiteboard</name>
+    <artifactId>org.apache.felix.http.samples.whiteboard</artifactId>
+    <packaging>bundle</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>
+                            org.apache.felix.http.samples.whiteboard.Activator
+                        </Bundle-Activator>
+                        <Private-Package>
+                            org.apache.felix.http.samples.whiteboard.*
+                        </Private-Package>
+                        <Import-Package>
+                            *;resolution:=optional
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+</project>

Added: felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/Activator.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/Activator.java (added)
+++ felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/Activator.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.samples.whiteboard;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import javax.servlet.Servlet;
+import javax.servlet.Filter;
+import java.util.Hashtable;
+
+public final class Activator
+    implements BundleActivator
+{
+    private ServiceRegistration reg1;
+    private ServiceRegistration reg2;
+    private ServiceRegistration reg3;
+    private ServiceRegistration reg4;
+    
+    public void start(BundleContext context)
+        throws Exception
+    {
+        Hashtable<String, String> props = new Hashtable<String, String>();
+        props.put("alias", "/");
+        this.reg1 = context.registerService(Servlet.class.getName(), new TestServlet("servlet1"), props);
+
+        props = new Hashtable<String, String>();
+        props.put("alias", "/other");
+        this.reg2 = context.registerService(Servlet.class.getName(), new TestServlet("servlet2"), props);
+
+        props = new Hashtable<String, String>();
+        props.put("pattern", ".*");
+        this.reg3 = context.registerService(Filter.class.getName(), new TestFilter("filter1"), props);
+
+        props = new Hashtable<String, String>();
+        props.put("pattern", "/other/.*");
+        props.put("service.ranking", "100");
+        this.reg4 = context.registerService(Filter.class.getName(), new TestFilter("filter2"), props);
+    }
+
+    public void stop(BundleContext context)
+        throws Exception
+    {
+        this.reg1.unregister();
+        this.reg2.unregister();
+        this.reg3.unregister();
+        this.reg4.unregister();
+    }
+}

Added: felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/TestFilter.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/TestFilter.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/TestFilter.java (added)
+++ felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/TestFilter.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,54 @@
+/*
+ * 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.samples.whiteboard;
+
+import javax.servlet.*;
+import java.io.IOException;
+
+public class TestFilter
+    implements Filter
+{
+    private final String name;
+
+    public TestFilter(String name)
+    {
+        this.name = name;
+    }
+
+    public void init(FilterConfig config)
+        throws ServletException
+    {
+        doLog("Init with config [" + config + "]");
+    }
+
+    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
+        throws IOException, ServletException
+    {
+        doLog("Filter request [" + req + "]");
+        chain.doFilter(req, res);
+    }
+
+    public void destroy()
+    {
+        doLog("Destroyed filter");
+    }
+
+    private void doLog(String message)
+    {
+        System.out.println("## [" + this.name + "] " + message);
+    }
+}
\ No newline at end of file

Added: felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/TestServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/TestServlet.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/TestServlet.java (added)
+++ felix/trunk/http/samples/whiteboard/src/main/java/org/apache/felix/http/samples/whiteboard/TestServlet.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,67 @@
+/*
+ * 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.samples.whiteboard;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class TestServlet
+    extends HttpServlet
+{
+    private final String name;
+
+    public TestServlet(String name)
+    {
+        this.name = name;
+    }
+
+    @Override
+    public void init(ServletConfig config)
+        throws ServletException
+    {
+        doLog("Init with config [" + config + "]");
+        super.init(config);
+    }
+
+    @Override
+    public void destroy()
+    {
+        doLog("Destroyed servlet");
+        super.destroy();
+    }
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse res)
+        throws ServletException, IOException
+    {
+        res.setContentType("text/plain");
+        PrintWriter out = res.getWriter();
+
+        out.println("Request = " + req);
+        out.println("PathInfo = " + req.getPathInfo());
+    }
+
+    private void doLog(String message)
+    {
+        System.out.println("## [" + this.name + "] " + message);
+    }
+}
\ No newline at end of file

Added: felix/trunk/http/whiteboard/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/pom.xml?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/whiteboard/pom.xml (added)
+++ felix/trunk/http/whiteboard/pom.xml Mon Sep 14 09:59:12 2009
@@ -0,0 +1,77 @@
+<!--
+    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">
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>org.apache.felix.http</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <name>Apache Felix Http Whiteboard</name>
+    <artifactId>org.apache.felix.http.whiteboard</artifactId>
+    <packaging>bundle</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>
+                            org.apache.felix.http.whiteboard.internal.WhiteboardActivator
+                        </Bundle-Activator>
+                        <Private-Package>
+                            org.apache.felix.http.whiteboard.*
+                        </Private-Package>
+                        <Import-Package>
+                            javax.servlet.*,
+                            org.osgi.service.http.*,
+                            *;resolution:=optional
+                        </Import-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>org.apache.felix.http.api</artifactId>
+            <version>${pom.version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+</project>

Added: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java (added)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,70 @@
+/*
+ * 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.whiteboard.internal;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+import org.apache.felix.http.whiteboard.internal.tracker.FilterTracker;
+import org.apache.felix.http.whiteboard.internal.tracker.HttpContextTracker;
+import org.apache.felix.http.whiteboard.internal.tracker.ServletTracker;
+import org.apache.felix.http.whiteboard.internal.tracker.HttpServiceTracker;
+import org.apache.felix.http.whiteboard.internal.manager.ExtenderManagerImpl;
+import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
+import org.apache.felix.http.whiteboard.internal.util.SystemLogger;
+import java.util.ArrayList;
+
+public final class WhiteboardActivator
+    implements BundleActivator
+{
+    private final ArrayList<ServiceTracker> trackers;
+    private ExtenderManager manager;
+
+    public WhiteboardActivator()
+    {
+        this.trackers = new ArrayList<ServiceTracker>();
+    }
+
+    public void start(BundleContext context)
+        throws Exception
+    {
+        SystemLogger.get().open(context);
+        this.manager = new ExtenderManagerImpl();
+        addTracker(new HttpContextTracker(context, this.manager));
+        addTracker(new FilterTracker(context, this.manager));
+        addTracker(new ServletTracker(context, this.manager));
+        addTracker(new HttpServiceTracker(context, this.manager));
+    }
+
+    private void addTracker(ServiceTracker tracker)
+    {
+        this.trackers.add(tracker);
+        tracker.open();
+    }
+
+    public void stop(BundleContext context)
+        throws Exception
+    {
+        for (ServiceTracker tracker : this.trackers) {
+            tracker.close();
+        }
+
+        this.trackers.clear();
+        this.manager.unregisterAll();
+        SystemLogger.get().close();
+    }
+}

Added: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/AbstractMapping.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/AbstractMapping.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/AbstractMapping.java (added)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/AbstractMapping.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.whiteboard.internal.manager;
+
+import org.osgi.service.http.HttpContext;
+import org.osgi.service.http.HttpService;
+import java.util.Hashtable;
+
+public abstract class AbstractMapping
+{
+    private final HttpContext context;
+    private final Hashtable<String, String> initParams;
+
+    public AbstractMapping(HttpContext context)
+    {
+        this.context = context;
+        this.initParams = new Hashtable<String, String>();
+    }
+
+    public final HttpContext getContext()
+    {
+        return this.context;
+    }
+
+    public final Hashtable<String, String> getInitParams()
+    {
+        return this.initParams;
+    }
+
+    public abstract void register(HttpService httpService);
+
+    public abstract void unregister(HttpService httpService);
+}

Added: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/DefaultHttpContext.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/DefaultHttpContext.java?rev=814549&view=auto
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/DefaultHttpContext.java (added)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/DefaultHttpContext.java Mon Sep 14 09:59:12 2009
@@ -0,0 +1,53 @@
+/*
+ * 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.whiteboard.internal.manager;
+
+import org.osgi.service.http.HttpContext;
+import org.osgi.framework.Bundle;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URL;
+
+public final class DefaultHttpContext 
+    implements HttpContext
+{
+    private Bundle bundle;
+
+    public DefaultHttpContext(Bundle bundle)
+    {
+        this.bundle = bundle;
+    }
+
+    public String getMimeType(String name)
+    {
+        return null;
+    }
+
+    public URL getResource(String name)
+    {
+        if (name.startsWith("/")) {
+            name = name.substring(1);
+        }
+
+        return this.bundle.getResource(name);
+    }
+
+    public boolean handleSecurity(HttpServletRequest req, HttpServletResponse res)
+    {
+        return true;
+    }
+}
\ No newline at end of file