tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ple...@apache.org
Subject [02/23] incubator-tamaya-sandbox git commit: Added logging support.
Date Sun, 25 Sep 2016 21:35:42 GMT
Added logging support.


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

Branch: refs/heads/master
Commit: 6e6419cb5f6f8c42cf984702e1110ed7bdf586e9
Parents: 9c922df
Author: anatole <anatole@apache.org>
Authored: Sun Sep 27 23:52:56 2015 +0200
Committer: anatole <anatole@apache.org>
Committed: Sun Sep 27 23:52:56 2015 +0200

----------------------------------------------------------------------
 .../internal/CLAwareServiceContext.java         | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/6e6419cb/src/main/java/org/apache/tamaya/clsupport/internal/CLAwareServiceContext.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/tamaya/clsupport/internal/CLAwareServiceContext.java
b/src/main/java/org/apache/tamaya/clsupport/internal/CLAwareServiceContext.java
index c023cff..02caed0 100644
--- a/src/main/java/org/apache/tamaya/clsupport/internal/CLAwareServiceContext.java
+++ b/src/main/java/org/apache/tamaya/clsupport/internal/CLAwareServiceContext.java
@@ -28,6 +28,8 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 
 /**
@@ -45,6 +47,9 @@ import java.util.List;
 @Priority(10)
 public class CLAwareServiceContext extends AbstractClassloaderAwareItemLoader<ServiceContainer>
         implements ServiceContext{
+
+    private static final Logger LOG = Logger.getLogger(CLAwareServiceContext.class.getName());
+
     /**
      * Default location for service loader files.
      */
@@ -75,6 +80,9 @@ public class CLAwareServiceContext extends AbstractClassloaderAwareItemLoader<Se
      */
     @Override
     protected ServiceContainer createItem(ClassLoader classLoader) {
+        if(LOG.isLoggable(Level.INFO)) {
+            LOG.info("Loading services for classloader: " + classLoader);
+        }
         return new ServiceContainer(classLoader);
     }
 
@@ -110,9 +118,15 @@ public class CLAwareServiceContext extends AbstractClassloaderAwareItemLoader<Se
      * @return the item found, or null.
      */
     public <T> T getService(Class<T> serviceType, ClassLoader classLoader) {
+        if(LOG.isLoggable(Level.INFO)) {
+            LOG.info("Evaluating services for classloader: " + classLoader);
+        }
         ServiceContainer container = getItemNoParent(classLoader, true);
         T singleton = container.getSingleton(serviceType);
         if(singleton!=null){
+            if(LOG.isLoggable(Level.FINEST)) {
+                LOG.finest("Evaluated singleton of type " + serviceType.getName() + " to
" + singleton);
+            }
             return singleton;
         }
         Collection<? extends T> services = getServices(serviceType, classLoader);
@@ -124,6 +138,9 @@ public class CLAwareServiceContext extends AbstractClassloaderAwareItemLoader<Se
         if(singleton!=null) {
             container.setSingleton(serviceType, singleton);
         }
+        if(LOG.isLoggable(Level.FINEST)) {
+            LOG.finest("Evaluated singleton of type " + serviceType.getName() + " to " +
singleton);
+        }
         return singleton;
     }
 
@@ -164,6 +181,9 @@ public class CLAwareServiceContext extends AbstractClassloaderAwareItemLoader<Se
             services.addAll(container.getServices(serviceType));
             prevContainers.add(container);
         }
+        if(LOG.isLoggable(Level.FINEST)) {
+            LOG.finest("Evaluated services of type " + serviceType.getName() + " to " + services);
+        }
         return services;
     }
 
@@ -218,6 +238,9 @@ public class CLAwareServiceContext extends AbstractClassloaderAwareItemLoader<Se
         if (priority != null) {
             prio = priority.value();
         }
+        if(LOG.isLoggable(Level.FINEST)) {
+            LOG.finest("Evaluated priority for " + o.getClass().getName() + " to " + prio);
+        }
         return prio;
     }
 


Mime
View raw message