felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1583367 [1/4] - in /felix/trunk/pojosr: ./ src/ src/main/ src/main/java/ src/main/java/de/ src/main/java/de/kalpatec/ src/main/java/de/kalpatec/pojosr/ src/main/java/de/kalpatec/pojosr/framework/ src/main/java/de/kalpatec/pojosr/framework/...
Date Mon, 31 Mar 2014 16:18:18 GMT
Author: gnodet
Date: Mon Mar 31 16:18:17 2014
New Revision: 1583367

URL: http://svn.apache.org/r1583367
Log:
[FELIX-4445] PojoSR code initial commit

Added:
    felix/trunk/pojosr/
    felix/trunk/pojosr/DEPENDENCIES
    felix/trunk/pojosr/LICENSE
    felix/trunk/pojosr/NOTICE
    felix/trunk/pojosr/pom.xml
    felix/trunk/pojosr/src/
    felix/trunk/pojosr/src/main/
    felix/trunk/pojosr/src/main/java/
    felix/trunk/pojosr/src/main/java/de/
    felix/trunk/pojosr/src/main/java/de/kalpatec/
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/DirRevision.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntriesEnumeration.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntryFilterEnumeration.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/FileEntriesEnumeration.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/JarRevision.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSR.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSRBundle.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSRBundleContext.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoServiceRegistryFactoryImpl.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/Revision.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/URLRevision.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/ServiceRegistrationImpl.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/ServiceRegistry.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/capabilityset/
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/capabilityset/Attribute.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/capabilityset/Capability.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/capabilityset/CapabilitySet.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/capabilityset/Directive.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/capabilityset/Requirement.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/capabilityset/SimpleFilter.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/EventDispatcher.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/ListenerHookInfoImpl.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/ListenerInfo.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/MapToDictionary.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/ShrinkableCollection.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/ShrinkableMap.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/StringComparator.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/StringMap.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/Util.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/felix/framework/util/VersionRange.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/launch/
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/launch/BundleDescriptor.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/launch/ClasspathScanner.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/launch/PojoServiceRegistry.java
    felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/launch/PojoServiceRegistryFactory.java
    felix/trunk/pojosr/src/main/resources/
    felix/trunk/pojosr/src/main/resources/META-INF/
    felix/trunk/pojosr/src/main/resources/META-INF/services/
    felix/trunk/pojosr/src/main/resources/META-INF/services/de.kalpatec.pojosr.framework.launch.PojoServiceRegistryFactory
    felix/trunk/pojosr/src/main/resources/META-INF/services/org.osgi.framework.launch.FrameworkFactory

