diff --git a/console/web/pom.xml b/console/web/pom.xml
index 20bf64faf85..3b560a3a17f 100644
--- a/console/web/pom.xml
+++ b/console/web/pom.xml
@@ -212,6 +212,10 @@
org.eclipse.kapua
kapua-commons
+
+ org.eclipse.kapua
+ kapua-commons-jersey-web
+
org.glassfish.jersey.inject
diff --git a/console/web/src/main/java/org/eclipse/kapua/app/console/server/util/ConsoleListener.java b/console/web/src/main/java/org/eclipse/kapua/app/console/server/util/ConsoleListener.java
index ea391e2de3a..8d55042d415 100644
--- a/console/web/src/main/java/org/eclipse/kapua/app/console/server/util/ConsoleListener.java
+++ b/console/web/src/main/java/org/eclipse/kapua/app/console/server/util/ConsoleListener.java
@@ -12,25 +12,21 @@
*******************************************************************************/
package org.eclipse.kapua.app.console.server.util;
-import org.eclipse.kapua.KapuaException;
-import org.eclipse.kapua.commons.core.ServiceModuleBundle;
-import org.eclipse.kapua.locator.KapuaLocator;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.eclipse.kapua.commons.jersey.web.ServiceBundleContextListener;
import org.eclipse.kapua.service.scheduler.quartz.SchedulerServiceInit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-
/**
* @since 1.0.0
*/
-public class ConsoleListener implements ServletContextListener {
+public class ConsoleListener extends ServiceBundleContextListener implements ServletContextListener {
private static final Logger LOG = LoggerFactory.getLogger(ConsoleListener.class);
- private ServiceModuleBundle moduleBundle;
-
@Override
public void contextInitialized(final ServletContextEvent event) {
// Start Quartz scheduler
@@ -44,32 +40,13 @@ public void contextInitialized(final ServletContextEvent event) {
}
// Start service modules
- try {
- LOG.info("Starting service modules...");
- if (moduleBundle == null) {
- moduleBundle = KapuaLocator.getInstance().getComponent(ServiceModuleBundle.class);
- }
- moduleBundle.startup();
- LOG.info("Starting service modules... DONE!");
- } catch (Exception e) {
- LOG.error("Starting service modules... ERROR! Error: {}", e.getMessage(), e);
- throw new ExceptionInInitializerError(e);
- }
+ initServiceModuleBundles();
}
@Override
public void contextDestroyed(final ServletContextEvent event) {
// Stop event modules
- try {
- LOG.info("Stopping service modules...");
- if (moduleBundle != null) {
- moduleBundle.shutdown();
- moduleBundle = null;
- }
- LOG.info("Stopping service modules... DONE!");
- } catch (KapuaException e) {
- LOG.error("Stopping service modules... ERROR! Error: {}", e.getMessage(), e);
- }
+ stopServiceModuleBundles();
// Stop Quartz scheduler
try {