TAMAYA-304 - If no services came back, use the class's class loader to discover 
services.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/fe4302a2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/fe4302a2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/fe4302a2

Branch: refs/heads/master
Commit: fe4302a2f715cddf5bcb6bf56775c12e9773ba6f
Parents: ec4079d
Author: John D. Ament <[email protected]>
Authored: Wed Sep 20 23:01:16 2017 -0400
Committer: Anatole Tresch <[email protected]>
Committed: Thu Sep 28 22:01:27 2017 +0200

----------------------------------------------------------------------
 .../org/apache/tamaya/core/internal/DefaultServiceContext.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/fe4302a2/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java
----------------------------------------------------------------------
diff --git 
a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java
 
b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java
index b4a059c..7146ccf 100644
--- 
a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java
+++ 
b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java
@@ -20,7 +20,6 @@ package org.apache.tamaya.core.internal;
 
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.spi.ServiceContext;
-import org.osgi.service.component.annotations.Component;
 
 import javax.annotation.Priority;
 import java.io.IOException;
@@ -96,6 +95,11 @@ public final class DefaultServiceContext implements 
ServiceContext {
             for (T t : ServiceLoader.load(serviceType)) {
                 services.add(t);
             }
+            if(services.isEmpty()) {
+                for (T t : ServiceLoader.load(serviceType, 
serviceType.getClassLoader())) {
+                    services.add(t);
+                }
+            }
             Collections.sort(services, 
PriorityServiceComparator.getInstance());
             services = Collections.unmodifiableList(services);
         } catch (ServiceConfigurationError e) {

Reply via email to