Skip to content

Commit

Permalink
♻️ using base class provided in library instead of reheating the same…
Browse files Browse the repository at this point in the history
… soup

Signed-off-by: dseurotech <[email protected]>
  • Loading branch information
dseurotech committed Aug 1, 2024
1 parent 85f8407 commit 37406a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 30 deletions.
4 changes: 4 additions & 0 deletions console/web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-commons</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-commons-jersey-web</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 37406a1

Please sign in to comment.