diff --git a/components/extensions/health-check-api/pom.xml b/components/extensions/health-check-api/pom.xml
new file mode 100644
index 000000000..27bf21b09
--- /dev/null
+++ b/components/extensions/health-check-api/pom.xml
@@ -0,0 +1,162 @@
+
+
+
+ 4.0.0
+
+
+ org.wso2.carbon.devicemgt-plugins
+ extensions
+ 5.0.7-SNAPSHOT
+ ../pom.xml
+
+
+ health-check-api
+ 5.0.7-SNAPSHOT
+
+ war
+ Entgra - Health check API
+ http://entgra.io
+
+
+
+
+ maven-compiler-plugin
+
+
+ 1.7
+
+
+
+ maven-war-plugin
+
+ WEB-INF/lib/*cxf*.jar
+ api#health-check#v1.0
+
+
+
+
+
+
+
+ deploy
+
+ compile
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 1.7
+
+
+ compile
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ client
+
+ test
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.2.1
+
+
+ test
+
+ java
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxws
+
+
+ org.apache.cxf
+ cxf-rt-frontend-jaxrs
+
+
+ org.apache.cxf
+ cxf-rt-transports-http
+
+
+ javax.ws.rs
+ jsr311-api
+ provided
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+ provided
+
+
+ org.wso2.carbon
+ org.wso2.carbon.logging
+ provided
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.common
+ provided
+
+
+ org.wso2.carbon.devicemgt
+ org.wso2.carbon.device.mgt.core
+ provided
+
+
+ org.apache.axis2.wso2
+ axis2-client
+
+
+
+
+ javax.servlet
+ servlet-api
+ provided
+
+
+
+
diff --git a/components/extensions/health-check-api/src/main/java/io/entgra/healthcheck/HealthCheck.java b/components/extensions/health-check-api/src/main/java/io/entgra/healthcheck/HealthCheck.java
new file mode 100644
index 000000000..354ff27b2
--- /dev/null
+++ b/components/extensions/health-check-api/src/main/java/io/entgra/healthcheck/HealthCheck.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2020, Entgra (pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (pvt) Ltd. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package io.entgra.healthcheck;
+
+import io.entgra.healthcheck.utils.APIUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
+import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
+import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+
+@Path("/")
+public class HealthCheck {
+
+ private static Log log = LogFactory.getLog(HealthCheck.class);
+
+ @GET
+ public Response check() {
+ try {
+ PrivilegedCarbonContext.startTenantFlow();
+ PrivilegedCarbonContext.getThreadLocalCarbonContext()
+ .setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
+ DeviceManagementProviderService dms = APIUtils.getDeviceManagementService();
+ return Response.ok("OK")
+ .entity(dms.getFunctioningDevicesInSystem()).build();
+ } catch (Exception e) {
+ log.error("Error occurred while invoking health check,", e);
+ return Response.serverError().entity(e.getMessage()).build();
+ } finally {
+ PrivilegedCarbonContext.endTenantFlow();
+ }
+ }
+}
diff --git a/components/extensions/health-check-api/src/main/java/io/entgra/healthcheck/utils/APIUtils.java b/components/extensions/health-check-api/src/main/java/io/entgra/healthcheck/utils/APIUtils.java
new file mode 100644
index 000000000..02f19eabe
--- /dev/null
+++ b/components/extensions/health-check-api/src/main/java/io/entgra/healthcheck/utils/APIUtils.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2020, Entgra (pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (pvt) Ltd. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package io.entgra.healthcheck.utils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
+
+public class APIUtils {
+
+ private static Log log = LogFactory.getLog(APIUtils.class);
+ private static DeviceManagementProviderService deviceManagementProviderService = null;
+
+ public static DeviceManagementProviderService getDeviceManagementService() {
+ if (deviceManagementProviderService == null) {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ deviceManagementProviderService =
+ (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
+ if (deviceManagementProviderService == null) {
+ String msg = "DeviceImpl Management provider service has not initialized.";
+ log.error(msg);
+ throw new IllegalStateException(msg);
+ }
+ }
+ return deviceManagementProviderService;
+ }
+}
diff --git a/components/extensions/health-check-api/src/main/webapp/META-INF/webapp-classloading.xml b/components/extensions/health-check-api/src/main/webapp/META-INF/webapp-classloading.xml
new file mode 100644
index 000000000..92d38b3c7
--- /dev/null
+++ b/components/extensions/health-check-api/src/main/webapp/META-INF/webapp-classloading.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+ false
+
+
+ CXF,Carbon
+
diff --git a/components/extensions/health-check-api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/extensions/health-check-api/src/main/webapp/WEB-INF/cxf-servlet.xml
new file mode 100644
index 000000000..aa0b18716
--- /dev/null
+++ b/components/extensions/health-check-api/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/extensions/health-check-api/src/main/webapp/WEB-INF/web.xml b/components/extensions/health-check-api/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 000000000..cb92ef15d
--- /dev/null
+++ b/components/extensions/health-check-api/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,37 @@
+
+
+
+ Admin-Webapp
+
+ JAX-WS/JAX-RS Health Check Endpoint
+ JAX-WS/JAX-RS Health Check
+ CXFServlet
+
+ org.apache.cxf.transport.servlet.CXFServlet
+
+ 1
+
+
+ CXFServlet
+ /*
+
+
+ 60
+
+
diff --git a/components/extensions/pom.xml b/components/extensions/pom.xml
index 99d0f8572..2fc7633fb 100644
--- a/components/extensions/pom.xml
+++ b/components/extensions/pom.xml
@@ -38,6 +38,7 @@
siddhi-extensions
pull-notification-listeners
remote-session-extension
+ health-check-api
diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceManagementProviderServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceManagementProviderServiceMock.java
index 7caccd4af..9bd50a2f0 100644
--- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceManagementProviderServiceMock.java
+++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.core/src/test/java/org/wso2/carbon/device/mgt/mobile/android/core/mokcs/DeviceManagementProviderServiceMock.java
@@ -757,6 +757,11 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv
return null;
}
+ @Override
+ public int getFunctioningDevicesInSystem() throws DeviceManagementException {
+ return 0;
+ }
+
@Override
public boolean deleteDevices(List deviceIdentifiers)
throws DeviceManagementException, InvalidDeviceException {
diff --git a/features/extensions-feature/io.entgra.health.check.api.feature/pom.xml b/features/extensions-feature/io.entgra.health.check.api.feature/pom.xml
new file mode 100644
index 000000000..212663251
--- /dev/null
+++ b/features/extensions-feature/io.entgra.health.check.api.feature/pom.xml
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+ org.wso2.carbon.devicemgt-plugins
+ extensions-feature
+ 5.0.7-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ io.entgra.health.check.api.feature
+ 5.0.7-SNAPSHOT
+ pom
+ Entgra - Health Check API Feature
+ http://entgra.io
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+ generate-resources
+
+ copy-resources
+
+
+ src/main/resources
+
+
+ resources
+
+ build.properties
+ p2.inf
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy-jaxrs-war
+ package
+
+ copy
+
+
+
+
+ org.wso2.carbon.devicemgt-plugins
+ health-check-api
+ war
+ true
+
+ ${project.build.directory}/maven-shared-archive-resources/webapps/
+
+ api#health-check#v1.0.war
+
+
+
+
+
+
+
+ org.wso2.maven
+ carbon-p2-plugin
+ ${carbon.p2.plugin.version}
+
+
+ p2-feature-generation
+ package
+
+ p2-feature-gen
+
+
+ io.entgra.health.check.api
+ ../../../features/etc/feature.properties
+
+
+ org.wso2.carbon.p2.category.type:server
+ org.eclipse.equinox.p2.type.group:true
+
+
+
+
+
+
+
+
+
diff --git a/features/extensions-feature/io.entgra.health.check.api.feature/src/main/resources/api/health-check.xml b/features/extensions-feature/io.entgra.health.check.api.feature/src/main/resources/api/health-check.xml
new file mode 100755
index 000000000..59c5153ba
--- /dev/null
+++ b/features/extensions-feature/io.entgra.health.check.api.feature/src/main/resources/api/health-check.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+ OK
+
+
+
+
+
+
+
+
+
+
+
diff --git a/features/extensions-feature/io.entgra.health.check.api.feature/src/main/resources/build.properties b/features/extensions-feature/io.entgra.health.check.api.feature/src/main/resources/build.properties
new file mode 100644
index 000000000..e6e21811e
--- /dev/null
+++ b/features/extensions-feature/io.entgra.health.check.api.feature/src/main/resources/build.properties
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2020, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
+#
+# Entgra (pvt) Ltd. licenses this file to you under the Apache License,
+# Version 2.0 (the "License"); you may not use this file except
+# in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+custom = true
diff --git a/features/extensions-feature/io.entgra.health.check.api.feature/src/main/resources/p2.inf b/features/extensions-feature/io.entgra.health.check.api.feature/src/main/resources/p2.inf
new file mode 100644
index 000000000..464f7a84f
--- /dev/null
+++ b/features/extensions-feature/io.entgra.health.check.api.feature/src/main/resources/p2.inf
@@ -0,0 +1,9 @@
+instructions.configure = \
+org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment);\
+org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server);\
+org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
+org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/synapse-configs/);\
+org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/synapse-configs/default/);\
+org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/synapse-configs/default/api/);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.health.check.api_${feature.version}/webapps/api#health-check#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#health-check#v1.0.war,overwrite:true);\
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.health.check.api_${feature.version}/api/health-check.xml,target:${installFolder}/../../deployment/server/synapse-configs/default/api/health-check.xml,overwrite:true);\
\ No newline at end of file
diff --git a/features/extensions-feature/pom.xml b/features/extensions-feature/pom.xml
index 77265a6c8..40cb22ecd 100644
--- a/features/extensions-feature/pom.xml
+++ b/features/extensions-feature/pom.xml
@@ -34,6 +34,7 @@
http://wso2.org
+ io.entgra.health.check.api.feature
org.wso2.carbon.device.mgt.adapter.feature
org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature
org.wso2.carbon.andes.extensions.device.mgt.api.feature
diff --git a/pom.xml b/pom.xml
index 814a1301a..610f45466 100644
--- a/pom.xml
+++ b/pom.xml
@@ -415,6 +415,11 @@
+
+ org.wso2.carbon.devicemgt-plugins
+ health-check-api
+ ${carbon.devicemgt.plugins.version}
+
org.wso2.carbon.devicemgt-plugins
org.wso2.extension.siddhi.device