diff --git a/pom.xml b/pom.xml index 135ee4a..69a78d0 100644 --- a/pom.xml +++ b/pom.xml @@ -79,6 +79,11 @@ + + javax.servlet + servlet-api + ${servlet.version} + org.glassfish.jersey.containers jersey-container-servlet @@ -133,5 +138,6 @@ 4.5.3 1.7.21 2.8.9 + 2.5 diff --git a/src/main/java/org/snlab/unicorn/Bootstrap.java b/src/main/java/org/snlab/unicorn/Bootstrap.java new file mode 100644 index 0000000..0c4e0cf --- /dev/null +++ b/src/main/java/org/snlab/unicorn/Bootstrap.java @@ -0,0 +1,27 @@ +package org.snlab.unicorn; + +import java.util.Collection; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.snlab.unicorn.orchestrator.OrchestratorInfo; +import org.snlab.unicorn.orchestrator.OrchestratorInfoReader; +import org.snlab.unicorn.register.UnicornRegister; +import org.snlab.unicorn.register.UnicornRegisterBuilder; + +public class Bootstrap extends HttpServlet { + private final static Logger LOG = LoggerFactory.getLogger(Bootstrap.class); + + @Override + public void init(ServletConfig config) throws ServletException { + LOG.info("Starting bootstrap stage..."); + // Register to orchestrator + Collection infos = OrchestratorInfoReader.read(UnicornDefinitions.OrchestratorConfig.CONFIG_PATH); + UnicornRegister register = new UnicornRegisterBuilder().addOrchestrators(infos).build(); + register.register(); + } +} \ No newline at end of file diff --git a/src/main/java/org/snlab/unicorn/UnicornApplication.java b/src/main/java/org/snlab/unicorn/UnicornApplication.java index 0e71b72..f91fa26 100644 --- a/src/main/java/org/snlab/unicorn/UnicornApplication.java +++ b/src/main/java/org/snlab/unicorn/UnicornApplication.java @@ -2,20 +2,14 @@ import org.glassfish.jersey.media.sse.SseFeature; import org.glassfish.jersey.server.ResourceConfig; -import org.snlab.unicorn.orchestrator.OrchestratorInfo; -import org.snlab.unicorn.orchestrator.OrchestratorInfoReader; -import org.snlab.unicorn.register.UnicornRegister; -import org.snlab.unicorn.register.UnicornRegisterBuilder; - -import java.util.Collection; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class UnicornApplication extends ResourceConfig { + private final static Logger LOG = LoggerFactory.getLogger(UnicornApplication.class); + public UnicornApplication() { super(UnicornService.class, SseFeature.class); - - // Register to orchestrator - Collection infos = OrchestratorInfoReader.read(UnicornDefinitions.OrchestratorConfig.CONFIG_PATH); - UnicornRegister register = new UnicornRegisterBuilder().addOrchestrators(infos).build(); - register.register(); + LOG.info("Starting unicorn application..."); } } diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 2a29821..8699ad9 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -13,6 +13,11 @@ 1 true + + Bootstrap + org.snlab.unicorn.Bootstrap + 2 + Jersey Web Application /experimental/v1/*