geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r936530 - in /geronimo/yoko/trunk: yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/
Date Wed, 21 Apr 2010 22:01:02 GMT
Author: djencks
Date: Wed Apr 21 22:01:02 2010
New Revision: 936530

URL: http://svn.apache.org/viewvc?rev=936530&view=rev
Log:
GERONIMO-5091 add priority to locator to make it easier to predict what class you'll get

Modified:
    geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/BundleProviderLoader.java
    geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderBean.java
    geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderRegistryImpl.java
    geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ServiceBean.java
    geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml

Modified: geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/BundleProviderLoader.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/BundleProviderLoader.java?rev=936530&r1=936529&r2=936530&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/BundleProviderLoader.java
(original)
+++ geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/BundleProviderLoader.java
Wed Apr 21 22:01:02 2010
@@ -25,7 +25,7 @@ import org.osgi.framework.Bundle;
 /**
  * Holder class for located services information.
  */
-public class BundleProviderLoader {
+public class BundleProviderLoader implements Comparable<BundleProviderLoader> {
     // the class name for this provider
     private final String providerId;
     // the mapped class name of the provider.
@@ -33,17 +33,21 @@ public class BundleProviderLoader {
     // the hosting bundle.
     private final Bundle bundle;
 
+    private final int priority;
+
     /**
      * 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.
+     * @param priority
      */
-    public BundleProviderLoader(String providerId, String providerClass, Bundle bundle) {
+    public BundleProviderLoader(String providerId, String providerClass, Bundle bundle, int
priority) {
         this.providerId = providerId;
         this.providerClass = providerClass;
         this.bundle = bundle;
+        this.priority = priority;
     }
 
     /**
@@ -108,4 +112,8 @@ public class BundleProviderLoader {
             return false;
         }
     }
+
+    public int compareTo(BundleProviderLoader other) {
+        return other.priority - priority;
+    }
 }

Modified: geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderBean.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderBean.java?rev=936530&r1=936529&r2=936530&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderBean.java
(original)
+++ geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderBean.java
Wed Apr 21 22:01:02 2010
@@ -22,7 +22,6 @@ package org.apache.yoko.osgi.locator;
 
 import java.util.logging.Logger;
 
-import org.apache.yoko.osgi.ProviderRegistry;
 import org.osgi.framework.Bundle;
 
 /**
@@ -36,10 +35,18 @@ public class ProviderBean {
     private BundleProviderLoader bundleProviderLoader;
 
     public ProviderBean(String key,
+                       String className,
+                       Bundle bundle,
+                       Register providerRegistry) {
+        this(key, className, bundle, providerRegistry, -1);
+    }
+
+    public ProviderBean(String key,
                         String className,
                         Bundle bundle,
-                        Register providerRegistry) {
-        bundleProviderLoader = new BundleProviderLoader(key, className, bundle);
+                        Register providerRegistry,
+                        Integer priority) {
+        bundleProviderLoader = new BundleProviderLoader(key, className, bundle, priority
== null? -1: priority);
         log.finer("ProviderBean: " + bundleProviderLoader);
         this.providerRegistry = providerRegistry;
     }

Modified: geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderRegistryImpl.java?rev=936530&r1=936529&r2=936530&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderRegistryImpl.java
(original)
+++ geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ProviderRegistryImpl.java
Wed Apr 21 22:01:02 2010
@@ -17,6 +17,7 @@
 package org.apache.yoko.osgi.locator;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -525,10 +526,11 @@ public class ProviderRegistryImpl implem
             // when asked to locate.
             List<BundleProviderLoader> l = registry.get(providerId);
             if (l ==  null) {
-                l = new ArrayList<BundleProviderLoader>();
+                l = new ArrayList<BundleProviderLoader>(2);
                 registry.put(providerId, l);
             }
             l.add(provider);
+            Collections.sort(l);
         }
 
         /**

Modified: geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ServiceBean.java
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ServiceBean.java?rev=936530&r1=936529&r2=936530&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ServiceBean.java
(original)
+++ geronimo/yoko/trunk/yoko-osgi/src/main/java/org/apache/yoko/osgi/locator/ServiceBean.java
Wed Apr 21 22:01:02 2010
@@ -35,10 +35,18 @@ public class ServiceBean {
     private BundleProviderLoader bundleProviderLoader;
 
     public ServiceBean(String key,
-                        String className,
-                        Bundle bundle,
-                        Register providerRegistry) {
-        bundleProviderLoader = new BundleProviderLoader(key, className, bundle);
+                       String className,
+                       Bundle bundle,
+                       Register providerRegistry) {
+        this(key, className, bundle, providerRegistry, -1);
+    }
+    
+    public ServiceBean(String key,
+                       String className,
+                       Bundle bundle,
+                       Register providerRegistry,
+                       Integer priority) {
+        bundleProviderLoader = new BundleProviderLoader(key, className, bundle, priority
== null? -1: priority);
         log.finer("ServiceBean: " + bundleProviderLoader);
         this.providerRegistry = providerRegistry;
     }

Modified: geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml
URL: http://svn.apache.org/viewvc/geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml?rev=936530&r1=936529&r2=936530&view=diff
==============================================================================
--- geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml (original)
+++ geronimo/yoko/trunk/yoko-rmi-impl/src/main/resources/OSGI-INF/blueprint/provider.xml Wed
Apr 21 22:01:02 2010
@@ -24,11 +24,6 @@ limitations under the License.
 
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
 
-    <!--<service id="yokoRegistry"-->
-             <!--interface="org.apache.yoko.osgi.ProviderRegistry"-->
-             <!--activation="eager">-->
-        <!--<ref component-id="yokoRegistryBean"/>-->
-    <!--</service>-->
     <service id="yokoRegister"
              interface="org.apache.yoko.osgi.locator.Register"
              activation="eager">
@@ -91,6 +86,23 @@ limitations under the License.
             <ref component-id="yokoRegistryBean"/>
         </argument>
     </bean>
+    <bean class="org.apache.yoko.osgi.locator.ServiceBean"
+          activation="eager"
+          init-method="start"
+          destroy-method="stop">
+        <argument>
+            <value>javax.rmi.CORBA.StubClass</value>
+        </argument>
+        <argument>
+            <value>org.apache.yoko.rmi.impl.StubImpl</value>
+        </argument>
+        <argument>
+            <ref component-id="blueprintBundle"/>
+        </argument>
+        <argument>
+            <ref component-id="yokoRegistryBean"/>
+        </argument>
+    </bean>
 
 
 </blueprint>
\ No newline at end of file



Mime
View raw message