package stroom.startup;

import io.dropwizard.Application;
import io.dropwizard.assets.AssetsBundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import stroom.Config;
import stroom.security.spring.SecurityConfiguration;
import stroom.util.spring.StroomSpringProfiles;
import stroom.util.thread.ThreadScopeContextHolder;

public class App extends Application<Config> {
    public static void main(String[] args) throws Exception {
        new App().run(args);
    }

    @Override
    public void initialize(Bootstrap<Config> bootstrap) {
        bootstrap.addBundle(new AssetsBundle("/webapp", "/stroom/", "stroom.jsp", "webapp"));
    }

    @Override
    public void run(Config configuration, Environment environment) throws Exception {
        // We need to set this otherwise we won't have all the beans we need.
        System.setProperty("spring.profiles.active", String.format("%s,%s", StroomSpringProfiles.PROD, SecurityConfiguration.PROD_SECURITY));

        // We need to prime this otherwise we won't have a thread scope context and bean initialisation will fail
        ThreadScopeContextHolder.createContext();

        ApplicationContexts.configure();
        Servlets.loadInto(environment);
        Filters.loadInto(environment);
        Listeners.loadInto(environment, ApplicationContexts.applicationContext);
        ApplicationContexts.start(environment, configuration);
    }



}

@@ -172,16 +172,69 @@
 onment;%0A
+import org.eclipse.jetty.util.resource.PathResource;%0A
 import s
@@ -247,16 +247,16 @@
 Config;%0A
-
 import s
@@ -401,16 +401,45 @@
 older;%0A%0A
+import java.nio.file.Paths;%0A%0A
 public c
@@ -709,15 +709,8 @@
 , %22/
-stroom/
 %22, %22
@@ -833,32 +833,172 @@
 ows Exception %7B%0A
+        // We want Stroom to use the root path so we need to move Dropwizard's path.%0A        environment.jersey().setUrlPattern(%22/api/*%22);%0A%0A
         // We ne
@@ -1198,24 +1198,25 @@
 ECURITY));%0A%0A
+%0A
         // W
@@ -1552,29 +1552,445 @@
 xts.
-applicationContext
+rootContext);%0A%0A        // If we don't set the baseResource then servlets might not be able to find files.%0A        environment.servlets().setBaseResource(new PathResource(Paths.get(%22src/main/resources/webapp/%22)));%0A%0A        // We need to set the servlet context otherwise there will be no default servlet handling.%0A        ApplicationContexts.applicationContext.setServletContext(environment.getApplicationContext().getServletContext()
 );%0A
+%0A
     
@@ -2048,16 +2048,17 @@
 ation);%0A
+%0A
     %7D%0A%0A%0A

Add super-important app configuration