You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ri...@apache.org on 2010/03/05 13:42:26 UTC
svn commit: r919392 [2/2] - in /geronimo/specs/trunk/geronimo-osgi-support:
./ geronimo-osgi-locator-itests/ geronimo-osgi-locator-itests/src/
geronimo-osgi-locator-itests/src/test/
geronimo-osgi-locator-itests/src/test/java/ geronimo-osgi-locator-ites...
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget2.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget2.java?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget2.java (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget2.java Fri Mar 5 12:42:25 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.osgi.registry;
+
+public class TestTarget2 {
+ public TestTarget2() {
+ }
+
+ @Override
+ /**
+ * The toString method is a simple means for determining
+ * which class has been instantiated without requiring
+ * interface classes to be exported by the test bundles.
+ *
+ * @return The unique identifier for this class.
+ */
+ public String toString() {
+ return "TestTarget2";
+ }
+}
+
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget2.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget2.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget2.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget3.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget3.java?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget3.java (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget3.java Fri Mar 5 12:42:25 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.osgi.registry;
+
+public class TestTarget3 {
+ public TestTarget3() {
+ }
+
+ @Override
+ /**
+ * The toString method is a simple means for determining
+ * which class has been instantiated without requiring
+ * interface classes to be exported by the test bundles.
+ *
+ * @return The unique identifier for this class.
+ */
+ public String toString() {
+ return "TestTarget3";
+ }
+}
+
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget3.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget3.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTarget3.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTargetTwo.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTargetTwo.java?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTargetTwo.java (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTargetTwo.java Fri Mar 5 12:42:25 2010
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.osgi.registry;
+
+public class TestTargetTwo {
+ public TestTargetTwo() {
+ }
+
+ @Override
+ /**
+ * The toString method is a simple means for determining
+ * which class has been instantiated without requiring
+ * interface classes to be exported by the test bundles.
+ *
+ * @return The unique identifier for this class.
+ */
+ public String toString() {
+ return "TestTargetTwo";
+ }
+}
+
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTargetTwo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTargetTwo.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/java/org/apache/geronimo/osgi/registry/TestTargetTwo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.DefaultTarget
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.DefaultTarget?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.DefaultTarget (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.DefaultTarget Fri Mar 5 12:42:25 2010
@@ -0,0 +1 @@
+# Tests default class mapping...there are no class definitions here
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.MultipleTarget
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.MultipleTarget?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.MultipleTarget (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.MultipleTarget Fri Mar 5 12:42:25 2010
@@ -0,0 +1,4 @@
+# Tests normal class mapping....
+org.apache.geronimo.osgi.registry.TestTarget
+# using multiple provider definitions for a single key
+org.apache.geronimo.osgi.registry.TestTarget2
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.TestTarget
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.TestTarget?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.TestTarget (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.TestTarget Fri Mar 5 12:42:25 2010
@@ -0,0 +1,2 @@
+# Tests normal class mapping....
+org.apache.geronimo.osgi.registry.TestTarget
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.TestTarget2
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.TestTarget2?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.TestTarget2 (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry-itests/src/test/resources/test/OSGI-INF/providers/org.apache.geronimo.osgi.registry.TestTarget2 Fri Mar 5 12:42:25 2010
@@ -0,0 +1 @@
+org.apache.geronimo.osgi.registry.TestTargetTwo # Used as an override to map TestTarget to TestTargetTwo
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/pom.xml?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/pom.xml (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/pom.xml Fri Mar 5 12:42:25 2010
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<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.geronimo.specs</groupId>
+ <artifactId>geronimo-osgi-support</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-osgi-registry</artifactId>
+ <packaging>bundle</packaging>
+ <name>OSGI factory registry</name>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <description>
+This bundle contains an extender that facilitates the use
+of Geronimo spec providers (components typically plugged in to the
+JRE through META-INF/services resources). The service created by this
+extender will maintain a registry of factory class implementations that
+can be used by the spec bundles to locate factory classes that reside in
+other bundles.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>org.apache.geronimo.osgi.registry.api;version=1.0</Export-Package>
+ <Import-Package>*</Import-Package>
+ <Private-Package>org.apache.geronimo.osgi.registry</Private-Package>
+ <Bundle-SymbolicName>${groupId}.${artifactId};singleton=true</Bundle-SymbolicName>
+ <Bundle-Activator>org.apache.geronimo.osgi.registry.Activator</Bundle-Activator>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/pom.xml
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/Activator.java?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/Activator.java (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/Activator.java Fri Mar 5 12:42:25 2010
@@ -0,0 +1,40 @@
+/**
+ * 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.geronimo.osgi.locator;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+
+public class Activator implements BundleActivator {
+ private BundleContext bundleContext;
+
+ public synchronized void start(BundleContext bundleContext) throws Exception {
+ this.bundleContext = bundleContext;
+ // initialize the locator
+ ProviderLocator.init(bundleContext);
+ }
+
+ public synchronized void stop(BundleContext bundleContext) throws Exception {
+ // shut down the locator service
+ ProviderLocator.destroy();
+ this.bundleContext = null;
+ }
+
+ public void bundleChanged(BundleEvent event) {
+ // nothing to change here
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/Activator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/Activator.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/Activator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java Fri Mar 5 12:42:25 2010
@@ -0,0 +1,115 @@
+/**
+ * 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.geronimo.osgi.locator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.geronimo.osgi.registry.api.ProviderRegistry;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class ProviderLocator {
+ // our bundle context
+ static private BundleContext context;
+ // a service tracker for the registry service
+ // NB: This is declared as just Object to avoid classloading issues if we're running
+ // outside of an OSGi environment.
+ static private Object registryTracker;
+
+ private ProviderLocator() {
+ // private constructor to prevent an instance from getting created.
+ }
+
+ /**
+ * initialize the tracker statics for this bundle
+ *
+ * @param c The starup BundleContext.
+ */
+ public static void init(BundleContext c) {
+ context = c;
+ // just create a tracker for our lookup service
+ registryTracker = new ServiceTracker(context, ProviderRegistry.class.getName(), null);
+ ((ServiceTracker)registryTracker).open();
+ }
+
+
+ /**
+ * Cleanup resources on bundle shutdown.
+ */
+ public static void destroy() {
+ // shutdown our tracking of the provider registry.
+ ((ServiceTracker)registryTracker).close();
+ registryTracker = null;
+ }
+
+
+ /**
+ * Locate a class by its provider id indicator. .
+ *
+ * @param providerId The provider id (generally, a fully qualified class name).
+ *
+ * @return The Class corresponding to this provider id. Returns null
+ * if this is not registered or the indicated class can't be
+ * loaded.
+ */
+ static public Class<?> locate(String providerId) {
+ // if not initialized in an OSGi environment, this is a failure
+ if (registryTracker == null) {
+ return null;
+ }
+ // get the service, if it exists. NB: if the tracker exists, then we
+ // were able to load the interface class in the first place, so we don't
+ // need to protect against that.
+ ProviderRegistry registry = (ProviderRegistry)((ServiceTracker)registryTracker).getService();
+ // it is also a failure if the service is not there.
+ if (registry == null) {
+ return null;
+ }
+ // the rest of the work is done by the registry
+ return registry.locate(providerId);
+ }
+
+ /**
+ * Locate all class files that match a given factory id.
+ *
+ * @param providerId The target provider identifier.
+ *
+ * @return A List containing the class objects corresponding to the
+ * provider identifier. Returns an empty list if no
+ * matching classes can be located.
+ */
+ static public List<Class<?>> locateAll(String providerId) {
+ // if not initialized in an OSGi environment, this is a lookup failure
+ if (registryTracker == null) {
+ return new ArrayList<Class<?>>();
+ }
+ // get the service, if it exists. NB: if the tracker exists, then we
+ // were able to load the interface class in the first place, so we don't
+ // need to protect against that.
+ ProviderRegistry registry = (ProviderRegistry)((ServiceTracker)registryTracker).getService();
+ // it is also a failure if the service is not there.
+ if (registry == null) {
+ return new ArrayList<Class<?>>();
+ }
+ // the rest of the work is done by the registry
+ return registry.locateAll(providerId);
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java Fri Mar 5 12:42:25 2010
@@ -0,0 +1,119 @@
+/**
+ * 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.geronimo.osgi.registry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.BundleTracker;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+import org.apache.geronimo.osgi.registry.api.ProviderRegistry;
+
+/**
+ * The activator that starts and manages the life-cycle of
+ * the class factory registry.
+ */
+public class Activator implements BundleActivator {
+ // tracker to watch for bundle updates
+ protected BundleTracker bt;
+ // service tracker for a logging service
+ protected ServiceTracker lst;
+ // Our provider registry
+ protected ProviderRegistryImpl registry;
+ // The service registration for the provider registry
+ protected ServiceRegistration registryRegistration;
+ // our bundle context
+ protected BundleContext context;
+ // an array of all active logging services.
+ List<LogService> logServices = new ArrayList<LogService>();
+
+
+ @Override
+ public synchronized void start(final BundleContext context) throws Exception {
+ this.context = context;
+ lst = new LogServiceTracker(context, LogService.class.getName(), null);
+ lst.open();
+
+ registry = new ProviderRegistryImpl(this);
+ // register this as a service
+ registryRegistration = context.registerService(ProviderRegistry.class.getName(), registry, null);
+
+ org.osgi.framework.ServiceReference ref = context.getServiceReference(ProviderRegistry.class.getName());
+
+ bt = new BundleTracker(context, Bundle.ACTIVE, new ProviderBundleTrackerCustomizer(this, context.getBundle(), registry));
+ bt.open();
+ }
+
+ @Override
+ public synchronized void stop(BundleContext context) throws Exception {
+ bt.close();
+ lst.close();
+ registryRegistration.unregister();
+ }
+
+ void log(int level, String message) {
+ synchronized (logServices) {
+ for (LogService log : logServices) {
+ log.log(level, message);
+ }
+ }
+ }
+
+ void log(int level, String message, Throwable th) {
+ synchronized (logServices) {
+ for (LogService log : logServices) {
+ log.log(level, message, th);
+ }
+ }
+ }
+
+ private final class LogServiceTracker extends ServiceTracker {
+ private LogServiceTracker(BundleContext context, String clazz,
+ ServiceTrackerCustomizer customizer) {
+ super(context, clazz, customizer);
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference) {
+ Object svc = super.addingService(reference);
+ if (svc instanceof LogService) {
+ synchronized (logServices) {
+ logServices.add((LogService) svc);
+ }
+ }
+ return svc;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service) {
+ synchronized (logServices) {
+ logServices.remove(service);
+ }
+ super.removedService(reference, service);
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/Activator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java Fri Mar 5 12:42:25 2010
@@ -0,0 +1,91 @@
+/**
+ * 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.geronimo.osgi.registry;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+
+public class ProviderBundleTrackerCustomizer implements BundleTrackerCustomizer {
+ // our base Activator (used as a service source)
+ private Activator activator;
+ // the bundle hosting this registry
+ private Bundle registryBundle;
+ // the registry we interact with
+ private ProviderRegistryImpl registry;
+ // the accumulated list of provider classes
+ private ConcurrentMap<Long, Map<String, Callable<Class>>> providers = new ConcurrentHashMap<Long, Map<String, Callable<Class>>>();
+
+ public ProviderBundleTrackerCustomizer(Activator a, Bundle b, ProviderRegistryImpl r) {
+ activator = a;
+ registryBundle = b;
+ registry = r;
+ }
+
+ /**
+ * Handle the activation of a new bundle.
+ *
+ * @param bundle The source bundle.
+ * @param event The bundle event information.
+ *
+ * @return A return object.
+ */
+ @Override
+ public Object addingBundle(Bundle bundle, BundleEvent event) {
+ log(LogService.LOG_DEBUG, "Bundle Considered for class providers: " + bundle.getSymbolicName());
+ if (bundle.equals(registryBundle)) {
+ return null;
+ }
+
+ return registry.addBundle(bundle);
+ }
+
+ @Override
+ public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
+ // nothing to do here
+ }
+
+ @Override
+ public void removedBundle(Bundle bundle, BundleEvent event, Object object) {
+ // have the registry process this
+ registry.removeBundle(bundle);
+ }
+
+ private void log(int level, String message) {
+ activator.log(level, message);
+ }
+
+ private void log(int level, String message, Throwable th) {
+ activator.log(level, message, th);
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderBundleTrackerCustomizer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderRegistryImpl.java?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderRegistryImpl.java (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderRegistryImpl.java Fri Mar 5 12:42:25 2010
@@ -0,0 +1,338 @@
+/**
+ * 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.geronimo.osgi.registry;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+
+import org.osgi.framework.Bundle;
+import org.osgi.service.log.LogService;
+
+/**
+ * The implementation of the provider registry used to store
+ * the bundle registrations.
+ */
+public class ProviderRegistryImpl implements org.apache.geronimo.osgi.registry.api.ProviderRegistry {
+ // our mapping between a provider id and the implementation information. There
+ // might be a one-to-many relationship between the ids and implementing classes.
+ private Map<String, List<BundleProviderLoader>> providers = new HashMap<String, List<BundleProviderLoader>>();
+ // our list of bundles and a mapping to the set of providers that each bundle
+ // declares
+ private Map<Long, List<BundleProviderLoader>> providerBundles = new HashMap<Long, List<BundleProviderLoader>>();
+
+ // our base Activator (used as a service source)
+ private Activator activator;
+
+ public ProviderRegistryImpl(Activator activator) {
+ this.activator = activator;
+ }
+
+ /**
+ * Add a bundle to the provider registry. This searches
+ * for services information in the OSGI-INF/providers
+ * directory of the bundle and registers this information
+ * in a provider registry. Bundles that need to locate
+ * class instances can use the provider registry to
+ * locate classes that might reside in other bundles.
+ *
+ * @param bundle The source bundle.
+ *
+ * @return A map of the located registrations. Returns null if
+ * this bundle does not contain any providers.
+ */
+ public Object addBundle(Bundle bundle) {
+ // a list for accumulating providers for this bundle
+ List<BundleProviderLoader> list = new ArrayList<BundleProviderLoader>();
+ // look for services definitions in the bundle...we accumulate these as provider class
+ // definitions.
+ Enumeration e = bundle.findEntries("OSGI-INF/providers/", "*", false);
+ if (e != null) {
+ while (e.hasMoreElements()) {
+ final URL u = (URL) e.nextElement();
+ // go parse out the control file
+ parseProviderFile(u, bundle, list);
+ }
+ }
+
+ // if we have providers defined, add each to the global registry and
+ // also keep track of this in the bundle list
+ if (!list.isEmpty()) {
+ providerBundles.put(bundle.getBundleId(), list);
+ // process the registrations for each item
+ for (BundleProviderLoader loader: list) {
+ // add to the mapping table
+ register(loader);
+ }
+ // this will tell the tracker this is a bundle of interest.
+ return list ;
+ }
+ else {
+ // indicate our lack of interest here
+ return null;
+ }
+ }
+
+
+ /**
+ * Parse a provider definition file and create loaders
+ * for all definitions contained within the file.
+ *
+ * @param u The URL of the file
+ * @param bundle The bundle this resides in.
+ * @param bundleProviders
+ * The list used to accumulate the provider definitions.
+ */
+ private void parseProviderFile(URL u, Bundle bundle, List<BundleProviderLoader> bundleProviders) {
+ final String url = u.toString();
+ // ignore directories
+ if (url.endsWith("/")) {
+ return;
+ }
+ // initial size of the provider list. If we don't add any because of parsing the
+ // lines, we can add a default one using the provider id as both key and mapped
+ // provider class.
+ int providerCount = bundleProviders.size();
+ // the identifier used for the provider is the last item in the URL.
+ final String providerId = url.substring(url.lastIndexOf("/") + 1);
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream(), "UTF-8"));
+ String providerClassName = null;
+ // the file can be multiple lines long, with comments. A single file can define multiple providers
+ // for a single key, so we might need to create multiple entries. If the file does not contain any
+ // definition lines, then as a default, we use the providerId as an implementation class also.
+ String line = br.readLine();
+ while (line != null) {
+ // we allow comments on these lines, and a line can be all comment
+ int comment = line.indexOf('#');
+ if (comment != -1) {
+ line = line.substring(0, comment);
+ }
+ line = line.trim();
+ // if there is nothing left on the line after stripping white space and comments, skip this
+ if (line.length() > 0) {
+ // add this to our list
+ bundleProviders.add(new BundleProviderLoader(providerId, line, bundle));
+ }
+ // keep reading until the end.
+ line = br.readLine();
+ }
+ br.close();
+ } catch (IOException e) {
+ // ignore errors and handle as default
+ }
+
+ // if nothing was defined inside the file, then add a default
+ if (providerCount == bundleProviders.size()) {
+ bundleProviders.add(new BundleProviderLoader(providerId, providerId, bundle));
+ }
+ }
+
+
+ /**
+ * Remove a bundle from the registry.
+ *
+ * @param bundle The target bundle.
+ */
+ public void removeBundle(Bundle bundle) {
+ List<BundleProviderLoader> list = providerBundles.remove(bundle.getBundleId());
+ if (list != null) {
+ for (BundleProviderLoader loader : list) {
+ // unregistry the individual entry
+ unregister(loader);
+ }
+ }
+ }
+
+ /**
+ * Removed a provider registration for a named provider id.
+ *
+ * @param id The target id
+ * @param provider The provider registration instance
+ */
+ public synchronized void unregister(BundleProviderLoader provider) {
+ log(LogService.LOG_DEBUG, "unregistering provider " + provider);
+ if (providers != null) {
+ // this is stored as a list. Just remove using the registration information
+ // This may move a different provider to the front of the list.
+ List<BundleProviderLoader> l = providers.get(provider.id());
+ if (l != null) {
+ l.remove(provider);
+ }
+ }
+ }
+
+
+ /**
+ * Register an individual provivider item by its provider identifier.
+ *
+ * @param id The provider id.
+ * @param provider The loader used to resolve the provider class.
+ */
+ public synchronized void register(BundleProviderLoader provider) {
+ log(LogService.LOG_DEBUG, "registering provider " + provider);
+ // if this is the first registration, create the mapping table
+ if (providers == null) {
+ providers = new HashMap<String, List<BundleProviderLoader>>();
+ }
+
+ String providerId = provider.id();
+
+ // the providers are stored as a list...we use the first one registered
+ // when asked to locate.
+ List<BundleProviderLoader> l = providers.get(providerId);
+ if (l == null) {
+ l = new ArrayList<BundleProviderLoader>();
+ providers.put(providerId, l);
+ }
+ l.add(provider);
+ }
+
+
+ /**
+ * Locate a class by its provider id indicator. .
+ *
+ * @param providerId The provider id (generally, a fully qualified class name).
+ *
+ * @return The Class corresponding to this provider id. Returns null
+ * if this is not registered or the indicated class can't be
+ * loaded.
+ */
+ public synchronized Class<?> locate(String providerId) {
+ if (providers != null) {
+ List<BundleProviderLoader> l = providers.get(providerId);
+ if (l != null && !l.isEmpty()) {
+ // we always use the first one registered
+ BundleProviderLoader c = l.get(0);
+ try {
+ // this loads the class from the hosting bundle.
+ return c.call();
+ } catch (Exception e) {
+ log(LogService.LOG_DEBUG, "Exception loading provider " + this, e);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Locate all class files that match a given provider id.
+ *
+ * @param providerId The target provider identifier.
+ *
+ * @return A List containing the class objects corresponding to the
+ * provider identifier. Returns an empty list if no
+ * matching classes can be located.
+ */
+ public synchronized List<Class<?>> locateAll(String providerId) {
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ if (providers != null) {
+ List<BundleProviderLoader> l = providers.get(providerId);
+ if (l != null) {
+ for (BundleProviderLoader c : l) {
+ try {
+ classes.add(c.call());
+ } catch (Exception e) {
+ log(LogService.LOG_DEBUG, "Exception loading " + c, e);
+ }
+ }
+ }
+ }
+ return classes;
+ }
+
+ private void log(int level, String message) {
+ activator.log(level, message);
+ }
+
+ private void log(int level, String message, Throwable th) {
+ activator.log(level, message, th);
+ }
+
+
+ /**
+ * Holder class for located services information.
+ */
+ private class BundleProviderLoader implements Callable<Class<?>> {
+ // the class name for this provider
+ private final String providerId;
+ // the mapped class name of the provider.
+ private final String providerClass;
+ // the hosting bundle.
+ private final Bundle bundle;
+
+ /**
+ * Create a loader for this registered provider.
+ *
+ * @param providerId The provider ID
+ * @param providerClass The mapped class name of the provider.
+ * @param bundle The hosting bundle.
+ */
+ public BundleProviderLoader(String providerId, String providerClass, Bundle bundle) {
+ this.providerId = providerId;
+ this.providerClass = providerClass;
+ this.bundle = bundle;
+ }
+
+ public Class<?> call() throws Exception {
+ try {
+ log(LogService.LOG_DEBUG, "creating provider for: " + this);
+ return bundle.loadClass(providerClass);
+ } catch (Exception e) {
+ e.printStackTrace();
+ log(LogService.LOG_DEBUG, "exception caught while creating " + this, e);
+ throw e;
+ } catch (Error e) {
+ e.printStackTrace();
+ log(LogService.LOG_DEBUG, "error caught while creating " + this, e);
+ throw e;
+ }
+ }
+
+ public String id() {
+ return providerId;
+ }
+
+ @Override
+ public String toString() {
+ return "Provider interface=" + providerId + " ,provider class=" + providerClass;
+ }
+
+ @Override
+ public int hashCode() {
+ return providerId.hashCode() + providerClass.hashCode() + (int)bundle.getBundleId();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof BundleProviderLoader) {
+ return providerId.equals(((BundleProviderLoader)obj).providerId) &&
+ providerClass.equals(((BundleProviderLoader)obj).providerClass) &&
+ bundle.getBundleId() == ((BundleProviderLoader)obj).bundle.getBundleId();
+ } else {
+ return false;
+ }
+ }
+ }
+}
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderRegistryImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderRegistryImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/ProviderRegistryImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java?rev=919392&view=auto
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java (added)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java Fri Mar 5 12:42:25 2010
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.osgi.registry.api;
+
+import java.util.List;
+
+/**
+ * The implementation of the factory registry used to store
+ * the bundle registrations.
+ */
+public interface ProviderRegistry {
+ /**
+ * Locate a class by its factory id indicator. .
+ *
+ * @param factoryId The factory id (generally, a fully qualified class name).
+ *
+ * @return The Class corresponding to this factory id. Returns null
+ * if this is not registered or the indicated class can't be
+ * loaded.
+ */
+ public Class<?> locate(String factoryId);
+
+ /**
+ * Locate all class files that match a given factory id.
+ *
+ * @param factoryId The target factory identifier.
+ *
+ * @return A List containing the class objects corresponding to the
+ * factory identifier. Returns an empty list if no
+ * matching classes can be located.
+ */
+ public List<Class<?>> locateAll(String factoryId);
+}
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-registry/src/main/java/org/apache/geronimo/osgi/registry/api/ProviderRegistry.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/specs/trunk/geronimo-osgi-support/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/pom.xml?rev=919392&r1=919391&r2=919392&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/pom.xml (original)
+++ geronimo/specs/trunk/geronimo-osgi-support/pom.xml Fri Mar 5 12:42:25 2010
@@ -32,17 +32,13 @@
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-osgi-support</artifactId>
- <packaging>bundle</packaging>
- <name>OSGI factory registry</name>
+ <packaging>pom</packaging>
+ <name>OSGI spec bundle support</name>
<version>1.0.0-SNAPSHOT</version>
<description>
-This bundle contains an extender that facilitates the use
-of Geronimo spec providers (components typically plugged in to the
-JRE through META-INF/services resources). The service created by this
-extender will maintain a registry of factory class implementations that
-can be used by the spec bundles to locate factory classes that reside in
-other bundles.
+This project is a set of bundles and integration tests for implementing
+OSGi-specific lookup in the Geronimo spec projects.
</description>
<url>http://geronimo.apache.org/maven/${siteId}/${version}</url>
@@ -63,146 +59,127 @@
<url>http://svn.apache.org/viewcvs.cgi/geronimo/specs/trunk/geronimo-osgi-support/</url>
</scm>
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>4.2.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>4.2.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-default</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-junit-extender-impl</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.swissbox</groupId>
- <artifactId>pax-swissbox-tinybundles</artifactId>
- <version>1.2.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.logging</groupId>
- <artifactId>pax-logging-api</artifactId>
- <version>1.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <version>1.2.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-osgi-registry</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-osgi-locator</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit-extender-impl</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.swissbox</groupId>
+ <artifactId>pax-swissbox-tinybundles</artifactId>
+ <version>1.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.logging</groupId>
+ <artifactId>pax-logging-api</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <version>1.2.4</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<build>
- <plugins>
- <plugin>
- <groupId>org.apache.servicemix.tooling</groupId>
- <artifactId>depends-maven-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>generate-depends-file</id>
- <goals>
- <goal>generate-depends-file</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Export-Package>org.apache.geronimo.osgi.registry.api;version=1.0</Export-Package>
- <Import-Package>
- *
- </Import-Package>
- <Private-Package>
- org.apache.geronimo.osgi.registry,org.apache.geronimo.osgi.locator
- </Private-Package>
- <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.apache.geronimo.osgi.registry.Activator</Bundle-Activator>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <failIfNoTests>false</failIfNoTests>
- <includes>
- <include>**/NonOSGi*.java</include>
- </includes>
- <excludes>
- <exclude>**/OSGi*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>failsafe-maven-plugin</artifactId>
- <version>2.4.3-alpha-1</version>
- <executions>
- <execution>
- <id>integration-test</id>
- <goals>
- <goal>integration-test</goal>
- </goals>
- </execution>
- <execution>
- <id>verify</id>
- <goals>
- <goal>verify</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <redirectTestOutputToFile>true</redirectTestOutputToFile>
- <failIfNoTests>false</failIfNoTests>
- <includes>
- <include>**/OSGiLocatorTest.java</include>
- <include>**/OSGiLocatorMultipleProviderTest.java</include>
- </includes>
- <excludes>
- <exclude>**/NonOSGi*.java</exclude>
- </excludes>
- <systemProperties>
- <property>
- <name>build.bundle.name</name>
- <value>${basedir}/target/${project.artifactId}-${project.version}.jar</value>
- </property>
- </systemProperties>
- </configuration>
- </plugin>
- </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.servicemix.tooling</groupId>
+ <artifactId>depends-maven-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>generate-depends-file</id>
+ <goals>
+ <goal>generate-depends-file</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <failIfNoTests>false</failIfNoTests>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>failsafe-maven-plugin</artifactId>
+ <version>2.4.3-alpha-1</version>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>verify</id>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <failIfNoTests>false</failIfNoTests>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
+ <modules>
+ <module>geronimo-osgi-registry</module>
+ <module>geronimo-osgi-locator</module>
+ <module>geronimo-osgi-registry-itests</module>
+ <module>geronimo-osgi-locator-itests</module>
+ </modules>
+
</project>