GERONIMO-6738 support spec v2
diff --git a/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/impl/HealthCheckResponseImpl.java b/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/impl/HealthCheckResponseImpl.java
index 50b5d62..27395d4 100644
--- a/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/impl/HealthCheckResponseImpl.java
+++ b/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/impl/HealthCheckResponseImpl.java
@@ -35,10 +35,15 @@
     }
 
     @Override
+    @JsonbTransient
     public State getState() {
         return state;
     }
 
+    public State getStatus() {
+        return state;
+    }
+
     @JsonbProperty("data")
     public Map<String, Object> getRawData() {
         return data;
diff --git a/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/jaxrs/HealthChecksEndpoint.java b/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/jaxrs/HealthChecksEndpoint.java
index cf4ec47..9498fdf 100644
--- a/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/jaxrs/HealthChecksEndpoint.java
+++ b/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/jaxrs/HealthChecksEndpoint.java
@@ -20,6 +20,8 @@
 
 import java.util.Collection;
 import java.util.List;
+import java.util.function.Consumer;
+import java.util.function.Function;
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
@@ -34,7 +36,7 @@
 @Path("health")
 // @ApplicationScoped
 public class HealthChecksEndpoint {
-    private HealthChecksRegistry registry;
+    private volatile HealthChecksRegistry registry;
 
     public void setRegistry(final HealthChecksRegistry registry) {
         this.registry = registry;
@@ -43,16 +45,40 @@
     @GET
     @Produces(MediaType.APPLICATION_JSON)
     public Response getChecks() {
-        if (registry == null) {
-            registry = HealthChecksRegistry.load();
-        }
+        return toResponse(HealthChecksRegistry::getChecks, r -> {});
+    }
 
-        final List<HealthCheckResponse> checks = registry.getChecks()
-                                                           .stream()
-                                                           .map(HealthCheck::call)
-                                                           .collect(toList());
+    @GET
+    @Path("live")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getLiveChecks() {
+        return toResponse(HealthChecksRegistry::getLiveness, r -> {});
+    }
+
+    @GET
+    @Path("ready")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response getReadyChecks() {
+        return toResponse(HealthChecksRegistry::getReadiness, r -> {});
+    }
+
+    private Response toResponse(final Function<HealthChecksRegistry, Collection<HealthCheck>> extractor,
+                                final Consumer<HealthChecksRegistry> validate) {
+        if (registry == null) {
+            synchronized (this) {
+                if (registry == null) {
+                    registry = HealthChecksRegistry.load();
+                }
+            }
+        }
+        validate.accept(registry);
+
+        final List<HealthCheckResponse> checks = extractor.apply(registry)
+                .stream()
+                .map(HealthCheck::call)
+                .collect(toList());
         final HealthCheckResponse.State globalState = checks.stream()
-                    .reduce(HealthCheckResponse.State.UP, (a, b) -> combine(a, b.getState()), this::combine);
+                .reduce(HealthCheckResponse.State.UP, (a, b) -> combine(a, b.getState()), this::combine);
         return Response.status(globalState == HealthCheckResponse.State.DOWN ? Response.Status.SERVICE_UNAVAILABLE : Response.Status.OK).entity(new AggregatedResponse(globalState, checks)).build();
     }
 
@@ -74,11 +100,6 @@
             return status;
         }
 
-        @Deprecated
-        public HealthCheckResponse.State getOutcome() {
-            return status;
-        }
-
         public Collection<HealthCheckResponse> getChecks() {
             return checks;
         }
diff --git a/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/registry/HealthChecksRegistry.java b/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/registry/HealthChecksRegistry.java
index 4f01ab1..7abf0d5 100644
--- a/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/registry/HealthChecksRegistry.java
+++ b/geronimo-health-common/src/main/java/org/apache/geronimo/microprofile/common/registry/HealthChecksRegistry.java
@@ -24,6 +24,9 @@
 
 public interface HealthChecksRegistry {
     Collection<HealthCheck> getChecks();
+    Collection<HealthCheck> getReadiness();
+    Collection<HealthCheck> getLiveness();
+    boolean isReady();
 
     static HealthChecksRegistry load() {
         final Iterator<HealthChecksRegistry> iterator = ServiceLoader.load(HealthChecksRegistry.class).iterator();
diff --git a/geronimo-health/pom.xml b/geronimo-health/pom.xml
index df861be..91ddc5b 100644
--- a/geronimo-health/pom.xml
+++ b/geronimo-health/pom.xml
@@ -92,7 +92,7 @@
     <dependency>
       <groupId>org.apache.meecrowave</groupId>
       <artifactId>meecrowave-arquillian</artifactId>
-      <version>1.2.3</version>
+      <version>1.2.8</version>
       <scope>test</scope>
       <exclusions>
         <exclusion>
@@ -114,8 +114,11 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.22.1</version>
+        <version>3.0.0-M3</version>
         <configuration>
+          <forkCount>1</forkCount>
+          <reuseForks>true</reuseForks>
+          <trimStackTrace>false</trimStackTrace>
           <dependenciesToScan>
             <dependency>org.eclipse.microprofile.health:microprofile-health-tck</dependency>
           </dependenciesToScan>
diff --git a/geronimo-health/src/main/java/org/apache/geronimo/microprofile/impl/health/cdi/GeronimoHealthExtension.java b/geronimo-health/src/main/java/org/apache/geronimo/microprofile/impl/health/cdi/GeronimoHealthExtension.java
index 78a9b06..946b13b 100644
--- a/geronimo-health/src/main/java/org/apache/geronimo/microprofile/impl/health/cdi/GeronimoHealthExtension.java
+++ b/geronimo-health/src/main/java/org/apache/geronimo/microprofile/impl/health/cdi/GeronimoHealthExtension.java
@@ -23,6 +23,7 @@
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Stream;
 
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.event.Observes;
@@ -32,26 +33,61 @@
 import javax.enterprise.inject.spi.BeforeShutdown;
 import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.ProcessBean;
+import javax.enterprise.util.AnnotationLiteral;
 
 import org.apache.geronimo.microprofile.common.registry.HealthChecksRegistry;
 import org.eclipse.microprofile.health.Health;
 import org.eclipse.microprofile.health.HealthCheck;
+import org.eclipse.microprofile.health.Liveness;
+import org.eclipse.microprofile.health.Readiness;
 
 public class GeronimoHealthExtension implements Extension, HealthChecksRegistry {
     private final Collection<Bean<?>> beans = new ArrayList<>();
+    private final Collection<Bean<?>> livenessBeans = new ArrayList<>();
+    private final Collection<Bean<?>> readinessBeans = new ArrayList<>();
     private final Collection<CreationalContext<?>> contexts = new ArrayList<>();
     private List<HealthCheck> checks;
+    private List<HealthCheck> liveness;
+    private List<HealthCheck> readiness;
+    private boolean started = false;
+
+    private static class LivenessLiteral extends AnnotationLiteral<Liveness> {
+        private static final Annotation INSTANCE = new LivenessLiteral();
+    }
+
+    private static class ReadinessLiteral extends AnnotationLiteral<Readiness> {
+        private static final Annotation INSTANCE = new ReadinessLiteral();
+    }
 
     void findChecks(@Observes final ProcessBean<?> bean) {
-        if (bean.getAnnotated().isAnnotationPresent(Health.class) && bean.getBean().getTypes().contains(HealthCheck.class)) {
+        if (!bean.getBean().getTypes().contains(HealthCheck.class)) {
+            return;
+        }
+        if (bean.getAnnotated().isAnnotationPresent(Health.class)) {
             beans.add(bean.getBean());
         }
+        if (bean.getBean().getQualifiers().contains(LivenessLiteral.INSTANCE)) {
+            livenessBeans.add(bean.getBean());
+        }
+        if (bean.getBean().getQualifiers().contains(ReadinessLiteral.INSTANCE)) {
+            readinessBeans.add(bean.getBean());
+        }
     }
 
     void start(@Observes final AfterDeploymentValidation afterDeploymentValidation, final BeanManager beanManager) {
-        checks = beans.stream()
+        liveness = livenessBeans.stream()
              .map(it -> lookup(it, beanManager))
              .collect(toList());
+        readiness = readinessBeans.stream()
+             .map(it -> lookup(it, beanManager))
+             .collect(toList());
+        checks = Stream.concat(Stream.concat(
+                    beans.stream()
+                        .map(it -> lookup(it, beanManager)),
+                    liveness.stream()),
+                    readiness.stream())
+                .collect(toList());
+        started = true;
     }
 
     void stop(@Observes final BeforeShutdown beforeShutdown) {
@@ -76,9 +112,24 @@
         return checks;
     }
 
+    @Override
+    public Collection<HealthCheck> getReadiness() {
+        return readiness;
+    }
+
+    @Override
+    public Collection<HealthCheck> getLiveness() {
+        return liveness;
+    }
+
+    @Override
+    public boolean isReady() {
+        return started;
+    }
+
     private HealthCheck lookup(final Bean<?> bean, final BeanManager manager) {
         final Class<?> type = bean.getBeanClass() == null ? HealthCheck.class : bean.getBeanClass();
-        final Set<Bean<?>> beans = manager.getBeans(type, bean.getQualifiers().toArray(new Annotation[bean.getQualifiers().size()]));
+        final Set<Bean<?>> beans = manager.getBeans(type, bean.getQualifiers().toArray(new Annotation[0]));
         final Bean<?> resolvedBean = manager.resolve(beans);
         final CreationalContext<Object> creationalContext = manager.createCreationalContext(null);
         if (!manager.isNormalScope(resolvedBean.getScope())) {
diff --git a/pom.xml b/pom.xml
index 2553d32..380b68f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,7 +42,7 @@
   </scm>
 
   <properties>
-    <spec.version>1.0</spec.version>
+    <spec.version>2.0.1</spec.version>
   </properties>
 
   <modules>
@@ -59,7 +59,7 @@
     <dependency>
       <groupId>org.apache.tomcat</groupId>
       <artifactId>tomcat-servlet-api</artifactId>
-      <version>9.0.7</version>
+      <version>9.0.20</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
@@ -71,13 +71,13 @@
     <dependency>
       <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-json_1.1_spec</artifactId>
-      <version>1.0</version>
+      <version>1.2</version>
       <scope>provided</scope>
     </dependency>
     <dependency>
       <groupId>org.apache.geronimo.specs</groupId>
       <artifactId>geronimo-jsonb_1.0_spec</artifactId>
-      <version>1.0</version>
+      <version>1.1</version>
       <scope>provided</scope>
     </dependency>
   </dependencies>
@@ -87,7 +87,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
-        <version>3.8.0</version>
+        <version>3.8.1</version>
         <configuration>
           <source>1.8</source>
           <target>1.8</target>