Author: limpbizkit
Date: Thu May 7 15:25:09 2009
New Revision: 942
Added:
wiki/GoogleAppEngine.wiki
Log:
Created wiki page through web user interface.
Added: wiki/GoogleAppEngine.wiki
==============================================================================
--- (empty file)
+++ wiki/GoogleAppEngine.wiki Thu May 7 15:25:09 2009
@@ -0,0 +1,85 @@
+= Using Guice with Google App Engine =
+
+You can use Guice with to write modular applications for
[http://code.google.com/appengine/ Google App Engine].
+
+==Supported Builds==
+Google App Engine support was added in
[http://code.google.com/p/google-guice/source/detail?r=937 r937]. It
requires Guice 2 (with or without AOP), plus the guice-servlet extension.
+
+==Setup==
+
+===Servlet and Filter Registration===
+[http://code.google.com/p/google-guice/wiki/ServletModule Configure
servlets and filters] by subclassing `ServletModule`:
+{{{
+package com.mycompany.myproject;
+
+import com.google.inject.servlet.ServletModule;
+
+class MyServletModule extends ServletModule {
+ @Override protected void configureServlets() {
+ serve("/*").with(MyServlet.class);
+ }
+}
+}}}
+
+===Injector Creation===
+Construct your Guice injector in the `getInjector()` method of a class
that extends GuiceServletContextListener. Be sure to include your
application's servlet module in the list of modules.
+{{{
+package com.mycompany.myproject;
+
+import com.google.inject.servlet.ServletModule;
+import com.google.inject.servlet.GuiceServletContextListener;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class MyGuiceServletContextListener extends
GuiceServletContextListener {
+
+ @Override protected Injector getInjector() {
+ return Guice.createInjector(
+ new MyServletModule(),
+ new BusinessLogicModule());
+ }
+}
+}}}
+
+===Web.xml Configuration===
+You must register both the
[http://code.google.com/p/google-guice/wiki/Servlets GuiceFilter] and your
subclass of
[http://google-guice.googlecode.com/svn/trunk/latest-javadoc/com/google/inject/servlet/GuiceServletContextListener.html
GuiceServletContextListener] in your application's `web.xml` file. All
other servlets and filters may be configured in your servlet module.
+{{{
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app
+ xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+ version="2.5">
+ <display-name>My Project</display-name>
+
+ <filter>
+ <filter-name>guiceFilter</filter-name>
+ <filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>guiceFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <listener>
+
<listener-class>com.mycompany.myproject.MyGuiceServletContextListener</listener-class>
+ </listener>
+</web-app>
+}}}
+
+===WAR Layout===
+Ensure the AOP alliance, Guice, and Guice servlet jars are in the
`WEB-INF/lib` directory of your `.war` file (or `www` directory):
+{{{
+ www/
+ WEB-INF/
+ lib/
+ aopalliance.jar
+ guice-servlet-snapshot.jar
+ guice-snapshot.jar
+ ...
+ classes/
+ ...
+ appengine-web.xml
+ web.xml
+}}}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---