Commits

Sam Adams  committed eda917d

Added jmol/jquery modules

  • Participants
  • Parent commits 4d557b3

Comments (0)

Files changed (3)

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

 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Module;
+import com.google.inject.multibindings.MapBinder;
+import com.google.inject.multibindings.Multibinder;
 import com.google.inject.servlet.GuiceServletContextListener;
 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.ChempoundConfiguration;
 import uk.ac.cam.ch.wwmm.chempound.DefaultChempoundModule;
 import uk.ac.cam.ch.wwmm.chempound.comp.CompChemModule;
 import uk.ac.cam.ch.wwmm.chempound.crystal.CrystallographyModule;
 import uk.ac.cam.ch.wwmm.chempound.datastore.DataStore;
 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.DefaultFreemarkerService;
 import uk.ac.cam.ch.wwmm.chempound.webapp.FreemarkerService;
+import uk.ac.cam.ch.wwmm.chempound.webapp.output.ContentHandler;
+import uk.ac.cam.ch.wwmm.chempound.webapp.plugins.ChempoundWebPlugin;
 import uk.ac.cam.ch.wwmm.chempound.webapp.search.chemistry.StructureSearchProviderModule;
 import uk.ac.cam.ch.wwmm.chempound.webapp.sword.impl.SwordModule;
 
         return new ServletModule() {
             @Override
             protected void configureServlets() {
+                Multibinder.newSetBinder(binder(), ContentHandler.class);
+                MapBinder.newMapBinder(binder(), String.class, ChempoundWebPlugin.class);
+
                 bind(FreemarkerService.class).to(DefaultFreemarkerService.class);
-                serve("/*").with(QuixoteServlet.class);
+                serve("/*").with(RestletServlet.class);
             }
         };
     }
     @Override
     protected Injector getInjector() {
         return Guice.createInjector(
+
                 createConfigurationModule(),
                 createChempoundModule(),
                 createServletModule(),
                 new CrystallographyModule(),
                 new CompChemModule(),
 
-                new SwordModule()
+                new JQueryModule(),
+                new JmolModule(),
+
+                new SwordModule(),
+
+                getRestletModule()
+
         );
     }
 
+    private AbstractModule getRestletModule() {
+        return new AbstractModule() {
+            @Override
+            protected void configure() {
+                Component component = new Component();
+                component.getClients().add(Protocol.CLAP);
+
+                bind(Context.class).toInstance(component.getContext().createChildContext());
+                bind(Application.class).to(ChempoundApplication.class);
+            }
+        };
+    }
+
 }

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

-package uk.ac.cam.ch.wwmm.quixote;
-
-import com.google.inject.Injector;
-import org.restlet.Component;
-import org.restlet.Context;
-import org.restlet.data.Protocol;
-import org.restlet.ext.servlet.ServletAdapter;
-import uk.ac.cam.ch.wwmm.chempound.webapp.ChempoundApplication;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * @author sea36
- */
-@Singleton
-public class QuixoteServlet extends HttpServlet {
-
-    private Injector injector;
-    private ServletAdapter adapter;
-
-    @Inject
-    public QuixoteServlet(Injector injector) {
-        this.injector = injector;
-    }
-
-    @Override
-    public void init() throws ServletException {
-        final Component component = new Component();
-        component.getClients().add(Protocol.CLAP);
-
-        Context context = component.getContext().createChildContext();
-        ChempoundApplication application = new ChempoundApplication(injector, context);
-        this.adapter = new ServletAdapter(getServletContext(), application);
-    }
-
-    @Override
-    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-        adapter.service(req, resp);
-    }
-
-}

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

+package uk.ac.cam.ch.wwmm.quixote;
+
+import com.google.inject.Injector;
+import org.restlet.Application;
+import org.restlet.ext.servlet.ServletAdapter;
+import uk.ac.cam.ch.wwmm.chempound.webapp.ChempoundApplication;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ * @author sea36
+ */
+@Singleton
+public class RestletServlet extends HttpServlet {
+
+    private Application application;
+    private ServletAdapter adapter;
+
+    @Inject
+    public RestletServlet(Application application) {
+        this.application = application;
+    }
+
+    @Override
+    public void init() throws ServletException {
+        this.adapter = new ServletAdapter(getServletContext(), application);
+    }
+
+    @Override
+    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+        adapter.service(req, resp);
+    }
+
+}