Google App Engine"

From Documentation
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">
+
<syntax lang="xml">
<sessions-enabled>true</sessions-enabled>
+
<sessions-enabled>true</sessions-enabled>
  
<static-files>
+
<static-files>
<exclude path="/**.zul"/>
+
<exclude path="/**.zul"/>
<exclude path="/**.zhtml"/>
+
<exclude path="/**.zhtml"/>
</static-files>
+
</static-files>
<resource-files>
+
<resource-files>
<include path="/**.zul"/>
+
<include path="/**.zul"/>
<include path="/**.zhtml"/>
+
<include path="/**.zhtml"/>
</resource-files>
+
</resource-files>
</source>
+
</syntax>
  
 
= More Information =
 
= More Information =

Revision as of 04:20, 7 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.

<syntax lang="xml"> <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> </syntax>

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.

<syntax lang="xml"> <zk> <system-config> <disable-event-thread/> <ui-factory-class>org.zkoss.zk.ui.http.SerializableUiFactory</ui-factory-class> </system-config>

<client-config> <resend-delay>-1</resend-delay> </client-config> </zk> </syntax>

The appengine-web.xml File

App Engine requires one addition configuration file named appengine-web.xml. It resides in the WEB-INF directory.

<syntax lang="xml"> <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> </syntax>

More Information

Due to the way App Engine serializes sessions, you have to use ZK 3.6.2 or later[1]. In additions, there are some other limitations.

  • You cannot define functions in zscript, since BeanShell's method can not be serialized correctly[2].
  • You cannot use captcha due to the limit support of AWT[3]

  1. You can get a freshly release here
  2. It runs correctly locally but not if uploaded.
  3. You will see a warning, ... Component captcha ignored., in the application log.

Sample

Download a sample application named zk-gae.

You can visit it at http://zk-gae.appspot.com/hello.zul

See Also

From forum

Composers on Google AppEngine?

Version History

Version Date Content
     



Last Update : 2010/09/07

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.