Commits

Anonymous committed 0c7a3b7

Move guice restlet config

Comments (0)

Files changed (8)

chempound-webapi/pom.xml

         </dependency>
 
         <dependency>
-            <groupId>org.restlet.jee</groupId>
-            <artifactId>org.restlet</artifactId>
-        </dependency>
-
-        <dependency>
             <groupId>org.freemarker</groupId>
             <artifactId>freemarker</artifactId>
         </dependency>

chempound-webapi/src/main/java/net/chempound/webapp/guice/GuiceFinder.java

-package net.chempound.webapp.guice;
-
-import com.google.inject.Injector;
-import org.restlet.Context;
-import org.restlet.Request;
-import org.restlet.Response;
-import org.restlet.resource.Finder;
-import org.restlet.resource.ServerResource;
-
-/**
- * Based on Harald Pehls blog post:
- * http://haraldpehl.blogspot.com/2009/11/google-appengine-restlet.html
- *
- * @author sea36
- */
-public class GuiceFinder extends Finder {
-
-    private final Injector injector;
-
-    public GuiceFinder(final Injector injector, final Context context, final Class targetClass) {
-        super(context, targetClass);
-        this.injector = injector;
-    }
-
-    @Override
-    public ServerResource create(final Class<? extends ServerResource> targetClass, final Request request, final Response response) {
-        return injector.getInstance(targetClass);
-    }
-
-}

chempound-webapi/src/main/java/net/chempound/webapp/guice/GuiceRouter.java

-package net.chempound.webapp.guice;
-
-import com.google.inject.Injector;
-import org.restlet.Context;
-import org.restlet.resource.Finder;
-import org.restlet.routing.Router;
-
-/**
- * Based on Harald Pehls blog post:
- * http://haraldpehl.blogspot.com/2009/11/google-appengine-restlet.html
- *
- * @author sea36
- */
-public class GuiceRouter extends Router {
-
-    private final Injector injector;
-
-    public GuiceRouter(final Injector injector, final Context context) {
-        super(context);
-        this.injector = injector;
-        attachRoutes();
-    }
-
-    @Override
-    public Finder createFinder(final Class targetClass) {
-        return new GuiceFinder(injector, getContext(), targetClass);
-    }
-
-    protected void attachRoutes() {
-
-    }
-
-    protected Injector getInjector() {
-        return injector;
-    }
-
-}
-

chempound-webapp/src/main/java/net/chempound/webapp/ChempoundServletConfig.java

 import com.google.inject.Injector;
 import com.google.inject.Stage;
 import com.google.inject.servlet.GuiceServletContextListener;
+import net.chempound.webapp.guice.GuiceServletModule;
 
 /**
  * @author sea36
     public Injector getInjector() {
         return Guice.createInjector(Stage.PRODUCTION,
                 new ChempoundWebappModule(),
-                new ChempoundServletModule());
+                new GuiceServletModule());
     }
 }

chempound-webapp/src/main/java/net/chempound/webapp/ChempoundServletModule.java

-package net.chempound.webapp;
-
-import com.google.inject.servlet.ServletModule;
-import net.chempound.webapp.guice.GuiceRestletServlet;
-
-/**
-* @author sea36
-*/
-public class ChempoundServletModule extends ServletModule {
-
-    @Override
-    protected void configureServlets() {
-        install(new ServletConfigurationModule(getServletContext()));
-        serve("/*").with(GuiceRestletServlet.class);
-    }
-
-}

chempound-webapp/src/main/java/net/chempound/webapp/guice/GuiceFinder.java

+package net.chempound.webapp.guice;
+
+import com.google.inject.Injector;
+import org.restlet.Context;
+import org.restlet.Request;
+import org.restlet.Response;
+import org.restlet.resource.Finder;
+import org.restlet.resource.ServerResource;
+
+/**
+ * Based on Harald Pehls blog post:
+ * http://haraldpehl.blogspot.com/2009/11/google-appengine-restlet.html
+ *
+ * @author sea36
+ */
+public class GuiceFinder extends Finder {
+
+    private final Injector injector;
+
+    public GuiceFinder(final Injector injector, final Context context, final Class targetClass) {
+        super(context, targetClass);
+        this.injector = injector;
+    }
+
+    @Override
+    public ServerResource create(final Class<? extends ServerResource> targetClass, final Request request, final Response response) {
+        return injector.getInstance(targetClass);
+    }
+
+}

chempound-webapp/src/main/java/net/chempound/webapp/guice/GuiceRouter.java

+package net.chempound.webapp.guice;
+
+import com.google.inject.Injector;
+import org.restlet.Context;
+import org.restlet.resource.Finder;
+import org.restlet.routing.Router;
+
+/**
+ * Based on Harald Pehls blog post:
+ * http://haraldpehl.blogspot.com/2009/11/google-appengine-restlet.html
+ *
+ * @author sea36
+ */
+public class GuiceRouter extends Router {
+
+    private final Injector injector;
+
+    public GuiceRouter(final Injector injector, final Context context) {
+        super(context);
+        this.injector = injector;
+        attachRoutes();
+    }
+
+    @Override
+    public Finder createFinder(final Class targetClass) {
+        return new GuiceFinder(injector, getContext(), targetClass);
+    }
+
+    protected void attachRoutes() {
+
+    }
+
+    protected Injector getInjector() {
+        return injector;
+    }
+
+}
+

chempound-webapp/src/main/java/net/chempound/webapp/guice/GuiceServletModule.java

+package net.chempound.webapp.guice;
+
+import com.google.inject.servlet.ServletModule;
+
+/**
+* @author sea36
+*/
+public class GuiceServletModule extends ServletModule {
+
+    @Override
+    protected void configureServlets() {
+        serve("/*").with(GuiceRestletServlet.class);
+    }
+
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.