sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1511243 - /sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
Date Wed, 07 Aug 2013 10:45:40 GMT
Author: desruisseaux
Date: Wed Aug  7 10:45:39 2013
New Revision: 1511243

URL: http://svn.apache.org/r1511243
Log:
Allow external modules to specialize factories (especially TemporalFactory).
This is a temporary workaround while we are waiting for real dependency injection in SIS.

Modified:
    sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java?rev=1511243&r1=1511242&r2=1511243&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DefaultFactories.java
[UTF-8] Wed Aug  7 10:45:39 2013
@@ -86,11 +86,17 @@ public final class DefaultFactories exte
         T factory = type.cast(FACTORIES.get(type));
         if (factory == null && !FACTORIES.containsKey(type)) {
             for (final T candidate : ServiceLoader.load(type)) {
-                if (candidate.getClass().getName().startsWith("org.apache.sis.")) {
+                final Class<?> ct = candidate.getClass();
+                if (ct.getName().startsWith("org.apache.sis.")) {
                     factory = candidate;
                     break;
                 }
-                if (factory == null) {
+                /*
+                 * Select the first provider found in the iteration. If more than one provider
is found,
+                 * select the most specialized type. This is okay only for relatively simple
configurations,
+                 * while we are waiting for a real dependency injection mechanism.
+                 */
+                if (factory == null || factory.getClass().isAssignableFrom(ct)) {
                     factory = candidate;
                 }
             }



Mime
View raw message