This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hc-samples.git

commit 4b56bd1d38443d450fe0e13a747681949004761d
Author: Bertrand Delacretaz <[email protected]>
AuthorDate: Thu Jul 31 08:47:26 2014 +0000

    SLING-3624 - use SlingHealthCheck annotation in AsyncHealthCheckSample
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1614829 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../hc/samples/impl/AsyncHealthCheckSample.java    | 25 +++++++---------------
 ...g.hc.samples.impl.AsyncHealthCheckSample-1.json |  2 +-
 2 files changed, 9 insertions(+), 18 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/hc/samples/impl/AsyncHealthCheckSample.java 
b/src/main/java/org/apache/sling/hc/samples/impl/AsyncHealthCheckSample.java
index 0da48dd..acee4f9 100644
--- a/src/main/java/org/apache/sling/hc/samples/impl/AsyncHealthCheckSample.java
+++ b/src/main/java/org/apache/sling/hc/samples/impl/AsyncHealthCheckSample.java
@@ -17,35 +17,26 @@
  */
 package org.apache.sling.hc.samples.impl;
 
+import java.util.Date;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.ConfigurationPolicy;
-import org.apache.felix.scr.annotations.Properties;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.PropertyUnbounded;
 import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.hc.annotations.SlingHealthCheck;
 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 that demonstrates how to implement asynchronous health checks
- *  that run in the background at regular intervals.
- *  The execute() method stays fast as it just reads a pre-computed value. 
+/** Sample Health Check that uses a cron expression to
+ *  schedule regular async execution. 
  */
-@Component(
+
+@SlingHealthCheck(
         configurationFactory=true,
-        policy=ConfigurationPolicy.REQUIRE,
+        configurationPolicy=ConfigurationPolicy.REQUIRE,
         metatype=true)
-@Properties({
-    @Property(name=HealthCheck.NAME),
-    @Property(name=HealthCheck.TAGS, unbounded=PropertyUnbounded.ARRAY),
-    @Property(name=HealthCheck.MBEAN_NAME),
-    @Property(name=HealthCheck.ASYNC_CRON_EXPRESSION)
-
-})
 @Service
 public class AsyncHealthCheckSample implements HealthCheck {
 
@@ -73,7 +64,7 @@ public class AsyncHealthCheckSample implements HealthCheck {
         
         final FormattingResultLog resultLog = new FormattingResultLog();
 
-        resultLog.debug("{} - counter value is {}", this, value);
+        resultLog.info("{} - counter value set to {} at {}", this, value, new 
Date());
         if(value % 2 != 0) {
             resultLog.warn("Counter value ({}) is not even", value);
         }
diff --git 
a/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.samples.impl.AsyncHealthCheckSample-1.json
 
b/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.samples.impl.AsyncHealthCheckSample-1.json
index 177f374..030ddb3 100644
--- 
a/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.samples.impl.AsyncHealthCheckSample-1.json
+++ 
b/src/main/resources/SLING-CONTENT/apps/hc/demo/install/org.apache.sling.hc.samples.impl.AsyncHealthCheckSample-1.json
@@ -3,5 +3,5 @@
     "hc.name" : "Asynchronous Health Check sample", 
     "hc.tags" : [async],
     "hc.mbean.name" : "AsyncHealthCheckSample", 
-    "hc.async.cronExpression" : "*/20 * * * * ?" 
+    "hc.async.cronExpression" : "*/5 * * * * ?" 
 }

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to