5

Click here to load reader

ZK_Arch_notes_20081121

Embed Size (px)

Citation preview

Page 1: ZK_Arch_notes_20081121

Knowing ZK by comparison

HTML

CSS

JAVASCRIPT

PHP/JSP/ASP

ZUML

STYLE

ZSCRIPT(java, python, ruby)

JAVA Servlet

Ordinary way ZK

JAVA

JAVA

JAVA/JAVASCRIPT

GWT

Model

View

Controller

Server Side

GWT RPC

Page 2: ZK_Arch_notes_20081121

Apache Tomcat: A Servlet Container

Editor(Eclipse)

Servlet Code Structure

JAVA Servlet(ZK Engine)

WEB-INF

ZK Studio plug-in

xxx.java

Firefox

lib

web.xml

Index.zul

META-INF

XHTML/CSS

JAVASCRIPT

Apache Tomcat: A Servlet container

ZK Library(xxx.jar)

Auto Generate folder structures

Zscript.Zuml

JSP translator(tomcat)

Servlet Source(.java)

Servlet Class(.class)

JavaCompilerJRE

http requestIndex.zul

1. Servlets are created when the tomcat is started.2. Then any http request are handle by these servlets3. Zk handles two kinds of request

1)first load page(non-ajax): handled by ZK Loader2)ajax request: handled by AU Engine

J2EE

Servlet(ZK loader)

JAVAServlet

ZUML JSP

Servlet(AU Engine)

ZUML

ZK Architecture

Page 3: ZK_Arch_notes_20081121

ZK architecture

Page 4: ZK_Arch_notes_20081121

Tomcat(1)Notes from reading http://tomcat.apache.org/tomcat-6.0-doc/introduction.html

Directory structureTomcat 6.0/-bin: Startup/Shutdown-conf: configuation file: set DTD & server.xml-lib: put global library-logs: logs-temp-webapps: where to put the web-apps

>docs>host-manager>manager>ROOT+META-INF

-context.xml: define Tomcat specific configuration options

+WEB-INF-lib

>*.jar: where the zk library will be-web.xml: define the web settings

+index.zul: zuml file-work

Tomcat setup- in Windows-Install JDK

>Set the JAVA_HOME and CLASSPATH-Install Tomcat>Download from>Windows Service Installer or zip>Double click->install as a service

-start the tomcat service(better to start from the command line could see the errors….)

-check http://localhost:8080/

.War (Web ARchive) Standard Directory Layout from doc-/ (*.html *.zul *.jsp)-/WEB-INF/web.xml (The Web Application Deployment Description of your app)

-/WEB-INF/classes/(ex: /com/mycompany/mypackage/MyServlet.class)

-/WEB-INF/lib/(*.jar)

Shared Library Files(install library JAR files (or unpacked classes) once, and make them visible to all installed web applications)Put your *.class & *.jar to $(tomcat_home)/libIt’s a good place to put JDBC driver, Ps: Servlet 2.5 & JSP2.1 & JAXP(xml parser) API are installed here.

Page 5: ZK_Arch_notes_20081121

Tomcat(2)Web.xmlWeb Application Deployment DescriptionUsing <servlet>,<servlet-mapping>,…tags in xml

Web.xml zk example……..<servlet>

<description>The asynchronous update engine for ZK</description><servlet-name>auEngine</servlet-name><servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>

</servlet><servlet-mapping>

<servlet-name>auEngine</servlet-name><url-pattern>/zkau/*</url-pattern>

</servlet-mapping>…….

Deployment1.Copy all unpack source to $(tomcat_home)/webapps2.Copy the *.war to $(tomcat_home)/webapps3.Use the Tomcat “Web Manager”….*****Restart the Tomcat server*****

About deployment *.warCopy the web application archive file into directory $CATALINA_BASE/webapps/. When Tomcat is started, it will automatically expand the web application archive file into its unpacked form, and execute the application that way. This approach would typically be used to install an additional application, provided by a third party vendor or by your internal development staff, into an existing Tomcat installation. NOTE - If you use this approach, and wish to update your application later, you must both replace the web application archive file ANDdelete the expanded directory that Tomcat created, and then restart Tomcat, in order to reflect your changes.Example:Put “zkdemo.war” at $(tomcat_home)/webappsAfter tomcat running, webapps/zkdemo will generated , you can access it at http://localhost:8080/zkdemo/

Difference between .war .jar .earThese files are simply zipped files using java jar tool. These files are created for different purposes. Here is the description of these files:.jar files: These files are with the .jar extension. The .jar files contain the libraries, resources and accessories files like property files. .war files: These files are with the .war extension. The war file contains the web application that can be deployed on the any servlet/jsp container. The .war file contains jsp, html, javascript and other files for necessary for the development of web applications..ear files: The .ear file contains the EJB modules of the applications.