SLING-865 : Move to bundles

git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk@746693 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,202 @@
+
+                                 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/NOTICE b/NOTICE
new file mode 100644
index 0000000..255444e
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,9 @@
+Apache Sling Bundle Resource Provider
+Copyright 2008-2009 The Apache Software Foundation
+
+Apache Sling is based on source code originally developed 
+by Day Software (http://www.day.com/).
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..480d767
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,38 @@
+Apache Sling Bundle Resource Provider
+
+Provides a ResourceProvider implementation supporting bundle
+based resources.
+
+Disclaimer
+==========
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
+
+Getting Started
+===============
+
+This component uses a Maven 2 (http://maven.apache.org/) build
+environment. It requires a Java 5 JDK (or higher) and Maven (http://maven.apache.org/)
+2.0.7 or later. We recommend to use the latest Maven version.
+
+If you have Maven 2 installed, you can compile and
+package the jar using the following command:
+
+    mvn package
+
+See the Maven 2 documentation for other build features.
+
+The latest source code for this component is available in the
+Subversion (http://subversion.tigris.org/) source repository of
+the Apache Software Foundation. If you have Subversion installed,
+you can checkout the latest source using the following command:
+
+    svn checkout http://svn.apache.org/repos/asf/incubator/sling/trunk/extensions/bundleresource
+
+See the Subversion documentation for other source control features.
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..a305122
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    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.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>5-incubator-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.bundleresource.impl</artifactId>
+    <packaging>bundle</packaging>
+    <version>2.0.3-incubator-SNAPSHOT</version>
+
+    <name>Apache Sling Bundle Resource Provider</name>
+    <description>
+        Provides a ResourceProvider implementation supporting bundle
+        based resources.
+    </description>
+
+    <scm>
+        <connection>
+            scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/extensions/bundleresource
+        </connection>
+        <developerConnection>
+            scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/extensions/bundleresource
+        </developerConnection>
+        <url>
+            http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/bundleresource
+        </url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Activator>
+                            org.apache.sling.bundleresource.impl.Activator
+                        </Bundle-Activator>
+                        <Private-Package>
+                            org.apache.sling.bundleresource.*,
+                            org.osgi.util.tracker
+                        </Private-Package>
+                        <DynamicImport-Package>
+                            org.apache.felix.webconsole
+                        </DynamicImport-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <excludePackageNames>
+                        org.apache.sling.bundleresource
+                    </excludePackageNames>
+                </configuration>
+            </plugin>
+        </plugins>
+    </reporting>
+    <dependencies>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.0.2-incubator</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.jcr.resource</artifactId>
+            <version>2.0.2-incubator</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.webconsole</artifactId>
+            <version>1.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/Activator.java b/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
new file mode 100644
index 0000000..33e7a60
--- /dev/null
+++ b/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
@@ -0,0 +1,176 @@
+/*
+ * 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.sling.bundleresource.impl;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class Activator implements BundleActivator, BundleListener {
+
+    /**
+     * The name of the bundle manifest header listing the resource provider root
+     * paths provided by the bundle (value is "Sling-Bundle-Resources").
+     */
+    public static final String BUNDLE_RESOURCE_ROOTS = "Sling-Bundle-Resources";
+
+    /**
+     * Fully qualified name of the Web Console Plugin class. This class will be
+     * loaded dynamically to prevent issues if the Felix Web Console is not
+     * installed in the system (value is
+     * "org.apache.sling.bundleresource.impl.BundleResourceWebConsolePlugin").
+     */
+    private static final String CONSOLE_PLUGIN_CLASS = "org.apache.sling.bundleresource.impl.BundleResourceWebConsolePlugin";
+
+    /**
+     * Name of the initialization method to call on the Web Console Plugin class
+     * (value is "initPlugin").
+     */
+    private static final String METHOD_INIT = "initPlugin";
+
+    /**
+     * Name of the shutdown method to call on the Web Console Plugin class
+     * (value is "destroyPlugin").
+     */
+    private static final String METHOD_DESTROY = "destroyPlugin";
+
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private Map<Long, BundleResourceProvider> bundleResourceProviderMap = new HashMap<Long, BundleResourceProvider>();
+
+    private BundleContext bundleContext;
+
+    public void start(BundleContext context) throws Exception {
+
+        this.bundleContext = context;
+
+        context.addBundleListener(this);
+
+        try {
+            Bundle[] bundles = context.getBundles();
+            for (Bundle bundle : bundles) {
+                if (bundle.getState() == Bundle.ACTIVE) {
+                    // add bundle resource provider for active bundles
+                    addBundleResourceProvider(bundle);
+                }
+            }
+        } catch (Throwable t) {
+            log.error(
+                "activate: Problem while registering bundle resources for existing bundles",
+                t);
+        }
+
+        // hackery thing to prevent problems if the web console is not present
+        callMethod(CONSOLE_PLUGIN_CLASS, METHOD_INIT,
+            new Class<?>[] { BundleContext.class }, new Object[] { context });
+
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        // hackery thing to prevent problems if the web console is not present
+        callMethod(CONSOLE_PLUGIN_CLASS, METHOD_DESTROY, null, null);
+
+        context.removeBundleListener(this);
+        this.bundleContext = null;
+    }
+
+    /**
+     * Loads and unloads any components provided by the bundle whose state
+     * changed. If the bundle has been started, the components are loaded. If
+     * the bundle is about to stop, the components are unloaded.
+     * 
+     * @param event The <code>BundleEvent</code> representing the bundle state
+     *            change.
+     */
+    public void bundleChanged(BundleEvent event) {
+        switch (event.getType()) {
+            case BundleEvent.STARTED:
+                // register resource provider for the started bundle
+                addBundleResourceProvider(event.getBundle());
+                break;
+
+            case BundleEvent.STOPPED:
+                // remove resource provider after the bundle has stopped
+                removeBundleResourceProvider(event.getBundle());
+                break;
+        }
+    }
+
+    // ---------- Bundle provided resources -----------------------------------
+
+    private void addBundleResourceProvider(Bundle bundle) {
+        String prefixes = (String) bundle.getHeaders().get(
+            BUNDLE_RESOURCE_ROOTS);
+        if (prefixes != null) {
+            BundleResourceProvider brp = new BundleResourceProvider(bundle,
+                prefixes);
+            brp.registerService(bundleContext);
+            bundleResourceProviderMap.put(bundle.getBundleId(), brp);
+        }
+    }
+
+    private void removeBundleResourceProvider(Bundle bundle) {
+        BundleResourceProvider brp = bundleResourceProviderMap.remove(bundle.getBundleId());
+        if (brp != null) {
+            brp.unregisterService();
+        }
+    }
+
+    /**
+     * Helper method to call the static method <code>methodName</code> on the
+     * class <code>clazzName</code> with the given <code>args</code>. This
+     * method operates exclusively using reflection to prevent any issues if the
+     * class cannot be loaded.
+     * <p>
+     * The goal is to enable running the bundle resource provider without a hard
+     * dependency on the Felix Web Console.
+     * 
+     * @param clazzName The fully qualified name of the class whose static
+     *            method is to be called.
+     * @param methodName The name of the method to call. This method must be
+     *            declared in the given class.
+     * @param argTypes The types of arguments of the methods to be able to find
+     *            the method. This may be <code>null</code> if the method has
+     *            no arguments.
+     * @param args The actual arguments to the method. This may be
+     *            <code>null</code> if the method has no arguments.
+     */
+    private void callMethod(String clazzName, String methodName,
+            Class<?>[] argTypes, Object[] args) {
+        try {
+            Class<?> clazz = getClass().getClassLoader().loadClass(clazzName);
+            Method method = clazz.getDeclaredMethod(methodName, argTypes);
+            if (!method.isAccessible()) {
+                method.setAccessible(true);
+            }
+            method.invoke(null, args);
+        } catch (Throwable t) {
+            // ignore anything
+        }
+    }
+}
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java
new file mode 100644
index 0000000..af49830
--- /dev/null
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java
@@ -0,0 +1,226 @@
+/*
+ * 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.sling.bundleresource.impl;
+
+import static org.apache.jackrabbit.JcrConstants.NT_FILE;
+import static org.apache.jackrabbit.JcrConstants.NT_FOLDER;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.sling.adapter.SlingAdaptable;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceMetadata;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** A Resource that wraps a Bundle entry */
+public class BundleResource extends SlingAdaptable implements Resource {
+
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    private final ResourceResolver resourceResolver;
+
+    private final BundleResourceCache bundle;
+
+    private final MappedPath mappedPath;
+
+    private final String path;
+
+    private URL url;
+
+    private final String resourceType;
+
+    private final ResourceMetadata metadata;
+
+    public static BundleResource getResource(ResourceResolver resourceResolver,
+            BundleResourceCache bundle, MappedPath mappedPath,
+            String resourcePath) {
+
+        String entryPath = mappedPath.getEntryPath(resourcePath);
+
+        // first try, whether the bundle has an entry with a trailing slash
+        // which would be a folder. In this case we check whether the
+        // repository contains an item with the same path. If so, we
+        // don't create a BundleResource but instead return null to be
+        // able to return an item-based resource
+        URL entry = bundle.getEntry(entryPath.concat("/"));
+        if (entry != null) {
+            Session session = resourceResolver.adaptTo(Session.class);
+            if (session != null) {
+                try {
+                    if (session.itemExists(resourcePath)) {
+                        return null;
+                    }
+                } catch (RepositoryException re) {
+                    // don't care
+                }
+            }
+
+            // append the slash to path for next steps
+            resourcePath = resourcePath.concat("/");
+        }
+
+        // if there is no entry with a trailing slash, try plain name
+        // which would then of course be a file
+        if (entry == null) {
+            entry = bundle.getEntry(entryPath);
+        }
+
+        // here we either have a folder for which no same-named item exists
+        // or a bundle file
+        if (entry != null) {
+            return new BundleResource(resourceResolver, bundle, mappedPath,
+                resourcePath);
+        }
+
+        // the bundle does not contain the path
+        return null;
+    }
+
+    public BundleResource(ResourceResolver resourceResolver,
+            BundleResourceCache bundle, MappedPath mappedPath,
+            String resourcePath) {
+
+        this.resourceResolver = resourceResolver;
+        this.bundle = bundle;
+        this.mappedPath = mappedPath;
+
+        metadata = new ResourceMetadata();
+        metadata.setResolutionPath(resourcePath);
+        metadata.setCreationTime(bundle.getBundle().getLastModified());
+        metadata.setModificationTime(bundle.getBundle().getLastModified());
+
+        if (resourcePath.endsWith("/")) {
+
+            this.path = resourcePath.substring(0, resourcePath.length() - 1);
+            this.resourceType = NT_FOLDER;
+
+        } else {
+
+            this.path = resourcePath;
+            this.resourceType = NT_FILE;
+
+            try {
+                URL url = bundle.getEntry(mappedPath.getEntryPath(resourcePath));
+                metadata.setContentLength(url.openConnection().getContentLength());
+            } catch (Exception e) {
+                // don't care, we just have no content length
+            }
+        }
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public String getResourceType() {
+        return resourceType;
+    }
+
+    /** Returns <code>null</code>, bundle resources have no super type */
+    public String getResourceSuperType() {
+        return null;
+    }
+
+    public ResourceMetadata getResourceMetadata() {
+        return metadata;
+    }
+
+    public ResourceResolver getResourceResolver() {
+        return resourceResolver;
+    }
+
+    @SuppressWarnings("unchecked")
+    public <Type> Type adaptTo(Class<Type> type) {
+        if (type == InputStream.class) {
+            return (Type) getInputStream(); // unchecked cast
+        } else if (type == URL.class) {
+            return (Type) getURL(); // unchecked cast
+        }
+
+        // fall back to nothing
+        return super.adaptTo(type);
+    }
+
+    public String toString() {
+        return getClass().getSimpleName() + ", type=" + getResourceType()
+            + ", path=" + getPath();
+    }
+
+    // ---------- internal -----------------------------------------------------
+
+    /**
+     * Returns a stream to the bundle entry if it is a file. Otherwise returns
+     * <code>null</code>.
+     */
+    private InputStream getInputStream() {
+        // implement this for files only
+        if (isFile()) {
+            try {
+                URL url = getURL();
+                if (url != null) {
+                    return url.openStream();
+                }
+            } catch (IOException ioe) {
+                log.error(
+                    "getInputStream: Cannot get input stream for " + this, ioe);
+            }
+        }
+
+        // otherwise there is no stream
+        return null;
+    }
+
+    private URL getURL() {
+        if (url == null) {
+            try {
+                url = new URL(BundleResourceURLStreamHandler.PROTOCOL, null,
+                    -1, path, new BundleResourceURLStreamHandler(
+                        bundle.getBundle(), mappedPath.getEntryPath(path)));
+            } catch (MalformedURLException mue) {
+                log.error("getURL: Cannot get URL for " + this, mue);
+            }
+        }
+
+        return url;
+    }
+
+    Iterator<Resource> listChildren() {
+        return new BundleResourceIterator(this);
+    }
+
+    BundleResourceCache getBundle() {
+        return bundle;
+    }
+
+    MappedPath getMappedPath() {
+        return mappedPath;
+    }
+
+    boolean isFile() {
+        return NT_FILE.equals(getResourceType());
+    }
+}
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java
new file mode 100644
index 0000000..55b5aa5
--- /dev/null
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java
@@ -0,0 +1,282 @@
+/*
+ * 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.sling.bundleresource.impl;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * The <code>BundleResourceCache</code> implements a simple caching for
+ * resources provided from a bundle. Each {@link BundleResourceProvider}
+ * instance uses an instance of this class to access the bundle resources (or
+ * bundle entries) through the cache.
+ * <p>
+ * The cache on the one hand caches single entries as URLs. The other part of
+ * the cache is for the child entries of a given bundle entry path. This caches
+ * lists of strings (entry path).
+ * <p>
+ * Currently the cache limits are fixed at {@value #CACHE_SIZE} for the entries
+ * cache and at {@value #LIST_CACHE_SIZE} for the child entries cache.
+ */
+class BundleResourceCache {
+
+    /**
+     * The maximum size of the single entry cache (value is 50).
+     */
+    private static final int CACHE_SIZE = 50;
+
+    /**
+     * The maximum size of the child entry cache (value is 20).
+     */
+    private static final int LIST_CACHE_SIZE = 20;
+
+    /**
+     * Sentinel for the single entry cache representing a missing entry to
+     * prevent looking for non-existing bundle entries multiple times (value is
+     * "file:///not_found").
+     */
+    private static final URL NOT_FOUND_URL;
+
+    /**
+     * Sentinel for the child entry cache representing a missing child list for
+     * a given path to prevent looking for non-existing bundle entries multiple
+     * times (value is an empty list).
+     */
+    private static final List<String> NOT_FOUND_CHILDREN = Collections.<String> emptyList();
+
+    /**
+     * Single entry cache. This is a synchronized map with a size limit.
+     */
+    private final Map<String, URL> cache;
+
+    /**
+     * The child entry cache. This is a synchronized map with a size limit.
+     */
+    private final Map<String, List<String>> listCache;
+
+    /**
+     * The Bundle providing the resource entries.
+     */
+    private final Bundle bundle;
+
+    // static initializer setting the NOT_FOUND_URL. Because the
+    // constructor may throw an exception we use a static initializer
+    // which fails the class initialization in the unlikely case
+    // of the URL constructor failing.
+    static {
+        try {
+            NOT_FOUND_URL = new URL("file:/not_found");
+        } catch (MalformedURLException mue) {
+            throw new ExceptionInInitializerError(mue);
+        }
+    }
+
+    /**
+     * Creates a new instance of this class providing access to the entries in
+     * the given <code>bundle</code>.
+     * 
+     * @param bundle
+     */
+    BundleResourceCache(Bundle bundle) {
+        this.bundle = bundle;
+
+        // create the limited maps wrapping in synchronized maps
+        this.cache = Collections.synchronizedMap(new BundleResourceMap<String, URL>(
+            CACHE_SIZE));
+        this.listCache = Collections.synchronizedMap(new BundleResourceMap<String, List<String>>(
+            LIST_CACHE_SIZE));
+    }
+
+    /**
+     * Returns the <code>Bundle</code> to which this instance provides access.
+     */
+    Bundle getBundle() {
+        return bundle;
+    }
+
+    /**
+     * Returns the entry in the underlying bundle at the given path. This path
+     * is assumed to be an absolute path. If relative it is resolved relative to
+     * the bundle root.
+     * <p>
+     * This method is backed by the <code>Bundle.getEntry(String)</code>
+     * method.
+     * 
+     * @param path The path to the bundle entry to return
+     * @return The URL to access the bundle entry or <code>null</code> if the
+     *         bundle does not contain the request entry.
+     */
+    URL getEntry(String path) {
+        URL url = cache.get(path);
+        if (url == null) {
+            url = bundle.getEntry(path);
+
+            if (url == null) {
+                url = NOT_FOUND_URL;
+            }
+
+            cache.put(path, url);
+        }
+
+        return (url == NOT_FOUND_URL) ? null : url;
+    }
+
+    /**
+     * Returns a list of bundle entry paths considered children of the given
+     * <code>parentPath</code>. This parent path is assumed to be an absolute
+     * path. If relative it is resolved relative to the bundle root.
+     * <p>
+     * This method is backed by the <code>Bundle.getEntryPaths(String)</code>
+     * method but returns an <code>Iterator<String></code> instead of an
+     * <code>Enumeration</code> of strings.
+     * 
+     * @param parentPath The path to the parent entry whose child entries are to
+     *            be returned.
+     * @return An <code>Iterator<String></code> providing the paths of
+     *         entries considered direct children of the <code>parentPath</code>
+     *         or <code>null</code> if the parent entry does not exist.
+     */
+    Iterator<String> getEntryPaths(String path) {
+        List<String> list = listCache.get(path);
+        if (list == null) {
+
+            @SuppressWarnings("unchecked")
+            Enumeration<String> entries = bundle.getEntryPaths(path);
+            if (entries != null && entries.hasMoreElements()) {
+                list = new LinkedList<String>();
+                while (entries.hasMoreElements()) {
+                    list.add(entries.nextElement());
+                }
+            }
+
+            if (list == null) {
+                list = NOT_FOUND_CHILDREN;
+            }
+
+            listCache.put(path, list);
+        }
+
+        return (list == NOT_FOUND_CHILDREN) ? null : list.iterator();
+    }
+
+    // ---------- Management API
+
+    /**
+     * Returns the current number of entries stored in the entry cache. This
+     * number includes "negative" entries, which are requested entries not found
+     * in the bundle.
+     */
+    int getEntryCacheSize() {
+        return cache.size();
+    }
+
+    /**
+     * Returns the maximum number of entries to be stored in the cache. This
+     * number is currently fixed at {@link #CACHE_SIZE}
+     */
+    int getEntryCacheMaxSize() {
+        return CACHE_SIZE;
+    }
+
+    /**
+     * Returns the current number of list entries stored in the list cache. This
+     * number includes "negative" list entries, which are requested list entries
+     * not found in the bundle.
+     */
+    int getListCacheSize() {
+        return listCache.size();
+    }
+
+    /**
+     * Returns the maximum number of list entries to be stored in the cache.
+     * This number is currently fixed at {@link #LIST_CACHE_SIZE}
+     */
+    int getListCacheMaxSize() {
+        return LIST_CACHE_SIZE;
+    }
+
+    // ---------- inner class
+
+    /**
+     * The <code>BundleResourceMap</code> class extends the
+     * <code>LinkedHashMap</code> class overwriting the
+     * {@link #removeEldestEntry(Entry)} method to implement the size limit,
+     * which is set in the constructor.
+     */
+    private static class BundleResourceMap<K, V> extends
+            LinkedHashMap<String, V> {
+
+        /**
+         * The default size of a bundle resource cache (value is 20).
+         */
+        private static final int DEFAULT_LIMIT = 20;
+
+        /**
+         * The limit configured for this map.
+         */
+        private final int limit;
+
+        /**
+         * Creates a new instance of this size limited map.
+         * 
+         * @param limit The maximum number of entries in this map. If this value
+         *            is less than or equal to zero, the default size of
+         *            {@link #DEFAULT_LIMIT} is used.
+         */
+        BundleResourceMap(int limit) {
+            // deliberately chosen initial size and load factor, but
+            // we need the access-order to implement the LRU mechanism
+            super(8, 0.75f, true);
+
+            // normalize size to a possitive number
+            if (limit <= 0) {
+                limit = DEFAULT_LIMIT;
+            }
+
+            this.limit = limit;
+        }
+
+        /**
+         * Returns the maximum number of entries to be stored in this map.
+         */
+        int getLimit() {
+            return limit;
+        }
+
+        /**
+         * Returns <code>true</code> if the current number of elements in the
+         * map exceeds the configured limit.
+         */
+        @Override
+        protected boolean removeEldestEntry(Entry<String, V> eldest) {
+            return size() > limit;
+        }
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java
new file mode 100644
index 0000000..de19d7d
--- /dev/null
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java
@@ -0,0 +1,153 @@
+/*
+ * 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.sling.bundleresource.impl;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The <code>BundleResourceIterator</code> class is a resource iterator, which
+ * returns resources for each Bundle entry of an underlying enumeration of
+ * Bundle entry paths.
+ */
+class BundleResourceIterator implements Iterator<Resource> {
+
+    /** default log */
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    /** The bundle resource resolver */
+    private final ResourceResolver resourceResolver;
+
+    /** Bundle providing the entry resources */
+    private final BundleResourceCache bundle;
+
+    private final MappedPath mappedPath;
+
+    /** Underlying bundle entry path enumeration */
+    private final Iterator<String> entries;
+
+    /** The length of the parent entry path, see seek() */
+    private final int prefixLength;
+
+    /** The prefetched next iterator entry, null at the end of iterating */
+    private Resource nextResult;
+
+    /**
+     * Creates an instance using the given parent bundle resource.
+     */
+    BundleResourceIterator(BundleResource parent) {
+
+        if (parent.isFile()) {
+
+            // if the parent is a file, the iterator is empty
+            this.resourceResolver = null;
+            this.bundle = null;
+            this.entries = null;
+            this.prefixLength = 0;
+            this.mappedPath = null;
+            this.nextResult = null;
+
+        } else {
+            // trailing slash to enumerate children
+            String parentPath = parent.getPath().concat("/");
+
+            this.resourceResolver = parent.getResourceResolver();
+            this.bundle = parent.getBundle();
+            this.mappedPath = parent.getMappedPath();
+            this.entries = parent.getBundle().getEntryPaths(parentPath);
+            this.prefixLength = parentPath.length();
+
+            this.nextResult = (entries != null) ? seek() : null;
+        }
+    }
+
+    BundleResourceIterator(ResourceResolver resourceResolver, BundleResourceCache bundle,
+            MappedPath mappedPath, String parentPath) {
+
+        // trailing slash to enumerate children
+        if (!parentPath.endsWith("/")) {
+            parentPath = parentPath.concat("/");
+        }
+
+        this.resourceResolver = resourceResolver;
+        this.bundle = bundle;
+        this.mappedPath = mappedPath;
+        this.entries = bundle.getEntryPaths(parentPath);
+        this.prefixLength = parentPath.length();
+
+        this.nextResult = (entries != null) ? seek() : null;
+    }
+
+    /** Returns true if there is another Resource available */
+    public boolean hasNext() {
+        return nextResult != null;
+    }
+
+    /** Returns the next resource in the iterator */
+    public Resource next() {
+        if (!hasNext()) {
+            throw new NoSuchElementException();
+        }
+
+        Resource result = nextResult;
+        nextResult = seek();
+        return result;
+    }
+
+    /**
+     * Throws <code>UnsupportedOperationException</code> as this method is not
+     * supported by this implementation.
+     */
+    public void remove() {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * Scans the entry path enumeration looking for the next entry being a
+     * direct child of the parent resource.
+     */
+    private Resource seek() {
+        while (entries.hasNext()) {
+            String entry = entries.next();
+
+            // require leading slash
+            if (!entry.startsWith("/")) {
+                entry = "/" + entry;
+            }
+
+            int slash = entry.indexOf('/', prefixLength);
+            if (slash < 0 || slash == entry.length() - 1) {
+                log.debug("seek: Using entry {}", entry);
+                return new BundleResource(resourceResolver, bundle, mappedPath,
+                    entry);
+            }
+
+            log.debug("seek: Ignoring entry {}", entry);
+        }
+
+        // no more results
+        log.debug("seek: No more nodes, iterator exhausted");
+        return null;
+    }
+}
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
new file mode 100644
index 0000000..2cbee15
--- /dev/null
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
@@ -0,0 +1,157 @@
+/*
+ * 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.sling.bundleresource.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.sling.api.SlingException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceProvider;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+
+public class BundleResourceProvider implements ResourceProvider {
+
+    /** The bundle providing the resources */
+    private final BundleResourceCache bundle;
+
+    /** The root paths */
+    private final MappedPath[] roots;
+
+    private ServiceRegistration serviceRegistration;
+
+    /**
+     * Creates Bundle resource provider accessing entries in the given Bundle an
+     * supporting resources below root paths given by the rootList which is a
+     * comma (and whitespace) separated list of absolute paths.
+     */
+    public BundleResourceProvider(Bundle bundle, String rootList) {
+        this.bundle = new BundleResourceCache(bundle);
+
+        StringTokenizer pt = new StringTokenizer(rootList, ", \t\n\r\f");
+        List<MappedPath> prefixList = new ArrayList<MappedPath>();
+        while (pt.hasMoreTokens()) {
+            String resourceRoot = pt.nextToken();
+            if (resourceRoot.length() > 0) {
+                prefixList.add(MappedPath.create(resourceRoot));
+            }
+        }
+        this.roots = prefixList.toArray(new MappedPath[prefixList.size()]);
+    }
+
+    void registerService(BundleContext context) {
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(Constants.SERVICE_DESCRIPTION,
+            "Provider of Bundle based Resources");
+        props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
+        props.put(ROOTS, getRoots());
+
+        serviceRegistration = context.registerService(SERVICE_NAME, this, props);
+    }
+
+    void unregisterService() {
+        if (serviceRegistration != null) {
+            serviceRegistration.unregister();
+        }
+    }
+
+    //---------- Web Console plugin support
+
+    BundleResourceCache getBundleResourceCache() {
+        return bundle;
+    }
+
+    MappedPath[] getMappedPaths() {
+        return roots;
+    }
+
+    //---------- internal
+
+    /** Returns the root paths */
+    private String[] getRoots() {
+        String[] rootPaths = new String[roots.length];
+        for (int i = 0; i < roots.length; i++) {
+            rootPaths[i] = roots[i].getResourceRoot();
+        }
+        return rootPaths;
+    }
+
+    private MappedPath getMappedPath(String resourcePath) {
+        for (MappedPath mappedPath : roots) {
+            if (mappedPath.isChild(resourcePath)) {
+                return mappedPath;
+            }
+        }
+
+        return null;
+    }
+
+    public Resource getResource(ResourceResolver resourceResolver,
+            HttpServletRequest request, String path) {
+        return getResource(resourceResolver, path);
+    }
+
+    /**
+     * Returns a BundleResource for the path if such an entry exists in the
+     * bundle of this provider. The JcrResourceResolver is ignored by this
+     * implementation.
+     */
+    public Resource getResource(ResourceResolver resourceResolver, String path) {
+        MappedPath mappedPath = getMappedPath(path);
+        if (mappedPath != null) {
+            return BundleResource.getResource(resourceResolver, bundle,
+                mappedPath, path);
+        }
+
+        return null;
+    }
+
+    public Iterator<Resource> listChildren(final Resource parent)
+            throws SlingException {
+
+        // bundle resources can handle this request directly
+        if (parent instanceof BundleResource) {
+            return ((BundleResource) parent).listChildren();
+        }
+
+        // ensure this provider may have children of the parent
+        String parentPath = parent.getPath();
+        MappedPath mappedPath = getMappedPath(parentPath);
+        if (mappedPath != null) {
+            return new BundleResourceIterator(parent.getResourceResolver(),
+                bundle, mappedPath, parentPath);
+        }
+
+        // the parent resource cannot have children in this provider,
+        // though this is basically not expected, we still have to
+        // be prepared for such a situation
+        return Collections.<Resource> emptyList().iterator();
+    }
+}
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLConnection.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLConnection.java
new file mode 100644
index 0000000..c121be4
--- /dev/null
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLConnection.java
@@ -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.sling.bundleresource.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * A Bundle based <code>UIRLConnection</code> which uses the bundle's last
+ * modification time as the last modification time of the URL in contrast to the
+ * (Apache Felix) URLConnection used for the bundle entry, which always returns
+ * zero.
+ */
+public class BundleResourceURLConnection extends URLConnection {
+
+    /** The bundle owning the resource underlying the URLConnection */
+    private final Bundle bundle;
+
+    private final String bundlePath;
+    
+    /** The original URLConnection */
+    private URLConnection delegatee;
+
+    protected BundleResourceURLConnection(Bundle bundle, String bundlePath, URL url) {
+        super(url);
+
+        this.bundle = bundle;
+        this.bundlePath = bundlePath;
+    }
+
+    /**
+     * Connects this URLConnection to access the data and metadata such as the
+     * content length, last modification time and content type.
+     */
+    public synchronized void connect() throws IOException {
+        if (!connected) {
+            URL url = bundle.getEntry(bundlePath);
+            if (url == null) {
+                throw new IOException("Cannot find entry " + bundlePath
+                    + " in bundle " + bundle + " for URL " + url);
+            }
+
+            delegatee = url.openConnection();
+
+            connected = true;
+        }
+    }
+
+    /** Returns the input stream of the Bundle provided URLConnection */
+    public InputStream getInputStream() throws IOException {
+        connect();
+
+        return delegatee.getInputStream();
+    }
+
+    /** Returns the content length of the Bundle provided URLConnection */
+    public int getContentLength() {
+        try {
+            connect();
+        } catch (IOException ex) {
+            return -1;
+        }
+
+        return delegatee.getContentLength();
+    }
+
+    /**
+     * Returns the last modification time of the underlying bundle, which is the
+     * last time the bundle was installed or updated
+     */
+    public long getLastModified() {
+        try {
+            connect();
+        } catch (IOException ex) {
+            return 0;
+        }
+
+        return bundle.getLastModified();
+    }
+
+    /** Returns the content type of the Bundle provided URLConnection */
+    public String getContentType() {
+        try {
+            connect();
+        } catch (IOException ex) {
+            return null;
+        }
+
+        return delegatee.getContentType();
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLStreamHandler.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLStreamHandler.java
new file mode 100644
index 0000000..a27585a
--- /dev/null
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLStreamHandler.java
@@ -0,0 +1,51 @@
+/*
+ * 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.sling.bundleresource.impl;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+import org.osgi.framework.Bundle;
+
+class BundleResourceURLStreamHandler extends URLStreamHandler {
+
+    static final String PROTOCOL = "bundle";
+
+    private final Bundle bundle;
+    
+    private final String bundlePath;
+
+    BundleResourceURLStreamHandler(Bundle bundle, String bundlePath) {
+        this.bundle = bundle;
+        this.bundlePath = bundlePath;
+    }
+
+    @Override
+    protected URLConnection openConnection(URL u) throws IOException {
+        if (!PROTOCOL.equals(u.getProtocol())) {
+            throw new IOException("Cannot open connection to " + u
+                + ", wrong protocol");
+        }
+
+        return new BundleResourceURLConnection(bundle, bundlePath, u);
+    }
+
+}
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java
new file mode 100644
index 0000000..19dd77a
--- /dev/null
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java
@@ -0,0 +1,222 @@
+/*
+ * 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.sling.bundleresource.impl;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.felix.webconsole.AbstractWebConsolePlugin;
+import org.apache.felix.webconsole.WebConsoleConstants;
+import org.apache.sling.api.resource.ResourceProvider;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.util.tracker.ServiceTracker;
+
+class BundleResourceWebConsolePlugin extends AbstractWebConsolePlugin {
+
+    private static final String LABEL = "bundleresources";
+
+    private ServiceRegistration serviceRegistration;
+
+    private ServiceTracker providerTracker;
+
+    private List<BundleResourceProvider> provider = new ArrayList<BundleResourceProvider>();
+
+    //--------- setup and shutdown
+
+    private static BundleResourceWebConsolePlugin INSTANCE;
+    
+    static void initPlugin(BundleContext context) {
+        if (INSTANCE == null) {
+            BundleResourceWebConsolePlugin tmp = new BundleResourceWebConsolePlugin();
+            tmp.activate(context);
+            INSTANCE = tmp;
+        }
+    }
+    
+    static void destroyPlugin() {
+        if (INSTANCE != null) {
+            try {
+                INSTANCE.deactivate();
+            } finally {
+                INSTANCE = null;
+            }
+        }
+    }
+    
+    // private constructor to force using static setup and shutdown
+    private BundleResourceWebConsolePlugin() {
+    }
+
+    //---------- AbstractWebConsolePlugin implementation
+    
+    @Override
+    public String getLabel() {
+        return LABEL;
+    }
+
+    @Override
+    public String getTitle() {
+        return "Bundle Resource Provider";
+    }
+
+    @Override
+    protected void renderContent(HttpServletRequest req, HttpServletResponse res)
+            throws IOException {
+
+        PrintWriter pw = res.getWriter();
+
+        pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'>");
+
+        pw.println("<tr class='content'>");
+        pw.println("<th colspan='2' class='content container'>Bundle Resource Provider</th>");
+        pw.println("</tr>");
+
+        BundleResourceProvider[] brp = provider.toArray(new BundleResourceProvider[provider.size()]);
+        for (BundleResourceProvider bundleResourceProvider : brp) {
+
+            BundleResourceCache cache = bundleResourceProvider.getBundleResourceCache();
+            MappedPath[] paths = bundleResourceProvider.getMappedPaths();
+
+            pw.println("<tr class='content'>");
+
+            pw.println("<td class='content'>");
+            pw.println(cache.getBundle().getBundleId());
+            pw.println("</td>");
+
+            pw.println("<td class='content'>");
+            pw.println(getName(cache.getBundle()));
+            pw.println("</td>");
+
+            pw.println("</tr>");
+
+            pw.println("<tr class='content'>");
+            pw.println("<td class='content'>&nbsp;</td>");
+
+            pw.println("<td class='content'>");
+
+            pw.println("<table>");
+
+            pw.println("<tr>");
+            pw.println("<td>Mappings</td>");
+            pw.println("<td>");
+            for (MappedPath mappedPath : paths) {
+                pw.print(mappedPath.getResourceRoot());
+                if (mappedPath.getEntryRoot() != null) {
+                    pw.print(" ==> ");
+                    pw.print(mappedPath.getEntryRoot());
+                }
+                pw.print("<br>");
+            }
+            pw.println("</td>");
+            pw.println("</tr>");
+
+            pw.println("<tr>");
+            pw.println("<td>Entry Cache</td>");
+            pw.printf("<td>Size: %d, Limit: %d</td>%n",
+                cache.getEntryCacheSize(), cache.getEntryCacheMaxSize());
+            pw.println("</tr>");
+
+            pw.println("<tr>");
+            pw.println("<td>List Cache</td>");
+            pw.printf("<td>Size: %d, Limit: %d</td>%n",
+                cache.getListCacheSize(), cache.getListCacheMaxSize());
+            pw.println("</tr>");
+
+            pw.println("</table>");
+
+            pw.println("</td>");
+            pw.println("</tr>");
+        }
+
+        pw.println("</table>");
+
+    }
+
+    public void activate(BundleContext context) {
+        super.activate(context);
+
+        providerTracker = new ServiceTracker(context,
+            ResourceProvider.SERVICE_NAME, null) {
+            @Override
+            public Object addingService(ServiceReference reference) {
+                Object service = super.addingService(reference);
+                if (service instanceof BundleResourceProvider) {
+                    provider.add((BundleResourceProvider) service);
+                }
+                return service;
+            }
+
+            @Override
+            public void removedService(ServiceReference reference,
+                    Object service) {
+                if (service instanceof BundleResourceProvider) {
+                    provider.remove(service);
+                }
+                super.removedService(reference, service);
+            }
+        };
+        providerTracker.open();
+
+        Dictionary<String, Object> props = new Hashtable<String, Object>();
+        props.put(Constants.SERVICE_DESCRIPTION,
+            "Web Console Plugin for Bundle Resource Providers");
+        props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
+        props.put(Constants.SERVICE_PID, getClass().getName());
+        props.put(WebConsoleConstants.PLUGIN_LABEL, LABEL);
+
+        serviceRegistration = context.registerService(
+            WebConsoleConstants.SERVICE_NAME, this, props);
+    }
+
+    public void deactivate() {
+        if (serviceRegistration != null) {
+            serviceRegistration.unregister();
+            serviceRegistration = null;
+        }
+
+        if (providerTracker != null) {
+            providerTracker.close();
+            providerTracker = null;
+        }
+
+        super.deactivate();
+    }
+
+    private String getName(Bundle bundle) {
+        String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
+        if (name == null) {
+            name = bundle.getSymbolicName();
+            if (name == null) {
+                name = bundle.getLocation();
+            }
+        }
+        return name;
+    }
+}
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/MappedPath.java b/src/main/java/org/apache/sling/bundleresource/impl/MappedPath.java
new file mode 100644
index 0000000..98b2fc0
--- /dev/null
+++ b/src/main/java/org/apache/sling/bundleresource/impl/MappedPath.java
@@ -0,0 +1,101 @@
+/*
+ * 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.sling.bundleresource.impl;
+
+class MappedPath {
+
+    private static final char prefixSeparatorChar = '!';
+    private final String resourceRoot;
+    private final String resourceRootPrefix;
+    private final String entryRoot;
+    private final String entryRootPrefix;
+
+    static MappedPath create(String configPath) {
+        String resourceRoot;
+        String entryRoot;
+        int prefixSep = configPath.indexOf(prefixSeparatorChar);
+        if (prefixSep >= 0) {
+            entryRoot = configPath.substring(prefixSep + 1);
+            resourceRoot = configPath.substring(0, prefixSep).concat(entryRoot);
+        } else {
+            resourceRoot = configPath;
+            entryRoot = null;
+        }
+        return new MappedPath(resourceRoot, entryRoot);
+    }
+    
+    MappedPath(String resourceRoot, String entryRoot) {
+        this.resourceRoot = resourceRoot;
+        this.resourceRootPrefix = ensureTrailingSlash(resourceRoot);
+        this.entryRoot = entryRoot;
+        this.entryRootPrefix = ensureTrailingSlash(entryRoot);
+    }
+    
+    boolean isChild(String resourcePath) {
+        return resourcePath.startsWith(resourceRootPrefix)
+            || resourcePath.equals(resourceRoot);
+    }
+    
+    String getEntryPath(String resourcePath) {
+        if (entryRootPrefix == null) {
+            return resourcePath;
+        }
+        
+        if (resourcePath.startsWith(resourceRootPrefix)) {
+            return entryRootPrefix.concat(resourcePath.substring(resourceRootPrefix.length()));
+        } else if (resourcePath.equals(resourceRoot)) {
+            return entryRoot;
+        }
+        
+        return null;
+    }
+    
+    String getResourceRoot() {
+        return resourceRoot;
+    }
+    
+    String getResourceRootPrefix() {
+        return resourceRootPrefix;
+    }
+    
+    String getEntryRoot() {
+        return entryRoot;
+    }
+    
+    String getEntryRootPrefix() {
+        return entryRootPrefix;
+    }
+    
+    private static String ensureTrailingSlash(String path) {
+        if (path == null || path.length() == 0) {
+            return null;
+        }
+        
+        if (!path.endsWith("/")) {
+            return path.concat("/");
+        }
+        
+        return path;
+    }
+    
+    @Override
+    public String toString() {
+        return "MappedPath: " + getResourceRoot() + " -> " + getEntryRoot();
+    }
+}
diff --git a/src/main/resources/META-INF/DISCLAIMER b/src/main/resources/META-INF/DISCLAIMER
new file mode 100644
index 0000000..90850c2
--- /dev/null
+++ b/src/main/resources/META-INF/DISCLAIMER
@@ -0,0 +1,7 @@
+Apache Sling is an effort undergoing incubation at The Apache Software Foundation (ASF),
+sponsored by the Apache Jackrabbit PMC. Incubation is required of all newly accepted
+projects until a further review indicates that the infrastructure, communications,
+and decision making process have stabilized in a manner consistent with other
+successful ASF projects. While incubation status is not necessarily a reflection of
+the completeness or stability of the code, it does indicate that the project has yet
+to be fully endorsed by the ASF.
\ No newline at end of file
diff --git a/src/main/resources/META-INF/LICENSE b/src/main/resources/META-INF/LICENSE
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/src/main/resources/META-INF/LICENSE
@@ -0,0 +1,202 @@
+
+                                 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/src/main/resources/META-INF/NOTICE b/src/main/resources/META-INF/NOTICE
new file mode 100644
index 0000000..255444e
--- /dev/null
+++ b/src/main/resources/META-INF/NOTICE
@@ -0,0 +1,9 @@
+Apache Sling Bundle Resource Provider
+Copyright 2008-2009 The Apache Software Foundation
+
+Apache Sling is based on source code originally developed 
+by Day Software (http://www.day.com/).
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+