Added: felix/trunk/pojosr/DEPENDENCIES
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/DEPENDENCIES?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/DEPENDENCIES (added)
+++ felix/trunk/pojosr/DEPENDENCIES Mon Mar 31 16:18:17 2014
@@ -0,0 +1,28 @@
+pojosr Framework
+
+I. Included Third-Party Software
+
+This product includes software developed at
+The Apache Software Foundation 
+(http://www.apache.org)
+Copyright (c) Apache Software Foundation
+Licensded under the Apache License 2.0
+
+This product includes software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2009).
+Licensed under the Apache License 2.0.
+
+II. Used Third-Party Software
+
+This product uses software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2009).
+Licensed under the Apache License 2.0.
+
+This product uses software developed at
+The Codehaus (http://www.codehaus.org)
+Licensed under the Apache License 2.0.
+
+III. License Summary
+- Apache License 2.0

Added: felix/trunk/pojosr/LICENSE
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/LICENSE?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/LICENSE (added)
+++ felix/trunk/pojosr/LICENSE Mon Mar 31 16:18:17 2014
@@ -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.

Added: felix/trunk/pojosr/NOTICE
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/NOTICE?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/NOTICE (added)
+++ felix/trunk/pojosr/NOTICE Mon Mar 31 16:18:17 2014
@@ -0,0 +1,10 @@
+pojosr Framework
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+Licensed under the Apache License 2.0.
+
+This product includes software developed at
+The OSGi Alliance (http://www.osgi.org/).
+Copyright (c) OSGi Alliance (2000, 2009).
+Licensed under the Apache License 2.0.

Added: felix/trunk/pojosr/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/pom.xml?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/pom.xml (added)
+++ felix/trunk/pojosr/pom.xml Mon Mar 31 16:18:17 2014
@@ -0,0 +1,144 @@
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.sonatype.oss</groupId>
+    <artifactId>oss-parent</artifactId>
+    <version>7</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <packaging>bundle</packaging>
+  <name>Pojo Service Registry</name>
+  <groupId>com.googlecode.pojosr</groupId>
+  <artifactId>de.kalpatec.pojosr.framework</artifactId>
+  <version>0.3.0-SNAPSHOT</version>
+  <description>A service registry that enables OSGi style service registry programs without using an OSGi framework.</description>
+  <url>http://pojosr.googlecode.com/</url>
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+  <scm>
+    <url>http://pojosr.googlecode.com/svn/trunk/</url>
+    <connection>scm:svn:http://pojosr.googlecode.com/svn/trunk/framework/</connection>
+    <developerConnection>scm:svn:https://pojosr.googlecode.com/svn/trunk/framework/</developerConnection>
+  </scm>
+  <developers>
+    <developer>
+      <id>karlpauls</id>
+      <name>Karl Pauls</name>
+      <email>karlpauls@gmail.com</email>
+    </developer>
+  </developers>
+  <dependencies>
+      <dependency>
+          <groupId>org.osgi</groupId>
+          <artifactId>org.osgi.core</artifactId>
+          <version>4.3.1</version>
+      </dependency>
+      <dependency>
+          <groupId>org.osgi</groupId>
+          <artifactId>org.osgi.compendium</artifactId>
+          <version>4.2.0</version>
+      </dependency> 
+  </dependencies>
+  <repositories />
+  <pluginRepositories />
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-release-plugin</artifactId>
+        <configuration>
+          <tagBase>https://pojosr.googlecode.com/svn/tags</tagBase>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <target>1.5</target>
+          <source>1.5</source>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <version>2.1.2</version>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>jar-no-fork</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <version>2.8</version>
+        <executions>
+          <execution>
+            <id>attach-javadoc</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>2.3.4</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>de.kalpatec.pojosr.framework</Bundle-SymbolicName>
+            <Bundle-Name>Pojo Service Registry</Bundle-Name>
+            <Bundle-Vendor>Apache Software Foundation</Bundle-Vendor>
+            <Private-Package>org.osgi.framework.*, org.osgi.service.url, org.osgi.service.packageadmin, org.osgi.service.startlevel, org.osgi.util.tracker, de.kalpatec.pojosr.framework.*</Private-Package>
+            <Import-Package>!*</Import-Package>
+            <Include-Resource>META-INF/LICENSE=LICENSE,META-INF/NOTICE=NOTICE,META-INF/DEPENDENCIES=DEPENDENCIES,{src/main/resources/}</Include-Resource> 
+            <Main-Class>de.kalpatec.pojosr.framework.PojoSR</Main-Class>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+     <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+        <filtering>true</filtering>
+      </resource>
+      <resource>
+      <directory>.</directory>
+      <targetPath>META-INF</targetPath>
+      <includes>
+        <include>LICENSE*</include>
+        <include>NOTICE*</include>
+        <include>DEPENDENCIES*</include>
+      </includes>
+    </resource>
+    </resources> 
+  </build>
+</project>

Added: felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/DirRevision.java
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/DirRevision.java?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/DirRevision.java (added)
+++ felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/DirRevision.java Mon Mar 31 16:18:17 2014
@@ -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 de.kalpatec.pojosr.framework;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Map;
+
+import de.kalpatec.pojosr.framework.felix.framework.util.StringMap;
+
+class DirRevision extends Revision
+{
+    private final File m_file;
+
+    public DirRevision(File file)
+    {
+        m_file = file;
+    }
+
+    @Override
+    public long getLastModified()
+    {
+        return m_file.lastModified();
+    }
+
+    public Enumeration getEntries()
+    {
+        return new FileEntriesEnumeration(m_file);
+    }
+
+    @Override
+    public URL getEntry(String entryName)
+    {
+        try
+        {
+		    if (entryName != null) {
+            File file = (new File(m_file, (entryName.startsWith("/")) ? entryName.substring(1) : entryName));
+            if (file.exists()) {
+                return file.toURL();
+            } 
+			}
+        }
+        catch (MalformedURLException e)
+        {
+            e.printStackTrace();
+        }
+            return null;
+
+    }
+
+}

Added: felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntriesEnumeration.java
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntriesEnumeration.java?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntriesEnumeration.java (added)
+++ felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntriesEnumeration.java Mon Mar 31 16:18:17 2014
@@ -0,0 +1,68 @@
+/*
+ * 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 de.kalpatec.pojosr.framework;
+
+import java.util.Enumeration;
+import java.util.zip.ZipEntry;
+
+class EntriesEnumeration implements Enumeration
+{
+    private final Enumeration m_enumeration;
+	private final String m_prefix;
+	private volatile Object current;
+
+    public EntriesEnumeration(Enumeration enumeration)
+    {
+        this(enumeration, null);
+    }
+	
+	public EntriesEnumeration(Enumeration enumeration, String prefix)
+	{
+	   m_enumeration = enumeration;
+	   m_prefix = prefix;
+	}
+
+    public boolean hasMoreElements() {
+				while ((current == null) && m_enumeration.hasMoreElements()) {
+					String result = (String) ((ZipEntry) m_enumeration.nextElement()).getName();
+					if (m_prefix != null){
+						if (result.startsWith(m_prefix)) {
+							current = result.substring(m_prefix.length());
+						}
+					}
+					else {
+						current = result;
+					}
+				}
+				return (current != null);
+			}
+
+			public Object nextElement() {
+				try {
+					if (hasMoreElements()) {
+						return current;
+					}
+					else {
+						return m_enumeration.nextElement();
+					}
+				} finally { 
+					current = null;
+				}
+			}
+}
\ No newline at end of file

Added: felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntryFilterEnumeration.java
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntryFilterEnumeration.java?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntryFilterEnumeration.java (added)
+++ felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/EntryFilterEnumeration.java Mon Mar 31 16:18:17 2014
@@ -0,0 +1,236 @@
+/*
+ * 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 de.kalpatec.pojosr.framework;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import de.kalpatec.pojosr.framework.felix.framework.capabilityset.SimpleFilter;
+
+class EntryFilterEnumeration<T> implements Enumeration<T>
+{
+    private final Enumeration<String> m_enumeration;
+    private final Revision m_revision;
+    private final String m_path;
+    private final List<String> m_filePattern;
+    private final boolean m_recurse;
+    private final boolean m_isURLValues;
+    private final Set<String> m_dirEntries = new HashSet<String>();
+    private final List<T> m_nextEntries = new ArrayList<T>(2);
+
+    public EntryFilterEnumeration(Revision rev, boolean includeFragments,
+            String path, String filePattern, boolean recurse,
+            boolean isURLValues)
+    {
+        m_revision = rev;
+        m_enumeration = rev.getEntries();
+        m_recurse = recurse;
+        m_isURLValues = isURLValues;
+
+        // Sanity check the parameters.
+        if (path == null)
+        {
+            throw new IllegalArgumentException(
+                    "The path for findEntries() cannot be null.");
+        }
+        // Strip leading '/' if present.
+        if ((path.length() > 0) && (path.charAt(0) == '/'))
+        {
+            path = path.substring(1);
+        }
+        // Add a '/' to the end if not present.
+        if ((path.length() > 0) && (path.charAt(path.length() - 1) != '/'))
+        {
+            path = path + "/";
+        }
+        m_path = path;
+
+        // File pattern defaults to "*" if not specified.
+        filePattern = (filePattern == null) ? "*" : filePattern;
+
+        m_filePattern = SimpleFilter.parseSubstring(filePattern);
+
+        findNext();
+    }
+
+    public synchronized boolean hasMoreElements()
+    {
+        return (m_nextEntries.size() != 0);
+    }
+
+    public synchronized T nextElement()
+    {
+        if (m_nextEntries.size() == 0)
+        {
+            throw new NoSuchElementException("No more entries.");
+        }
+        T last = m_nextEntries.remove(0);
+        findNext();
+        return last;
+    }
+
+    private void findNext()
+    {
+        // This method filters the content entry enumeration, such that
+        // it only displays the contents of the directory specified by
+        // the path argument either recursively or not; much like using
+        // "ls -R" or "ls" to list the contents of a directory, respectively.
+        if (m_enumeration == null)
+        {
+            return;
+        }
+        if (m_nextEntries.size() == 0)
+        {
+            while (m_enumeration.hasMoreElements() && m_nextEntries.size() == 0)
+            {
+                // Get the current entry to determine if it should be filtered
+                // or not.
+                String entryName = (String) m_enumeration.nextElement();
+                // Check to see if the current entry is a descendent of the
+                // specified path.
+                if (!entryName.equals(m_path) && entryName.startsWith(m_path))
+                {
+                    // Cached entry URL. If we are returning URLs, we use this
+                    // cached URL to avoid doing multiple URL lookups from a
+                    // module
+                    // when synthesizing directory URLs.
+                    URL entryURL = null;
+
+                    // If the current entry is in a subdirectory of the
+                    // specified path,
+                    // get the index of the slash character.
+                    int dirSlashIdx = entryName.indexOf('/', m_path.length());
+
+                    // JAR files are supposed to contain entries for
+                    // directories,
+                    // but not all do. So calculate the directory for this entry
+                    // and see if we've already seen an entry for the directory.
+                    // If not, synthesize an entry for the directory. If we are
+                    // doing a recursive match, we need to synthesize each
+                    // matching
+                    // subdirectory of the entry.
+                    if (dirSlashIdx >= 0)
+                    {
+                        // Start synthesizing directories for the current entry
+                        // at the subdirectory after the initial path.
+                        int subDirSlashIdx = dirSlashIdx;
+                        String dir;
+                        do
+                        {
+                            // Calculate the subdirectory name.
+                            dir = entryName.substring(0, subDirSlashIdx + 1);
+                            // If we have not seen this directory before, then
+                            // record
+                            // it and potentially synthesize an entry for it.
+                            if (!m_dirEntries.contains(dir))
+                            {
+                                // Record it.
+                                m_dirEntries.add(dir);
+                                // If the entry is actually a directory entry
+                                // (i.e.,
+                                // it ends with a slash), then we don't need to
+                                // synthesize an entry since it exists;
+                                // otherwise,
+                                // synthesize an entry if it matches the file
+                                // pattern.
+                                if (entryName.length() != (subDirSlashIdx + 1))
+                                {
+                                    // See if the file pattern matches the last
+                                    // element of the path.
+                                    if (SimpleFilter.compareSubstring(
+                                            m_filePattern,
+                                            getLastPathElement(dir)))
+                                    {
+                                        if (m_isURLValues)
+                                        {
+                                            entryURL = (entryURL == null) ? m_revision
+                                                    .getEntry(entryName)
+                                                    : entryURL;
+                                            try
+                                            {
+                                                m_nextEntries.add((T) new URL(
+                                                        entryURL, "/" + dir));
+                                            }
+                                            catch (MalformedURLException ex)
+                                            {
+                                            }
+                                        }
+                                        else
+                                        {
+                                            m_nextEntries.add((T) dir);
+                                        }
+                                    }
+                                }
+                            }
+                            // Now prepare to synthesize the next subdirectory
+                            // if we are matching recursively.
+                            subDirSlashIdx = entryName.indexOf('/',
+                                    dir.length());
+                        }
+                        while (m_recurse && (subDirSlashIdx >= 0));
+                    }
+
+                    // Now we actually need to check if the current entry itself
+                    // should
+                    // be filtered or not. If we are recursive or the current
+                    // entry
+                    // is a child (not a grandchild) of the initial path, then
+                    // we need
+                    // to check if it matches the file pattern.
+                    if (m_recurse || (dirSlashIdx < 0)
+                            || (dirSlashIdx == entryName.length() - 1))
+                    {
+                        // See if the file pattern matches the last element of
+                        // the path.
+                        if (SimpleFilter.compareSubstring(m_filePattern,
+                                getLastPathElement(entryName)))
+                        {
+                            if (m_isURLValues)
+                            {
+                                entryURL = (entryURL == null) ? m_revision
+                                        .getEntry(entryName) : entryURL;
+                                m_nextEntries.add((T) entryURL);
+                            }
+                            else
+                            {
+                                m_nextEntries.add((T) entryName);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private static String getLastPathElement(String entryName)
+    {
+        int endIdx = (entryName.charAt(entryName.length() - 1) == '/') ? entryName
+                .length() - 1 : entryName.length();
+        int startIdx = (entryName.charAt(entryName.length() - 1) == '/') ? entryName
+                .lastIndexOf('/', endIdx - 1) + 1 : entryName.lastIndexOf('/',
+                endIdx) + 1;
+        return entryName.substring(startIdx, endIdx);
+    }
+}
\ No newline at end of file

Added: felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/FileEntriesEnumeration.java
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/FileEntriesEnumeration.java?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/FileEntriesEnumeration.java (added)
+++ felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/FileEntriesEnumeration.java Mon Mar 31 16:18:17 2014
@@ -0,0 +1,88 @@
+/*
+ * 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 de.kalpatec.pojosr.framework;
+
+import java.io.File;
+import java.util.Enumeration;
+import java.util.NoSuchElementException;
+
+class FileEntriesEnumeration implements Enumeration
+{
+    private final File m_dir;
+    private final File[] m_children;
+    private int m_counter = 0;
+
+    public FileEntriesEnumeration(File dir)
+    {
+        m_dir = dir;
+        m_children = listFilesRecursive(m_dir);
+    }
+
+    public synchronized boolean hasMoreElements()
+    {
+        return (m_children != null) && (m_counter < m_children.length);
+    }
+
+    public synchronized Object nextElement()
+    {
+        if ((m_children == null) || (m_counter >= m_children.length))
+        {
+            throw new NoSuchElementException("No more entry paths.");
+        }
+
+        // Convert the file separator character to slashes.
+        String abs = m_children[m_counter].getAbsolutePath().replace(
+                File.separatorChar, '/');
+
+        // Remove the leading path of the reference directory, since the
+        // entry paths are supposed to be relative to the root.
+        StringBuffer sb = new StringBuffer(abs);
+        sb.delete(0, m_dir.getAbsolutePath().length() + 1);
+        // Add a '/' to the end of directory entries.
+        if (m_children[m_counter].isDirectory())
+        {
+            sb.append('/');
+        }
+        m_counter++;
+        return sb.toString();
+    }
+
+    private File[] listFilesRecursive(File dir)
+    {
+        File[] children = dir.listFiles();
+        File[] combined = children;
+        for (int i = 0; i < children.length; i++)
+        {
+            if (children[i].isDirectory())
+            {
+                File[] grandchildren = listFilesRecursive(children[i]);
+                if (grandchildren.length > 0)
+                {
+                    File[] tmp = new File[combined.length
+                            + grandchildren.length];
+                    System.arraycopy(combined, 0, tmp, 0, combined.length);
+                    System.arraycopy(grandchildren, 0, tmp, combined.length,
+                            grandchildren.length);
+                    combined = tmp;
+                }
+            }
+        }
+        return combined;
+    }
+}
\ No newline at end of file

Added: felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/JarRevision.java
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/JarRevision.java?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/JarRevision.java (added)
+++ felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/JarRevision.java Mon Mar 31 16:18:17 2014
@@ -0,0 +1,131 @@
+/*
+ * 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 de.kalpatec.pojosr.framework;
+
+import java.io.*;
+import java.net.URLStreamHandler;
+import java.net.URLConnection;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
+import java.util.zip.ZipEntry;
+
+import de.kalpatec.pojosr.framework.felix.framework.util.StringMap;
+
+class JarRevision extends Revision
+{
+    private final long m_lastModified;
+    private final JarFile m_jar;
+    private final URL m_url;
+	private final String m_urlString;
+	private final String m_prefix;
+
+    public JarRevision(JarFile jar, URL url, String prefix, long lastModified)
+    {
+        m_jar = jar;
+        m_url = url;
+		m_urlString =  m_url.toExternalForm();
+		m_prefix = prefix;
+        if (lastModified > 0)
+        {
+            m_lastModified = lastModified;
+        }
+        else
+        {
+            m_lastModified = System.currentTimeMillis();
+        }
+    }
+
+    @Override
+    public long getLastModified()
+    {
+        return m_lastModified;
+    }
+
+    public Enumeration getEntries()
+    {
+        return new EntriesEnumeration(m_jar.entries(), m_prefix);
+    }
+
+    @Override
+    public URL getEntry(String entryName)
+    {
+        try
+        {
+		    if("/".equals(entryName) || "".equals(entryName) || " ".equals(entryName)) {
+			    return new URL("jar:" + m_urlString + "!/" + ((m_prefix == null) ? "" : m_prefix));
+			}
+            if (entryName != null)
+			{ 
+				final String target = ((entryName.startsWith("/")) ? entryName.substring(1) : entryName);
+				final JarEntry entry = m_jar.getJarEntry(((m_prefix == null) ? "" : m_prefix) + target);
+				if ( entry != null) {
+								URL result = new URL(null, "jar:" + m_urlString + "!/" + ((m_prefix == null) ? "" : m_prefix) + target, new URLStreamHandler() {
+									
+									
+									protected URLConnection openConnection(final URL u) throws IOException {
+										return new java.net.JarURLConnection(u) {
+											
+											public JarFile getJarFile() {
+											    return m_jar;
+											}
+											public void connect() throws IOException {
+												// TODO Auto-generated method stub
+												
+											}
+											
+											public InputStream getInputStream()
+													throws IOException {
+													
+												String extF = u.toExternalForm();
+												JarEntry targetEntry = entry;
+												if (!extF.endsWith(target)) {
+												    extF = extF.substring(extF.indexOf('!') + 2);
+												    if (m_prefix != null) {
+														if (!extF.startsWith(m_prefix)) {
+														    extF = m_prefix + extF;
+														}
+													}
+													targetEntry = m_jar.getJarEntry(extF);
+												}
+												return m_jar.getInputStream(targetEntry);
+											}
+										};
+									}
+								});
+								return result;
+							}
+							else {
+								if (entryName.endsWith("/")) {
+								     return new URL("jar:" + m_urlString + "!/" + ((m_prefix == null) ? "" : m_prefix) + target);
+								}
+							}
+			}
+        }
+        catch (IOException e)
+        {
+            e.printStackTrace();
+        }
+            return null;
+
+    }
+
+}

Added: felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSR.java
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSR.java?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSR.java (added)
+++ felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSR.java Mon Mar 31 16:18:17 2014
@@ -0,0 +1,513 @@
+/*
+ * 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 de.kalpatec.pojosr.framework;
+
+import java.io.File;
+import java.net.JarURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.Version;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.packageadmin.RequiredBundle;
+import org.osgi.service.startlevel.StartLevel;
+
+import de.kalpatec.pojosr.framework.felix.framework.ServiceRegistry;
+import de.kalpatec.pojosr.framework.felix.framework.util.EventDispatcher;
+import de.kalpatec.pojosr.framework.launch.BundleDescriptor;
+import de.kalpatec.pojosr.framework.launch.ClasspathScanner;
+import de.kalpatec.pojosr.framework.launch.PojoServiceRegistry;
+import de.kalpatec.pojosr.framework.launch.PojoServiceRegistryFactory;
+
+public class PojoSR implements PojoServiceRegistry
+{
+    private final BundleContext m_context;
+    private final ServiceRegistry m_reg = new ServiceRegistry(
+            new ServiceRegistry.ServiceRegistryCallbacks()
+            {
+
+                public void serviceChanged(ServiceEvent event,
+                        Dictionary oldProps)
+                {
+                    m_dispatcher.fireServiceEvent(event, oldProps, null);
+                }
+            });
+
+    private final EventDispatcher m_dispatcher = new EventDispatcher(m_reg);
+    private final Map<Long, Bundle> m_bundles =new HashMap<Long, Bundle>();
+    private final Map<String, Bundle> m_symbolicNameToBundle = new HashMap<String, Bundle>();
+    private final Map bundleConfig;
+    public PojoSR(Map config) throws Exception
+    {
+        final Map<String, String> headers = new HashMap<String, String>();
+        headers.put(Constants.BUNDLE_SYMBOLICNAME,
+                "de.kalpatec.pojosr.framework");
+        headers.put(Constants.BUNDLE_VERSION, "0.3.0-SNAPSHOT");
+        headers.put(Constants.BUNDLE_NAME, "System Bundle");
+        headers.put(Constants.BUNDLE_MANIFESTVERSION, "2");
+		headers.put(Constants.BUNDLE_VENDOR, "kalpatec");
+        bundleConfig = new HashMap(config);
+        final Bundle b = new PojoSRBundle(new Revision()
+        {
+
+            @Override
+            public long getLastModified()
+            {
+                // TODO Auto-generated method stub
+                return System.currentTimeMillis();
+            }
+
+            @Override
+            public Enumeration getEntries()
+            {
+                return new Properties().elements();
+            }
+
+            @Override
+            public URL getEntry(String entryName)
+            {
+                return getClass().getClassLoader().getResource(entryName);
+            }
+        }, headers, new Version(0, 0, 1), "file:pojosr", m_reg, m_dispatcher,
+                null, 0, "de.kalpatec.pojosr.framework", m_bundles, getClass()
+                        .getClassLoader(), bundleConfig)
+        {
+        	@Override
+        	public synchronized void start() throws BundleException {
+        		if (m_state != Bundle.RESOLVED) {
+        			return;
+        		}
+        		m_dispatcher.startDispatching();
+        		m_state = Bundle.STARTING;
+
+                m_dispatcher.fireBundleEvent(new BundleEvent(BundleEvent.STARTING,
+                        this));
+                m_context = new PojoSRBundleContext(this, m_reg, m_dispatcher,
+                                m_bundles, bundleConfig);
+                int i = 0;
+                for (Bundle b : m_bundles.values()) {
+                	i++;
+                	try
+                    {
+                        if (b != this)
+                        {
+                            b.start();
+                        }
+                    }
+                    catch (Throwable t)
+                    {
+                    	System.out.println("Unable to start bundle: " + i );
+                    	t.printStackTrace();
+                    }
+                }
+                m_state = Bundle.ACTIVE;
+                m_dispatcher.fireBundleEvent(new BundleEvent(BundleEvent.STARTED,
+                        this));
+
+                m_dispatcher.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.STARTED, this, null));
+        		super.start();
+        	};
+            @Override
+            public synchronized void stop() throws BundleException
+            {
+            	if ((m_state == Bundle.STOPPING) || m_state == Bundle.RESOLVED) {
+            		return;
+
+            	}
+            	else if (m_state != Bundle.ACTIVE) {
+            		throw new BundleException("Can't stop pojosr because it is not ACTIVE");
+            	}
+            	final Bundle systemBundle = this;
+            	Runnable r = new Runnable() {
+
+					public void run() {
+		                m_dispatcher.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING,
+		                		systemBundle));
+		                for (Bundle b : m_bundles.values())
+		                {
+		                    try
+		                    {
+		                        if (b != systemBundle)
+		                        {
+		                            b.stop();
+		                        }
+		                    }
+		                    catch (Throwable t)
+		                    {
+		                        t.printStackTrace();
+		                    }
+		                }
+		                m_dispatcher.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED,
+		                		systemBundle));
+		                m_state = Bundle.RESOLVED;
+		                m_dispatcher.stopDispatching();
+					}
+				};
+				m_state = Bundle.STOPPING;
+				if ("true".equalsIgnoreCase(System.getProperty("de.kalpatec.pojosr.framework.events.sync"))) {
+					r.run();
+				}
+				else {
+					new Thread(r).start();
+				}
+            }
+        };
+        m_symbolicNameToBundle.put(b.getSymbolicName(), b);
+        b.start();
+        b.getBundleContext().registerService(StartLevel.class.getName(),
+                new StartLevel()
+                {
+
+                    public void setStartLevel(int startlevel)
+                    {
+                        // TODO Auto-generated method stub
+
+                    }
+
+                    public void setInitialBundleStartLevel(int startlevel)
+                    {
+                        // TODO Auto-generated method stub
+
+                    }
+
+                    public void setBundleStartLevel(Bundle bundle,
+                            int startlevel)
+                    {
+                        // TODO Auto-generated method stub
+
+                    }
+
+                    public boolean isBundlePersistentlyStarted(Bundle bundle)
+                    {
+                        // TODO Auto-generated method stub
+                        return true;
+                    }
+
+                    public boolean isBundleActivationPolicyUsed(Bundle bundle)
+                    {
+                        // TODO Auto-generated method stub
+                        return false;
+                    }
+
+                    public int getStartLevel()
+                    {
+                        // TODO Auto-generated method stub
+                        return 1;
+                    }
+
+                    public int getInitialBundleStartLevel()
+                    {
+                        // TODO Auto-generated method stub
+                        return 1;
+                    }
+
+                    public int getBundleStartLevel(Bundle bundle)
+                    {
+                        // TODO Auto-generated method stub
+                        return 1;
+                    }
+                }, null);
+
+        b.getBundleContext().registerService(PackageAdmin.class.getName(),
+                new PackageAdmin()
+                {
+
+                    public boolean resolveBundles(Bundle[] bundles)
+                    {
+                        // TODO Auto-generated method stub
+                        return true;
+                    }
+
+                    public void refreshPackages(Bundle[] bundles)
+                    {
+                        m_dispatcher.fireFrameworkEvent(new FrameworkEvent(
+                                FrameworkEvent.PACKAGES_REFRESHED, b, null));
+                    }
+
+                    public RequiredBundle[] getRequiredBundles(
+                            String symbolicName)
+                    {
+                        return null;
+                    }
+
+                    public Bundle[] getHosts(Bundle bundle)
+                    {
+                        // TODO Auto-generated method stub
+                        return null;
+                    }
+
+                    public Bundle[] getFragments(Bundle bundle)
+                    {
+                        // TODO Auto-generated method stub
+                        return null;
+                    }
+
+                    public ExportedPackage[] getExportedPackages(String name)
+                    {
+                        // TODO Auto-generated method stub
+                        return null;
+                    }
+
+                    public ExportedPackage[] getExportedPackages(Bundle bundle)
+                    {
+                        // TODO Auto-generated method stub
+                        return null;
+                    }
+
+                    public ExportedPackage getExportedPackage(String name)
+                    {
+                        // TODO Auto-generated method stub
+                        return null;
+                    }
+
+                    public Bundle[] getBundles(String symbolicName,
+                            String versionRange)
+                    {
+					    Bundle result = m_symbolicNameToBundle.get((symbolicName != null) ? symbolicName.trim() : symbolicName);
+						if (result != null) {
+							return new Bundle[] {result};
+						}
+						return null;
+                    }
+
+                    public int getBundleType(Bundle bundle)
+                    {
+                        return 0;
+                    }
+
+                    public Bundle getBundle(Class clazz)
+                    {
+                        return m_context.getBundle();
+                    }
+                }, null);
+        m_context = b.getBundleContext();
+
+        List<BundleDescriptor> scan = (List<BundleDescriptor>) config
+                .get(PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS);
+
+        if (scan != null)
+        {
+            startBundles(scan);
+		}
+    }
+
+	public void startBundles(List<BundleDescriptor> scan) throws Exception {
+	 for (BundleDescriptor desc : scan)
+            {
+                URL u = new URL(desc.getUrl().toExternalForm()
+                        + "META-INF/MANIFEST.MF");
+                Revision r;
+                if (u.toExternalForm().startsWith("file:"))
+                {
+                    File root = new File(URLDecoder.decode(desc.getUrl()
+                            .getFile(), "UTF-8"));
+                    u = root.toURL();
+                    r = new DirRevision(root);
+                }
+                else
+                {
+                    URLConnection uc = u.openConnection();
+                    if (uc instanceof JarURLConnection)
+                    {
+					    String target = ((JarURLConnection) uc).getJarFileURL().toExternalForm();
+						String prefix = null;
+						if (!("jar:" + target + "!/").equals(desc.getUrl().toExternalForm())) {
+						    prefix = desc.getUrl().toExternalForm().substring(("jar:" + target + "!/").length());
+						}
+                        r = new JarRevision(
+                                ((JarURLConnection) uc).getJarFile(),
+                                ((JarURLConnection) uc).getJarFileURL(),
+								prefix,
+                                uc.getLastModified());
+                    }
+                    else
+                    {
+                        r = new URLRevision(desc.getUrl(), desc.getUrl()
+                                .openConnection().getLastModified());
+                    }
+                }
+                Map<String, String> bundleHeaders = desc.getHeaders();
+				Version osgiVersion = null;
+				try {
+					osgiVersion = Version.parseVersion(bundleHeaders.get(Constants.BUNDLE_VERSION));
+				} catch (Exception ex) {
+					ex.printStackTrace();
+					osgiVersion = Version.emptyVersion;
+				}
+                String sym = bundleHeaders.get(Constants.BUNDLE_SYMBOLICNAME);
+                    if (sym != null)
+                    {
+                        int idx = sym.indexOf(';');
+                        if (idx > 0)
+                        {
+                            sym = sym.substring(0, idx);
+                        }
+						sym = sym.trim();
+                    }
+
+                if ((sym == null)
+                        || !m_symbolicNameToBundle.containsKey( sym ))
+                {
+                    // TODO: framework - support multiple versions
+                    Bundle bundle = new PojoSRBundle(r, bundleHeaders,
+                            osgiVersion, desc.getUrl().toExternalForm(), m_reg,
+                            m_dispatcher,
+                            bundleHeaders.get(Constants.BUNDLE_ACTIVATOR),
+                            m_bundles.size(),
+                            sym,
+                            m_bundles, desc.getClassLoader(), bundleConfig);
+                    if (sym != null)
+                    {
+                        m_symbolicNameToBundle.put(bundle.getSymbolicName(),
+                                bundle);
+                    }
+                }
+
+            }
+
+
+        for (long i = 1; i < m_bundles.size(); i++)
+        {
+            try
+            {
+                m_bundles.get(i).start();
+            }
+            catch (Throwable e)
+            {
+                System.out.println("Unable to start bundle: " + i);
+                e.printStackTrace();
+            }
+        }
+
+	}
+
+    public static void main(String[] args) throws Exception
+    {
+    	Filter filter = null;
+    	Class main = null;
+    	for (int i = 0;(args != null) && (i < args.length) && (i < 2); i++) {
+	    	try {
+	    		filter = FrameworkUtil.createFilter(args[i]);
+	    	} catch (InvalidSyntaxException ie) {
+	    		try {
+	    			main = PojoSR.class.getClassLoader().loadClass(args[i]);
+	    		} catch (Exception ex) {
+	    			throw new IllegalArgumentException("Argument is neither a filter nor a class: " + args[i]);
+	    		}
+	    	}
+    	}
+        Map config = new HashMap();
+        config.put(
+                PojoServiceRegistryFactory.BUNDLE_DESCRIPTORS,
+                (filter != null) ? new ClasspathScanner()
+                        .scanForBundles(filter.toString()) : new ClasspathScanner()
+                        .scanForBundles());
+        new PojoServiceRegistryFactoryImpl().newPojoServiceRegistry(config);
+        if (main != null) {
+        	int count = 0;
+        	if (filter != null) {
+        		count++;
+        	}
+        	if (main != null) {
+        		count++;
+        	}
+        	String[] newArgs = args;
+        	if (count > 0) {
+        		newArgs = new String[args.length - count];
+        		System.arraycopy(args, count, newArgs, 0, newArgs.length);
+        	}
+        	main.getMethod("main", String[].class).invoke(null, (Object) newArgs );
+        }
+    }
+
+    public BundleContext getBundleContext()
+    {
+        return m_context;
+    }
+
+    public void addServiceListener(ServiceListener listener, String filter)
+            throws InvalidSyntaxException
+    {
+        m_context.addServiceListener(listener, filter);
+    }
+
+    public void addServiceListener(ServiceListener listener)
+    {
+        m_context.addServiceListener(listener);
+    }
+
+    public void removeServiceListener(ServiceListener listener)
+    {
+        m_context.removeServiceListener(listener);
+    }
+
+    public ServiceRegistration registerService(String[] clazzes,
+            Object service, Dictionary properties)
+    {
+        return m_context.registerService(clazzes, service, properties);
+    }
+
+    public ServiceRegistration registerService(String clazz, Object service,
+            Dictionary properties)
+    {
+        return m_context.registerService(clazz, service, properties);
+    }
+
+    public ServiceReference[] getServiceReferences(String clazz, String filter)
+            throws InvalidSyntaxException
+    {
+        return m_context.getServiceReferences(clazz, filter);
+    }
+
+    public ServiceReference getServiceReference(String clazz)
+    {
+        return m_context.getServiceReference(clazz);
+    }
+
+    public Object getService(ServiceReference reference)
+    {
+        return m_context.getService(reference);
+    }
+
+    public boolean ungetService(ServiceReference reference)
+    {
+        return m_context.ungetService(reference);
+    }
+}

Added: felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSRBundle.java
URL: http://svn.apache.org/viewvc/felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSRBundle.java?rev=1583367&view=auto
==============================================================================
--- felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSRBundle.java (added)
+++ felix/trunk/pojosr/src/main/java/de/kalpatec/pojosr/framework/PojoSRBundle.java Mon Mar 31 16:18:17 2014
@@ -0,0 +1,659 @@
+/*
+ * 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 de.kalpatec.pojosr.framework;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.framework.startlevel.BundleStartLevel;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleRevisions;
+import org.osgi.framework.wiring.BundleWire;
+import org.osgi.framework.wiring.BundleWiring;
+
+
+import de.kalpatec.pojosr.framework.felix.framework.ServiceRegistry;
+import de.kalpatec.pojosr.framework.felix.framework.util.EventDispatcher;
+import de.kalpatec.pojosr.framework.felix.framework.util.MapToDictionary;
+import de.kalpatec.pojosr.framework.felix.framework.util.StringMap;
+
+class PojoSRBundle implements Bundle, BundleRevisions, BundleRevision
+{
+    private final Revision m_revision;
+    private final Map<String, String> m_manifest;
+    private final Version m_version;
+    private final String m_location;
+    private final Map<Long, Bundle> m_bundles;
+    private final ServiceRegistry m_reg;
+    private final String m_activatorClass;
+    private final long m_id;
+    private final String m_symbolicName;
+    private volatile BundleActivator m_activator = null;
+    volatile int m_state = Bundle.RESOLVED;
+    volatile BundleContext m_context = null;
+    private final EventDispatcher m_dispatcher;
+    private final ClassLoader m_loader;
+    private final Map m_config;
+
+    Revision getRevision()
+    {
+        return m_revision;
+    }
+
+    public PojoSRBundle(Revision revision, Map<String, String> manifest,
+            Version version, String location, ServiceRegistry reg,
+            EventDispatcher dispatcher, String activatorClass, long id,
+            String symbolicName, Map<Long, Bundle> bundles, ClassLoader loader, Map config)
+    {
+        m_revision = revision;
+        m_manifest = manifest;
+        m_version = version;
+        m_location = location;
+        m_reg = reg;
+        m_dispatcher = dispatcher;
+        m_activatorClass = activatorClass;
+        m_id = id;
+        m_symbolicName = symbolicName;
+        bundles.put(m_id, this);
+        m_bundles = bundles;
+        m_loader = loader;
+        m_config = config;
+    }
+
+    public int getState()
+    {
+        return m_state;
+    }
+
+    public void start(int options) throws BundleException
+    {
+        // TODO: lifecycle - fix this
+        start();
+    }
+
+    public synchronized void start() throws BundleException
+    {
+        if (m_state != Bundle.RESOLVED)
+        {
+            if (m_state == Bundle.ACTIVE)
+            {
+                return;
+            }
+            throw new BundleException("Bundle is in wrong state for start");
+        }
+        try
+        {
+            m_state = Bundle.STARTING;
+
+            m_context = new PojoSRBundleContext(this, m_reg, m_dispatcher,
+                    m_bundles, m_config);
+            m_dispatcher.fireBundleEvent(new BundleEvent(BundleEvent.STARTING,
+                    this));
+            if (m_activatorClass != null)
+            {
+                m_activator = (BundleActivator) m_loader.loadClass(
+                        m_activatorClass).newInstance();
+                m_activator.start(m_context);
+            }
+            m_state = Bundle.ACTIVE;
+            m_dispatcher.fireBundleEvent(new BundleEvent(BundleEvent.STARTED,
+                    this));
+        }
+        catch (Throwable ex)
+        {
+            m_state = Bundle.RESOLVED;
+            m_activator = null;
+            m_dispatcher.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED,
+                    this));
+            throw new BundleException("Unable to start bundle", ex);
+        }
+    }
+
+    public void stop(int options) throws BundleException
+    {
+        // TODO: lifecycle - fix this
+        stop();
+    }
+
+    public synchronized void stop() throws BundleException
+    {
+        if (m_state != Bundle.ACTIVE)
+        {
+            if (m_state == Bundle.RESOLVED)
+            {
+                return;
+            }
+            throw new BundleException("Bundle is in wrong state for stop");
+        }
+        try
+        {
+            m_state = Bundle.STOPPING;
+            m_dispatcher.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING,
+                    this));
+            if (m_activator != null)
+            {
+                m_activator.stop(m_context);
+            }
+        }
+        catch (Throwable ex)
+        {
+            throw new BundleException("Error while stopping bundle", ex);
+        }
+        finally
+        {
+            m_reg.unregisterServices(this);
+            m_dispatcher.removeListeners(m_context);
+            m_activator = null;
+            m_context = null;
+            m_state = Bundle.RESOLVED;
+            m_dispatcher.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED,
+                    this));
+        }
+    }
+
+    public void update(InputStream input) throws BundleException
+    {
+        throw new BundleException("pojosr bundles can't be updated");
+    }
+
+    public void update() throws BundleException
+    {
+        throw new BundleException("pojosr bundles can't be updated");
+    }
+
+    public void uninstall() throws BundleException
+    {
+        throw new BundleException("pojosr bundles can't be uninstalled");
+    }
+
+    public Dictionary getHeaders()
+    {
+        return getHeaders(Locale.getDefault().toString());
+    }
+
+    public long getBundleId()
+    {
+        return m_id;
+    }
+
+    public String getLocation()
+    {
+        return m_location;
+    }
+
+    public ServiceReference[] getRegisteredServices()
+    {
+        return m_reg.getRegisteredServices(this);
+    }
+
+    public ServiceReference[] getServicesInUse()
+    {
+        return m_reg.getServicesInUse(this);
+    }
+
+    public boolean hasPermission(Object permission)
+    {
+        // TODO: security - fix this
+        return true;
+    }
+
+    public URL getResource(String name)
+    {
+        // TODO: module - implement this based on the revision
+        URL result = m_loader.getResource(name);
+        return result;
+    }
+
+    public Dictionary getHeaders(String locale)
+    {
+        return new MapToDictionary(getCurrentLocalizedHeader(locale));
+    }
+
+    Map getCurrentLocalizedHeader(String locale)
+    {
+        Map result = null;
+
+        // Spec says empty local returns raw headers.
+        if ((locale == null) || (locale.length() == 0))
+        {
+            result = new StringMap(m_manifest, false);
+        }
+
+        // If we have no result, try to get it from the cached headers.
+        if (result == null)
+        {
+            synchronized (m_cachedHeaders)
+            {
+                // If the bundle is uninstalled, then the cached headers should
+                // only contain the localized headers for the default locale at
+                // the time of uninstall, so just return that.
+                if (getState() == Bundle.UNINSTALLED)
+                {
+                    result = (Map) m_cachedHeaders.values().iterator().next();
+                }
+                // If the bundle has been updated, clear the cached headers.
+                else if (getLastModified() > m_cachedHeadersTimestamp)
+                {
+                    m_cachedHeaders.clear();
+                }
+                // Otherwise, returned the cached headers if they exist.
+                else
+                {
+                    // Check if headers for this locale have already been
+                    // resolved
+                    if (m_cachedHeaders.containsKey(locale))
+                    {
+                        result = (Map) m_cachedHeaders.get(locale);
+                    }
+                }
+            }
+        }
+
+        // If the requested locale is not cached, then try to create it.
+        if (result == null)
+        {
+            // Get a modifiable copy of the raw headers.
+            Map headers = new StringMap(m_manifest, false);
+            // Assume for now that this will be the result.
+            result = headers;
+
+            // Check to see if we actually need to localize anything
+            boolean localize = false;
+            for (Iterator it = headers.values().iterator(); !localize
+                    && it.hasNext();)
+            {
+                if (((String) it.next()).startsWith("%"))
+                {
+                    localize = true;
+                }
+            }
+
+            if (!localize)
+            {
+                // If localization is not needed, just cache the headers and
+                // return
+                // them as-is. Not sure if this is useful
+                updateHeaderCache(locale, headers);
+            }
+            else
+            {
+                // Do localization here and return the localized headers
+                String basename = (String) headers
+                        .get(Constants.BUNDLE_LOCALIZATION);
+                if (basename == null)
+                {
+                    basename = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME;
+                }
+
+                // Create ordered list of files to load properties from
+                List resourceList = createLocalizationResourceList(basename,
+                        locale);
+
+                // Create a merged props file with all available props for this
+                // locale
+                boolean found = false;
+                Properties mergedProperties = new Properties();
+                for (Iterator it = resourceList.iterator(); it.hasNext();)
+                {
+                    URL temp = m_revision.getEntry(it.next() + ".properties");
+                    if (temp != null)
+                    {
+                        found = true;
+                        try
+                        {
+                            mergedProperties.load(temp.openConnection()
+                                    .getInputStream());
+                        }
+                        catch (IOException ex)
+                        {
+                            // File doesn't exist, just continue loop
+                        }
+                    }
+                }
+
+                // If the specified locale was not found, then the spec says we
+                // should
+                // return the default localization.
+                if (!found && !locale.equals(Locale.getDefault().toString()))
+                {
+                    result = getCurrentLocalizedHeader(Locale.getDefault()
+                            .toString());
+                }
+                // Otherwise, perform the localization based on the discovered
+                // properties and cache the result.
+                else
+                {
+                    // Resolve all localized header entries
+                    for (Iterator it = headers.entrySet().iterator(); it
+                            .hasNext();)
+                    {
+                        Map.Entry entry = (Map.Entry) it.next();
+                        String value = (String) entry.getValue();
+                        if (value.startsWith("%"))
+                        {
+                            String newvalue;
+                            String key = value
+                                    .substring(value.indexOf("%") + 1);
+                            newvalue = mergedProperties.getProperty(key);
+                            if (newvalue == null)
+                            {
+                                newvalue = key;
+                            }
+                            entry.setValue(newvalue);
+                        }
+                    }
+
+                    updateHeaderCache(locale, headers);
+                }
+            }
+        }
+
+        return result;
+    }
+
+    private void updateHeaderCache(String locale, Map localizedHeaders)
+    {
+        synchronized (m_cachedHeaders)
+        {
+            m_cachedHeaders.put(locale, localizedHeaders);
+            m_cachedHeadersTimestamp = System.currentTimeMillis();
+        }
+    }
+
+    private final Map m_cachedHeaders = new HashMap();
+    private long m_cachedHeadersTimestamp;
+
+    private static List createLocalizationResourceList(String basename,
+            String locale)
+    {
+        List result = new ArrayList(4);
+
+        StringTokenizer tokens;
+        StringBuffer tempLocale = new StringBuffer(basename);
+
+        result.add(tempLocale.toString());
+
+        if (locale.length() > 0)
+        {
+            tokens = new StringTokenizer(locale, "_");
+            while (tokens.hasMoreTokens())
+            {
+                tempLocale.append("_").append(tokens.nextToken());
+                result.add(tempLocale.toString());
+            }
+        }
+        return result;
+    }
+
+    public String getSymbolicName()
+    {
+        return m_symbolicName;
+    }
+
+    public Class<?> loadClass(String name) throws ClassNotFoundException
+    {
+        return m_loader.loadClass(name);
+    }
+
+    public Enumeration<URL> getResources(String name) throws IOException
+    {
+        // TODO: module - implement this based on the revision
+        return m_loader.getResources(name);
+    }
+
+    public Enumeration<String> getEntryPaths(String path)
+    {
+        return new EntryFilterEnumeration<String>(m_revision, false, path, null, false,
+                false);
+    }
+
+    public URL getEntry(String path)
+    {
+        URL result = m_revision.getEntry(path);
+        return result;
+    }
+
+    public long getLastModified()
+    {
+        return m_revision.getLastModified();
+    }
+
+    public Enumeration<URL> findEntries(String path, String filePattern,
+            boolean recurse)
+    {
+        // TODO: module - implement this based on the revision
+        return new EntryFilterEnumeration<URL>(m_revision, false, path, filePattern,
+                recurse, true);
+    }
+
+    public BundleContext getBundleContext()
+    {
+        return m_context;
+    }
+
+    public Map getSignerCertificates(int signersType)
+    {
+        // TODO: security - fix this
+        return new HashMap();
+    }
+
+    public Version getVersion()
+    {
+        return m_version;
+    }
+
+	public boolean equals(Object o)
+	{
+	     if (o instanceof PojoSRBundle) {
+		     return ((PojoSRBundle) o).m_id == m_id;
+		 }
+		 return false;
+	}
+
+    public int compareTo(Bundle o)
+    {
+        long thisBundleId = this.getBundleId();
+        long thatBundleId = o.getBundleId();
+        return (thisBundleId < thatBundleId ? -1 : (thisBundleId == thatBundleId ? 0 : 1));
+    }
+
+    public <A> A adapt(Class<A> type)
+    {
+        if (type == BundleStartLevel.class)
+        {
+            return (A) new BundleStartLevel() {
+
+                public Bundle getBundle()
+                {
+                    return PojoSRBundle.this;
+                }
+
+                public int getStartLevel()
+                {
+                    // TODO Implement this?
+                    return 1;
+                }
+
+                public void setStartLevel(int startlevel)
+                {
+                    // TODO Implement this?
+                }
+
+                public boolean isPersistentlyStarted()
+                {
+                    return true;
+                }
+
+                public boolean isActivationPolicyUsed()
+                {
+                    return false;
+                }};
+        }
+        else if (type == BundleRevisions.class)
+        {
+            return (A) this;
+        }
+        else if (type == BundleWiring.class)
+        {
+            return (A) this.getWiring();
+        }
+        return null;
+    }
+
+    public File getDataFile(String filename)
+    {
+        return m_context.getDataFile(filename);
+    }
+
+    public String toString()
+    {
+        String sym = getSymbolicName();
+        if (sym != null)
+        {
+            return sym + " [" + getBundleId() +"]";
+        }
+        return "[" + getBundleId() +"]";
+    }
+
+    public Bundle getBundle()
+    {
+        return this;
+    }
+
+    public List<BundleRevision> getRevisions()
+    {
+        return Arrays.asList((BundleRevision) this);
+    }
+
+    public List<BundleCapability> getDeclaredCapabilities(String namespace)
+    {
+        return Collections.emptyList();
+    }
+
+    public List<BundleRequirement> getDeclaredRequirements(String namespace)
+    {
+        return Collections.emptyList();
+    }
+
+    public int getTypes()
+    {
+        if (getHeaders().get(Constants.FRAGMENT_HOST) != null) {
+            return BundleRevision.TYPE_FRAGMENT;
+        }
+        return 0;
+    }
+
+    public BundleWiring getWiring()
+    {
+        return new BundleWiring()
+        {
+
+            public Bundle getBundle()
+            {
+                return PojoSRBundle.this;
+            }
+
+            public Collection<String> listResources(String path, String filePattern, int options)
+            {
+                Collection<String> result = new ArrayList<String>();
+                for (URL u : findEntries(path, filePattern, options))
+                {
+                    result.add(u.toString());
+                }
+                // TODO: implement this
+                return result;
+            }
+
+            public boolean isInUse()
+            {
+                return true;
+            }
+
+            public boolean isCurrent()
+            {
+                return true;
+            }
+
+            public BundleRevision getRevision()
+            {
+                return PojoSRBundle.this;
+            }
+
+            public List<BundleRequirement> getRequirements(String namespace)
+            {
+                return getDeclaredRequirements(namespace);
+            }
+
+            public List<BundleWire> getRequiredWires(String namespace)
+            {
+                return Collections.emptyList();
+            }
+
+            public List<BundleWire> getProvidedWires(String namespace)
+            {
+                return Collections.emptyList();
+            }
+
+            public ClassLoader getClassLoader()
+            {
+                return getClass().getClassLoader();
+            }
+
+            public List<BundleCapability> getCapabilities(String namespace)
+            {
+                return Collections.emptyList();
+            }
+
+            public List<URL> findEntries(String path, String filePattern, int options)
+            {
+                List<URL> result = new ArrayList<URL>();
+                for (Enumeration<URL> e = PojoSRBundle.this.findEntries(path, filePattern, options == BundleWiring.FINDENTRIES_RECURSE); e.hasMoreElements();)
+                {
+                    result.add(e.nextElement());
+                }
+                return result;
+            }
+        };
+    }
+}



Mime
View raw message