Google App Engine"
m |
|||
Line 17: | Line 17: | ||
The content is similar to other ZK application except the AU engine has to be mapped to <tt>/zkau</tt>, too (in additions to <tt>/zkau/*</tt>. Otherwise, AU requests won't be sent to the AU engine. Here is is an example. | The content is similar to other ZK application except the AU engine has to be mapped to <tt>/zkau</tt>, too (in additions to <tt>/zkau/*</tt>. Otherwise, AU requests won't be sent to the AU engine. Here is is an example. | ||
− | < | + | <source lang="xml"> |
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> | <web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> | ||
<listener> | <listener> | ||
Line 55: | Line 55: | ||
</welcome-file-list> | </welcome-file-list> | ||
</web-app> | </web-app> | ||
− | </ | + | </source> |
== The zk.xml File == | == The zk.xml File == | ||
Line 63: | Line 63: | ||
Here is an example. | Here is an example. | ||
− | < | + | <source lang="xml"> |
<zk> | <zk> | ||
<!-- clustering environment --> | <!-- clustering environment --> | ||
Line 76: | Line 76: | ||
</client-config> | </client-config> | ||
</zk> | </zk> | ||
− | </ | + | </source> |
== The appengine-web.xml File == | == The appengine-web.xml File == | ||
Line 82: | Line 82: | ||
App Engine requires one addition configuration file named <tt>appengine-web.xml</tt>. It resides in the <tt>WEB-INF</tt> directory. | App Engine requires one addition configuration file named <tt>appengine-web.xml</tt>. It resides in the <tt>WEB-INF</tt> directory. | ||
− | < | + | <source lang="xml"> |
<sessions-enabled>true</sessions-enabled> | <sessions-enabled>true</sessions-enabled> | ||
Line 93: | Line 93: | ||
<include path="/**.zhtml"/> | <include path="/**.zhtml"/> | ||
</resource-files> | </resource-files> | ||
− | </ | + | </source> |
= More Information = | = More Information = |
Revision as of 03:28, 22 September 2010
Get Your App Engine Account Ready
First, you have to sign up an App Engine account and download the App Engine SDK. Refer to the official website for details.
To use Google App Engine for Java, you have to take one additional step: sign up here.
Configure Your App Engine Project
Here we assume you created a App Engine project. If not, please refer here.
There are three files that you have to configure: web.xml, zk.xml and appengine-web.xml. They all reside in the WEB-INF directory.
The web.xml File
The content is similar to other ZK application except the AU engine has to be mapped to /zkau, too (in additions to /zkau/*. Otherwise, AU requests won't be sent to the AU engine. Here is is an example.
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<listener>
<description>ZK listener for session cleanup</description>
<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
</listener>
<servlet>
<servlet-name>zkLoader</servlet-name>
<servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
<init-param>
<param-name>update-uri</param-name>
<param-value>/zkau</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>auEngine</servlet-name>
<servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zul</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>auEngine</servlet-name>
<url-pattern>/zkau/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>auEngine</servlet-name>
<url-pattern>/zkau</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.zul</welcome-file>
<welcome-file>index.zhtml</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
The zk.xml File
Google App Engine is a cloud service, so you have to enable the clustering: disable event threads and use serializable UI factory. In addition, Google App Engine doesn't allow users to create a working thread, so we have to disable the resend mechanism.
Here is an example.
<zk>
<!-- clustering environment -->
<system-config>
<disable-event-thread/>
<ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-class>
</system-config>
<!-- GAE doesn't allow user's thread -->
<client-config>
<resend-delay>-1</resend-delay>
</client-config>
</zk>
The appengine-web.xml File
App Engine requires one addition configuration file named appengine-web.xml. It resides in the WEB-INF directory.
<sessions-enabled>true</sessions-enabled>
<static-files>
<exclude path="/**.zul"/>
<exclude path="/**.zhtml"/>
</static-files>
<resource-files>
<include path="/**.zul"/>
<include path="/**.zhtml"/>
</resource-files>
More Information
Due to the way App Engine serializes sessions, you have to use ZK 3.6.2 or later. In additions, there are some other limitations.
- You cannot define functions in zscript, since BeanShell's method can not be serialized correctly[1].
- You cannot use captcha due to the limit support of AWT[2]
Sample
Download a sample application named zk-gae.
You can visit it at http://zk-gae.appspot.com/hello.zul
See Also
From forum
Version History
Version | Date | Content |
---|---|---|