incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1558772 - /sling/trunk/bundles/extensions/healthcheck/samples/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java
Date Thu, 16 Jan 2014 12:45:40 GMT
Author: bdelacretaz
Date: Thu Jan 16 12:45:40 2014
New Revision: 1558772

URL: http://svn.apache.org/r1558772
Log:
SLING-3278 - add lifecycle logging

Modified:
    sling/trunk/bundles/extensions/healthcheck/samples/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java

Modified: sling/trunk/bundles/extensions/healthcheck/samples/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/samples/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java?rev=1558772&r1=1558771&r2=1558772&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/healthcheck/samples/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java
(original)
+++ sling/trunk/bundles/extensions/healthcheck/samples/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java
Thu Jan 16 12:45:40 2014
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.Atomi
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
+import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Properties;
 import org.apache.felix.scr.annotations.Property;
 import org.apache.felix.scr.annotations.PropertyUnbounded;
@@ -31,6 +32,8 @@ import org.apache.sling.commons.osgi.Pro
 import org.apache.sling.hc.api.HealthCheck;
 import org.apache.sling.hc.api.Result;
 import org.apache.sling.hc.util.FormattingResultLog;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /** Sample Health Check that takes N msec to execute,
  *  used to demonstrate execution timeouts and caching.
@@ -47,6 +50,7 @@ import org.apache.sling.hc.util.Formatti
 @Service(value=HealthCheck.class)
 public class SlowHealthCheckSample implements HealthCheck{
 
+    private final Logger log = LoggerFactory.getLogger(getClass());
     private final AtomicInteger counter = new AtomicInteger();
     private long minExecutionTime;
     private long maxExecutionTime;
@@ -72,6 +76,12 @@ public class SlowHealthCheckSample imple
     protected void activate(Map<String, Object> config) {
         minExecutionTime = PropertiesUtil.toInteger(config.get(PROP_MIN_EXEC_TIME), DEFAULT_MIN_EXEC_TIME);
         maxExecutionTime = PropertiesUtil.toInteger(config.get(PROP_MAX_EXEC_TIME), DEFAULT_MAX_EXEC_TIME);
+        log.debug("{} activated", this);
+    }
+    
+    @Deactivate
+    protected void deactivate(Map<String, Object> config) {
+        log.debug("{} deactivated", this);
     }
     
     @Override
@@ -85,7 +95,9 @@ public class SlowHealthCheckSample imple
         } catch(InterruptedException iex) {
             resultLog.warn("{} during execution", iex.getClass().getSimpleName());
         }
-        resultLog.debug("Done executing, {} has been executed {} times", this, counter.incrementAndGet());
+        final String execMsg = "Done executing, execution counter=" + counter.incrementAndGet();

+        resultLog.debug("{}:{}", this, execMsg);
+        log.debug("{}:{}", this, execMsg);
         return new Result(resultLog);
     }
 }
\ No newline at end of file



Mime
View raw message