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 2fb7b3fcaa54e03d3932f398f32a0ebec1b0f994 Author: Konrad Windszus <[email protected]> AuthorDate: Thu Feb 25 08:31:55 2016 +0000 SLING-4417 allow to configure immediate flag in the healthcheck annotation and use that in some examples git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1732260 13f79535-47bb-0310-9956-ffa450edef68 --- .../hc/samples/impl/AsyncHealthCheckSample.java | 4 +--- .../hc/samples/impl/SlowHealthCheckSample.java | 23 +++------------------- 2 files changed, 4 insertions(+), 23 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 acee4f9..41fa248 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 @@ -42,9 +42,7 @@ public class AsyncHealthCheckSample implements HealthCheck { private final Logger log = LoggerFactory.getLogger(AsyncHealthCheckSample.class); - // static because for factories, not always the same instance is returned for - // the same service reference - private static final AtomicInteger counter = new AtomicInteger(); + private final AtomicInteger counter = new AtomicInteger(); public static final int PERIOD_SECONDS = 5; diff --git a/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java b/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java index 740a62b..b2a2492 100644 --- a/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java +++ b/src/main/java/org/apache/sling/hc/samples/impl/SlowHealthCheckSample.java @@ -21,14 +21,11 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; 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; -import org.apache.felix.scr.annotations.Service; import org.apache.sling.commons.osgi.PropertiesUtil; +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; @@ -39,22 +36,8 @@ import org.slf4j.LoggerFactory; * used to demonstrate execution timeouts and caching. */ -// Need to make the component immediate to make sure a single -// instance is used, otherwise the lazy DS activation policy -// might cause a different instance to be used for every -// execution. In this sample this is just done to allow the -// counter to persist as long as this service's bundle is active. -@Component( - configurationFactory=true, - policy=ConfigurationPolicy.REQUIRE, - metatype=true, - immediate=true) -@Properties({ - @Property(name=HealthCheck.NAME), - @Property(name=HealthCheck.TAGS, unbounded=PropertyUnbounded.ARRAY), - @Property(name=HealthCheck.MBEAN_NAME) -}) -@Service(value=HealthCheck.class) +// The annotation make the component immediate by default now +@SlingHealthCheck(configurationFactory = true, configurationPolicy = ConfigurationPolicy.REQUIRE) public class SlowHealthCheckSample implements HealthCheck{ private final Logger log = LoggerFactory.getLogger(getClass()); -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
