Commits

Sam Adams  committed e6e47f0

Simplified static content plugins

  • Participants
  • Parent commits 912368d

Comments (0)

Files changed (3)

File chemistry-jmol-plugin/pom.xml

             <artifactId>guice-multibindings</artifactId>
         </dependency>
 
-        <dependency>
-            <groupId>org.restlet.jee</groupId>
-            <artifactId>org.restlet</artifactId>
-        </dependency>
-
     </dependencies>
 
 </project>

File chemistry-jmol-plugin/src/main/java/net/chempound/plugins/jmol/JmolModule.java

 
     @Override
     protected void configure() {
-        bindPlugin(JmolPlugin.class);
+        bindStaticContent(JmolPlugin.class);
     }
 
 }

File chemistry-jmol-plugin/src/main/java/net/chempound/plugins/jmol/JmolPlugin.java

 package net.chempound.plugins.jmol;
 
 import net.chempound.webapp.plugins.ChempoundWebPlugin;
-import org.restlet.Context;
-import org.restlet.Request;
-import org.restlet.Response;
-import org.restlet.data.LocalReference;
-import org.restlet.resource.Directory;
-
-import javax.inject.Inject;
 
 /**
  * @author Sam Adams
  */
 public class JmolPlugin extends ChempoundWebPlugin {
 
-    private Directory directory;
-
-    @Inject
-    public JmolPlugin(final Context context) {
-        super(context, "jmol");
+    public JmolPlugin() {
+        super("jmol");
     }
 
-    @Override
-    public void start() throws Exception {
-        super.start();
-        final String path = "/"+JmolPlugin.class.getPackage().getName().replace('.', '/') + "/resources";
-        final LocalReference ref = LocalReference.createClapReference(LocalReference.CLAP_CLASS, path);
-        this.directory = new Directory(getContext(), ref);
-        this.directory.setListingAllowed(true);
-        this.directory.setNegotiatingContent(false);
-        this.directory.start();
+    public Class<?> getContext() {
+        return JmolPlugin.class;
     }
 
-    @Override
-    public void stop() throws Exception {
-        if (this.directory != null) {
-            this.directory.stop();
-            this.directory = null;
-        }
-        super.stop();
-    }
-
-    @Override
-    public void handle(final Request request, final Response response) {
-        this.directory.handle(request, response);
+    public String getPath() {
+        return "/net/chempound/plugins/jmol/resources/";
     }
 
 }