geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1521832 - in /geronimo/specs/trunk/geronimo-jbatch_1.0_spec: pom.xml src/main/java/javax/batch/runtime/BatchRuntime.java
Date Wed, 11 Sep 2013 13:43:08 GMT
Author: rmannibucau
Date: Wed Sep 11 13:43:08 2013
New Revision: 1521832

URL: http://svn.apache.org/r1521832
Log:
using ProviderLocator to find the JobOperator

Modified:
    geronimo/specs/trunk/geronimo-jbatch_1.0_spec/pom.xml
    geronimo/specs/trunk/geronimo-jbatch_1.0_spec/src/main/java/javax/batch/runtime/BatchRuntime.java

Modified: geronimo/specs/trunk/geronimo-jbatch_1.0_spec/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jbatch_1.0_spec/pom.xml?rev=1521832&r1=1521831&r2=1521832&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jbatch_1.0_spec/pom.xml (original)
+++ geronimo/specs/trunk/geronimo-jbatch_1.0_spec/pom.xml Wed Sep 11 13:43:08 2013
@@ -63,6 +63,12 @@
       <version>1.0</version>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-osgi-locator</artifactId>
+      <version>1.0</version>
+      <scope>provided</scope>
+    </dependency>
   </dependencies>
 
   <build>
@@ -72,8 +78,13 @@
         <artifactId>maven-bundle-plugin</artifactId>
         <configuration>
           <instructions>
+            <Specification-Version>1.0</Specification-Version>
+            <Specification-Title>JSR-352 JBatch 1.0</Specification-Title>
             <Export-Package>javax.batch*;version=1.0</Export-Package>
+            <Private-Package>org.apache.geronimo.osgi.locator</Private-Package>
+            <Bundle-Activator>org.apache.geronimo.osgi.locator.Activator</Bundle-Activator>
             <Import-Package>
+              org.apache.geronimo.osgi.registry.api;resolution:=optional,
               javax.inject;resolution:=optional,
               javax.enterprise.util;resolution:=optional
             </Import-Package>

Modified: geronimo/specs/trunk/geronimo-jbatch_1.0_spec/src/main/java/javax/batch/runtime/BatchRuntime.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-jbatch_1.0_spec/src/main/java/javax/batch/runtime/BatchRuntime.java?rev=1521832&r1=1521831&r2=1521832&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-jbatch_1.0_spec/src/main/java/javax/batch/runtime/BatchRuntime.java
(original)
+++ geronimo/specs/trunk/geronimo-jbatch_1.0_spec/src/main/java/javax/batch/runtime/BatchRuntime.java
Wed Sep 11 13:43:08 2013
@@ -18,9 +18,13 @@
  */
 package javax.batch.runtime;
 
+import org.apache.geronimo.osgi.locator.ProviderLocator;
+
 import javax.batch.operations.JobOperator;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.Iterator;
+import java.util.List;
 import java.util.ServiceLoader;
 
 public class BatchRuntime {
@@ -36,13 +40,21 @@ public class BatchRuntime {
     }
 
     private static JobOperator findJobOperator() {
-        final ServiceLoader<JobOperator> loader = ServiceLoader.load(JobOperator.class);
-        for (final JobOperator provider : loader) {
+        final Iterator<JobOperator> iterator = operators();
+        while (iterator.hasNext()) {
+            final JobOperator provider = iterator.next();
             if (provider != null) {
-                // Use first one
                 return provider;
             }
         }
         return null;
     }
+
+    private static Iterator<JobOperator> operators() {
+        try {
+            return ((List<JobOperator>) ProviderLocator.getService(JobOperator.class.getName(),
JobOperator.class, Thread.currentThread().getContextClassLoader())).iterator();
+        } catch (final Throwable th) { // rarely case where potentially missing OSGi stuff
+            return ServiceLoader.load(JobOperator.class).iterator();
+        }
+    }
 }



Mime
View raw message