Commits

Sam Adams committed dc302c9

Updating for refactored chempound/guice

  • Participants
  • Parent commits f11d781

Comments (0)

Files changed (1)

File src/main/java/uk/ac/cam/ch/wwmm/quixote/QuixoteWebappLauncher.java

 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Module;
-import com.google.inject.servlet.ServletModule;
-import com.hp.hpl.jena.query.Dataset;
-import com.hp.hpl.jena.tdb.TDBFactory;
-import org.apache.commons.io.FileUtils;
 import org.restlet.Application;
 import org.restlet.Component;
-import org.restlet.Context;
 import org.restlet.data.Protocol;
 import uk.ac.cam.ch.wwmm.chempound.DefaultChempoundModule;
 import uk.ac.cam.ch.wwmm.chempound.compchem.CompChemModule;
 import uk.ac.cam.ch.wwmm.chempound.config.ChempoundConfiguration;
 import uk.ac.cam.ch.wwmm.chempound.config.DefaultChempoundConfiguration;
 import uk.ac.cam.ch.wwmm.chempound.crystal.CrystallographyModule;
-import uk.ac.cam.ch.wwmm.chempound.datastore.JenaTripleStore;
-import uk.ac.cam.ch.wwmm.chempound.datastore.TripleStore;
 import uk.ac.cam.ch.wwmm.chempound.plugins.jmol.JmolModule;
 import uk.ac.cam.ch.wwmm.chempound.plugins.jquery.JQueryModule;
-import uk.ac.cam.ch.wwmm.chempound.storage.FileSystemResourceStore;
-import uk.ac.cam.ch.wwmm.chempound.storage.ResourceStore;
-import uk.ac.cam.ch.wwmm.chempound.webapp.ChempoundApplication;
-import uk.ac.cam.ch.wwmm.chempound.webapp.ChempoundServletModule;
-import uk.ac.cam.ch.wwmm.chempound.webapp.DefaultFreemarkerService;
-import uk.ac.cam.ch.wwmm.chempound.webapp.FreemarkerService;
+import uk.ac.cam.ch.wwmm.chempound.webapp.DefaultChempoundWebModule;
 import uk.ac.cam.ch.wwmm.chempound.webapp.search.chemistry.StructureSearchProviderModule;
 
 import java.io.File;
 
         Injector injector = Guice.createInjector(
                 getConfigurationModule(),
-                getChempoundModule(),
-                getServletModule(),
-                getPluginsModule(),
-                getRestletModule()
-
+                new DefaultChempoundModule(),
+                new DefaultChempoundWebModule(),
+                getPluginsModule()
         );
 
         Component component = injector.getInstance(Component.class);
-        component.getContext().getParameters().add("maxThreads", "256");
-        component.getServers().add(Protocol.HTTP, 8181);
-        Application application = injector.getInstance(Application.class);
-        component.getDefaultHost().attach(application);
+        component.getServers().add(Protocol.HTTP, 8181)
+                .getContext().getParameters().add("maxThreads", "256");
+        component.getDefaultHost().attach(injector.getInstance(Application.class));
         component.start();
 
     }
                 try {
                     ChempoundConfiguration config = getConfiguration();
                     bind(ChempoundConfiguration.class).toInstance(config);
-
-                    TripleStore dataStore = getTripleStore(config);
-                    bind(TripleStore.class).toInstance(dataStore);
-
-                    ResourceStore resourceStore = getResourceStore(config);
-                    bind(ResourceStore.class).toInstance(resourceStore);
                 } catch (IOException e) {
                     throw new RuntimeException("Error initialising chempound", e);
                 }
         };
     }
 
-    protected static JenaTripleStore getTripleStore(ChempoundConfiguration config) throws IOException {
-        File dir = new File(config.getWorkspace(), "tdb/");
-        FileUtils.forceMkdir(dir);
-        Dataset dataset = TDBFactory.createDataset(dir.getPath());
-        return new JenaTripleStore(dataset);
-    }
-
-    protected static ResourceStore getResourceStore(ChempoundConfiguration config) throws IOException {
-        File dir = new File(config.getWorkspace(), "content/");
-        FileUtils.forceMkdir(dir);
-        return new FileSystemResourceStore(dir);
-    }
-
     private static ChempoundConfiguration getConfiguration() throws IOException {
         String workspace = System.getProperty("chempound.workspace");
         String baseUri = System.getProperty("chempound.uri");
         return DefaultChempoundConfiguration.load(uri, workspaceDir);
     }
 
-    protected static Module getChempoundModule() {
-        return new DefaultChempoundModule();
-    }
-
-    protected static ServletModule getServletModule() {
-        return new ChempoundServletModule();
-    }
-
     protected static AbstractModule getPluginsModule() {
         return new AbstractModule() {
             @Override
         };
     }
 
-
-    protected static AbstractModule getRestletModule() {
-        return new AbstractModule() {
-            @Override
-            protected void configure() {
-                Component component = new Component();
-                component.getClients().add(Protocol.CLAP);
-                component.getClients().add(Protocol.FILE);
-
-                bind(FreemarkerService.class).to(DefaultFreemarkerService.class);
-
-                bind(Component.class).toInstance(component);
-                bind(Context.class).toInstance(component.getContext().createChildContext());
-                bind(Application.class).to(ChempoundApplication.class);
-            }
-        };
-
-
-    }
-
 }