2007年8月21日 星期二

How to setup Java Connector Samples for ArcIMS

How to setup Java Connector Samples

The jspsamples.war can be found in {$ArcIMS_Home}\Samples\Java.
Copy it to {$Tomcat_Home}\webapps for automatically depolying as web site jspsamples.
In this case, {$Tomcat_Home} would be set to C:\Tomcat5.5

Step I. Modify web service document
1. Modify the map file SantaClara.axl -
The map file is stored in {$ArcIMS_Home}\Samples\TutorialData\AXL, while the corresponding shape files are saved in the

folder under {$ArcIMS_Home}\Samples\TutorialData\
It is able to use ArcIMS Author to make sure it is available to load.
Before that, in the map file SantaClara.axl, following tag must be revised to indicate where the shape files exist.

tag:WORKSPACES
child_tag:SHAPEWORKSPACE name="shp_ws-0" directory="D:\arcgis\ArcIMS\Samples\TutorialData\SantaClara"
tag:WORKSPACES

2. Make up context file -
Under the folder {$Tomcat_Home}\conf\Catalina\localhost
Create a xml file, say JavaConnSample.xml, with following content:

tag:Context docBase="D:\GISProj\ArcIMSTest\Output" path="/JavaConnSample"

Then, ArcIMS will create map images and output to D:\GISProj\ArcIMSTest\Output
The WebSite can present these images from http://snowlin:8000/JavaConnSample through the configuration of xml file.

3. Check or Alter web service properties - jspsamples.properties
The jspsamples web site will drive ArcIMS service by jspsamples.properties file that is located at
{$Tomcat_Home}\webapps\jspsamples\WEB-INF\classes
The default value is as following

host=localhost
port=5300
arcmapservice=arcmapSample
service=SantaClara
streamservice=SantaClaraStream

where, the host and port conduct ArcIMS service site, service and streamservice will be mapped to the configuration in Step

II.

Step II. Configuration in ArcIMS Administrator
1. Check out map file
The map file SantaClara.axl is stored in {$ArcIMS_Home}\Samples\TutorialData\AXL.
It is able to use ArcIMS Author to make sure it is available to load.

2. Create Service SantaClara with following Service Information
Service Name: SantaClara
Map File: D:\arcgis\ArcIMS\Samples\TutorialData\AXL\SantaClara.axl
Virtual Server: ImageServer1

herein, the Service Name and Map File are defined by jspsamples.properties.

3. Server Output - Create an output folder to save temporary map images and display through URL
Image Type: JPG, PNG...(Select one)
Directory Location: D:\GISProj\ArcIMSTest\Output
HTTP Location(URL): http://snowlin:8000/JavaConnSample

where, "Directory Location" and "URL" are the same setting as "docBase" and "path"

Note: The default sample is presenting Santa Clara city map, there're other samples like San Francisco, World, Canada, etc.

Just following steps above and change "SantaClara" as "SanFrancisco", then create new service in ArcIMS.
While both SanataClara and SanFrancisco services are running, jspsamples.properties file will be the key to decide which

service is linked.

2007年5月28日 星期一

Web 2.0 時代下的幾個 Java Web Framework

from
http://nettrace.blogspirit.com/tag/wicket

在這 Web 2.0 的時代,現今的 Java Web Framework 也與過去第一代的 Java Web Framework 有些不同,先列出我所關注的幾個:


Spring Framework

  • Spring Framework - http://static.springframework.org/

    輕量級的 Java 應用程式容器,同時支援 Rich Client、Web及 Java EE 應用系統之開發。

  • Spring Web MVC Framework - http://static.springframework.org/spring/docs/2.0.x/refer...

    Spring Web MVC 是一簡單易用的 web MVC 套件,可讓開發人員把 View, Controller 及 Model 分離,開發出容易維護的 Web 程式碼。由於其 View 端採用 pluggable 方式設計,可搭配 JSP, Struts 或 JSF 展示框架使用。

    由於 Struts 架構因限制特定用途且開發動能不足,目前已呈老化之趨勢,開發新專案時,不建議採用。對過去只採用 JSP 的系統來說,採用 Spring Web MVC + JSP 將是最可行而簡易的升級方案。

  • 中文版的 Spring Framework 教材 - http://caterpillar.onlyfun.net/Gossip/SpringGossip/Spring...

    良葛格寫的,其中對 Spring Framework 有深入淺出的介紹。若對 Spring Framework 不熟悉,建議先看這裡的介紹,大致上看完後對基本的應用就足夠了。若有不足處,可再參考官方參考手冊(http: //static.springframework.org/spring/docs/2.0.x/reference/)。

  • Spring Web Flow - http://opensource.atlassian.com/confluence/spring/display...

    Spring Web Flow 讓開發人員定義一組態設定檔,透過定義 page 及 action 的 binding,完成 page flow 的定義。令人興奮的是,在 Spring IDE(http://springide.org/project/wiki/SpringideFeatures) 中,提供對 Spring Web Flow 的支援,讓開發人員可以透過視覺化的方式(http://springide.org/project/wiki/WebFlowEditor), 來定義 網頁流程。
Echo2
  • Echo2 - http://www.nextapp.com/platform/echo2/echo/

    支援 Ajax 最徹底的 Web Framework,其特色是 Echo2 將網頁元素完全物件化,透過它所開發出來的網頁程式,不用寫到一行 HTML, javascript 程式碼。如果開發者對 Swing 熟悉,那麼開發 Echo2 程式將會輕而易舉。想要了解 Echo2 所開發出來的程式風格,可參考其 demo(http://www.nextapp.com/platform/echo2/echo/demo/)。 看過 Echo2 令人印象深刻的展示程式後,會覺得其他 Web Framework 的展示程式是那麼軟弱無力。

    另外,我發現 Echo2 的社群也是非常活躍,像是其 forum(http://forum.nextapp.com/forum/) 或 wiki(http://wiki.nextapp.com/echowiki/) 裡,可以找到不錯的參考資源。而 EndPointNG (http://wiki.nextapp.com/echowiki/EchoPointNG) 則提供了許多額外的元件,像是 Tree, TreeTable, PageableTable 等。

    在應用上,把所有 web 元素通通轉換成 Java 資源放在 session 裡面,對於使用者眾多的應用程式將非常不利(但若是像我們公司這類程式由於非訴諸一般 end user,則無所謂)。
Google Web Toolkit
  • Google Web Toolkit - http://code.google.com/webtoolkit/

    Google 所出品的 Java Ajax Web Framework。其實說它是 Java Web Framework 有些不對,因為它在開發的過程中,採用與 Echo2 類似的 Approach,是以 Java 物件來代表/處理 Web 元素。但是真正佈署前,必須將這些 Java 物件 compile 成 HTML 及 Javascript,再佈署這些轉譯後的 web 資源。因此這些資源極有可能佈署至一般的 web server 內(如 Apache),而不需要特定的 Java web container(如 tomcat)。

    由於 GWT 已經實際應用於 Google 的產品線(如 Gmail、Google Calendar 等)由於 Google 的Ajax 技術已經過實際應用,因此可以確認的是它的效能不成問題。另外由於它的展現層與邏輯層完全分離,兩者之間採用 jscon 或 RPC 的方式進行呼叫,因此 server 端完全免除 UI 的 loading,只要專注於 service 的邏輯即可。再加上它可透過 JavaScript Native Interface (JSNI) 來整合既有 javascript 撰寫的網頁元件,對於 third-party 的元件,將較容易整合與移植。結論是:GWT 是一適用於高負載,運用彈性靈活的 web framework。
Wicket
  • Wicket - http://wicket.sourceforge.net/

    Wicket 是 web 應用程式中,將 Java 程式與 HTML 源碼切割的最乾淨的一套 web framework。與 JSP 一樣,Wicket 將 view 端的 UI 定義在 HTML 中,但與 JSP 不同的是,它並不是採用 <%%> 這類特殊的 tag 來夾注 server 端的邏輯,而是利用 XML namespace 的方式,在一般的 html tag 中加注 Wicket id 來達到 server 端邏輯連結的效果。

    Wicket 與 Echo2 一樣,將所有的 UI 元素都轉換成 Java 物件存在 session 裡,對於流量大的應用程式非常不適用。實際試用 Wicket 之後,發現在使用既有元件的情況下,要完成相同的工作,它所需的程式碼要比 Echo2 來的多。且由於 Echo2 是所謂 "一頁式" 的 web 應用程式,而 Wicket 可支援多個頁面,因此它在 URL 連結及 session 的處理上更為複雜。所得到的益處是,Wicket 同時支援 Ajax 與 refresh based 的 web 應用程式開發,且支援 bookmarkable URL。

    另外,由於 Wicket 使用 HTML 作為網頁元素樣版,因此可以在美工人員與程式設計師之間作良好的分工。而既有的 javascript 在整合上,也會較 Echo2 來的簡易。



接下來,我想透過分析以上幾個 frameworks,檢視應用程式框架發展、轉變背後所隱含的意義:

支持輕量級開發

所謂輕量級開發,可以由幾個角度來檢視,一個是元件模型,UI 與 Server 端的邏輯是否容易連結。另一是在開發應用程式的過程中,是否需要採用特殊的工具,如特殊的 GUI Builder 或 configure file editor。最後,則是其執行環境是否單純,或是需要特定的 web 容器。

在第一點上,個人認為 Wicket 及 Echo2 皆有良好的表現。因為它們所採用的方式,是直接撰寫視覺元件的 action listener,與 Swing 的作法一致。而 Spring Web Framework 則承襲第一代 web framework,採用 dispatcher/handler 的作法,在觀念是 request/response 模式。至於 GWT,由於 client 端邏輯純粹由 javascript 負責,它所提供的 javascript 包含 RPC 呼叫程式,用來呼叫 server 端的應用程式邏輯。而 GWT 的 server 端邏輯,是一種特殊型式的 servlet。因此,如果系統中後端邏輯複雜多變,需要多個 server 端元件時,採用 GWT 預計就要維持很多個 servlet,可能會令人相當頭疼。

第二點,應用程式之開發環境,在 GWT, Wicket 及 Echo2 中,都是直接以既有的 Java IDE 即可開發,至於 Spring Web Framework 在這一點上,因為其 View 端採 plugable 設計,基本上是獨立的。不過其 config file,個人認為若有合適的 editor,會較容易使用。最仰賴 GUI builder 的,我想是 JSF,不過也不排除有存在樂於 hand coding JSF tags 的天才。

最後是運行環境,這方面的贏家是 GWT,因為它在運行時甚是不需要 server 環境。至於 Spring、Wicket 及 Echo2 等,則需要(只要)一搬的 java web container, 加上 framework 特有函式庫即可。

另外,這裡我並未強調元件模型是否為 POJO,因為繫結視覺元素與後端邏輯,本身就是 glue code。你只能看它是否夠不夠簡易,而無需用 model layer 的標準來要求,

支援新一代的動態網頁技術

Wicket、Echo2 及 GWT 都支援所謂的 Ajax 技術。在使用上,Echo2 的方式相當靈活,因為它讓你可以動態的在 clinet 端加入與移除視覺元件。Wicket 在使用上感覺就有些限制,因為它要求 Web UI 元件與後端的處理元件,需存在一對一的對應。

對於標準的支持

這一項有些含糊,因為每個 framework 所重視的標準不一。像是 GWT 重視的是平台的獨立性,而 Spring 重視的是支援既存的各種 framework,達到中立性。Wicket 重視的是 HTML 語法的相容性,而 Echo2 重視的則是瀏覽器的相容性,以及 Swing 風格的設計思路。不過總而言之,新一代的 web framework 在這個面向已進步許多。

視覺元件與程式邏輯更明確的分割

這可分為「看起來是」與「實際上是」,像是 Wicket 就做到看起來是。有趣的是,Echo2 是看起來不是,但實際上卻是。至於 GWT 嗎,由於它的 server 端的邏輯是另外寫成 service,而 client 端的視覺元素在開發時也是以 java 撰寫。兩者採用一致的方式,不過卻必須分開撰寫,可以說它是實際上是,至於看起來是不是,就見仁見智了。

2007年2月24日 星期六

Running ArcIMS9.1 with Tomcat5.5 in Windows - Part C: Configure Virtual Directory

Use virtual directory in Tomcat5.5 Application Server

1. Create ArcIMS Website and Ouput folders at desired location, for example,
D:\arcgis\ArcIMS\Website
D:\arcgis\ArcIMS\Output
Note: both of folders have been created in for sample as installing ArcIMS9.1. They can be copied to the path above.

2. Create xml-format context files for both directories in Tomcat, they are put in \conf\Catalina\localhost\ for virtual directory service, for example, if the website is ArcIMS_WebSite and output site it ArcIMS_OutputSite, then create ArcIMS_WebSite.xml and ArcIMS_OutputSite.xml with following content, respectively, (omit ... symbol since it is escape character)
<...?xml version="1.0" encoding="UTF-8"?...>
<...Context path="/ArcIMS_WebSite" docBase="D:\arcgis\ArcIMS\Website" debug="0" privileged="true" /...>

<...?xml version="1.0" encoding="UTF-8"?...>
<...Context path="/ArcIMS_OutputSite" docBase="D:\arcgis\ArcIMS\Output" debug="0" privileged="true" /...>

3. Run ArcIMS Administrator, with correct login username and password, the web folder, server and service will be listed.

4. Check view->site properties, input data for ArcIMS Site and Server Ouput tags:
in ArcIMS Site tag, make sure hostname and host alias are correct, then input HTTP Location (URL) and Web Site Directory. For example:
http://server_name:8000
D:\arcgis\ArcIMS\Website
in Server Output tag, input Directory Location and HTTP Location (URL), e.g.
D:\arcgis\ArcIMS\Output
http://server_name:8000/ArcIMS_OutputSite

5. Check service item, and create new service. Herein, in Service pan, the name, map file and virtual server are required. For example, set them as
ServiceTest
mapfile.mxd
ImageArcMapServer1
Note: as selecting map file, if mxd format file is selected, the virtual server must be ImageArcMapServer; if axl format file is selected, the virtual server would be ImageServer. The mxd file is created by ArcMap tool, the axl file is created by ArcIMS Author tool.

6. Then, go to check service output in the same panel, the image type should be jpeg format, the output directory and URL should be the same as setup above, i.e.
D:\arcgis\ArcIMS\Output
http://server_name:8000/ArcIMS_OutputSite

7. Click OK! If the service works, the service status would be running.

8. It is also available to create a virtual server by selecting server item and indicating server type. The new virtual server can be assigned to service.

9. Check Tools->Start Designer, input a web site directory, say ShapeTest, the folder “ShapeTest” will be created under D:\arcgis\ArcIMS\Website\ and include all material related to display image map.

10. Determinate a hostname and connect it, then select a service for display map.
Note: the hostname will be a key to browse it from the client site. For example, if the hostname is servername in this case, it might be only browsed at local machine or local network; e.g., http://server_name:8000/.... If the hostname is intranet IP address, such as 192.168.1.2, or internet IP like 140.128.65.114, it would be able to work through internet.

11. Follow up indication for choosing viewer such as html or Java viewer and click OK. HTML viewer will be recommended for easy setup.

12. When it is done, click “create site” button to complete.

Open the browser, type the website to view. For example in this case,
http://server_name:8000/ArcIMS_WebSite/ShapeTest
if the hostname is IP like 192.168.1.2, the it would be
http://192.168.1.2:8000/ArcIMS_WebSite/ShapeTest

Running ArcIMS9.1 with Tomcat5.5 in Windows - Part B: Configure Real Directory

Use real directory in Tomcat5.5 Application Server

1. Create ArcIMS Website and Ouput folders under \webapps\ROOT\, e.g.
C:\Tomcat5.5\webapps\ROOT\Website
C:\Tomcat5.5\webapps\ROOT\Output
Note: both of folders have been created in as installing ArcIMS9.1. They can be copied to the path above.

2. Run ArcIMS Administrator, with correct login username and password, the web folder, server and service will be listed.

3. Check view->site properties, input data for ArcIMS Site and Server Ouput tags:
in ArcIMS Site tag, make sure hostname and host alias are correct, then input HTTP Location (URL) and Web Site Directory. For example:
http://server_name:8000
C:\Tomcat5.5\webapps\ROOT\Website
in Server Output tag, input Directory Location and HTTP Location (URL), e.g.
C:\Tomcat5.5\webapps\ROOT\Output
http://server_name:8000/Output

4. Check service item, and create new service. Herein, in Service pan, the name, map file and virtual server are required. For example, set them as
ServiceTest
mapfile.mxd
ImageArcMapServer1
Note: as selecting map file, if mxd format file is selected, the server type of virtual server “ImageArcMapServer1” must be ImageServer-ArcMap; if axl format file is selected, that of virtual server would be ImageServer. The mxd file is created by ArcMap tool, the axl file is created by ArcIMS Author tool.

5. Then, go to check service output in the same panel, the image type should be jpeg format, the output directory and URL should be the same as setup above, i.e.
C:\Tomcat5.5\webapps\ROOT\Output
http://server_name:8000/Output

6. Click OK! If the service works, the service status would be running.

7. It is also available to create a virtual server by selecting server item and indicating server type. The new virtual server can be assigned to service.

8. Check Tools->Start Designer, input a web site directory, say ShapeTest, the folder “ShapeTest” will be created under C:\Tomcat5.5\webapps\ROOT\Website\ and include all material related to display image map.

9. Select a service for display map; then, follow up the indication for choosiPublishng viewer such as html or Java viewer and click OK. HTML viewer will be recommended for easy setup.

10. When it is done, click “create site” button to complete.

Open the browser, type the website to view. For example in this case,
http://server_name:8000/Website/ShapeTest

Running ArcIMS9.1 with Tomcat5.5 in Windows - Part A: Setup Servlet

1. After finishing installation and post-installation of ArcIMS9.1, find the servlet file “arcimsservletconnector.war” in \Connectors\Servlet\, then rename it as servlet.war.

2. Copy the servlet file to \webapps, and startup Tomcat5.5. The servlet website will be automatically created.

3. Under \webapps\servlet\WEB-INF\classes, find the file Esrimap_prop, revise the parameter below
### appServerMachine=129.103.35.97,123.151.62.57
appServerMachine=server_name
Where, server_name means the name of server or computer installing Tomcat

4. Go to service console, make sure following ArcIMS services are active:
ArcIMS Application Server 9.1
ArcIMS Monitor 9.1
ArcIMS Tasker 9.1

5. Execute ArcIMS Diagnostics to check if both Servlet and Application Server are running well. In the example herein, Tomcat5.5 is running as following IP and port:
http://server_name:8000

2007年2月22日 星期四

Deploy Virtual Directory in Tomcat 5.5

Tomcat5.5中部署虛擬路徑站台

1. /conf/Catalina/localhost下要存在一個以站台名稱為檔名的xml組構檔,Tomcat伺服器會根據此檔找到站台名稱及磁碟中對應的站台路徑,假如只有站台名稱,表示其對應之路徑會是在/webapps底下

2. 假設已經有一開發好的站台WebAssessment,所有相關的網頁均放置在C:\Inetput\wwwroot\WebAssessment之下,則可以手動建立WebAssessment.xml檔,假設存放在C:\Inetput\wwwroot下,則設定其內容如下(...在此為跳脫字,實作時略去):
<...?xml version="1.0" encoding="UTF-8"?...>
<...Context path="/ArcIMS_OutputSite" docBase="D:\arcgis\ArcIMS\Output" debug="0" privileged="true" /...>

3. WebAssessment.xml複製到/conf/Catalina/localhost下,啟動Tomcat即可在瀏覽器中以http://localhost:8000/WebAssessment打開此站台。其中localhost:8000Tomcat網站伺服器所在IP

4. 如利用netbeans開發網站上述網站之頁面,所開發完成的所有頁面資料會被存放在/build/web底下,其中Project_Home為所開發之網站專案路徑;假設要以上述之C:\Inetput\wwwroot\WebAssessment為站台之虛擬路徑,則應將/build/web下所有網站資料全部複製到此虛擬路徑下。

5. 其中,站台之組構檔為context.xml,被存放在META-INF資料夾中,可直接更改此檔案之內容加入如上之docBase, debug, privileged參數,即可依上述第2點建立虛擬站台之xml組構檔,並重複第3點。

6. 亦可利用Tomcat Manager在遠端部署虛擬站台,執行Tomcat Manager(或在Tomcat伺服器首頁點選Tomcat Manager連結),輸入管理者帳號密碼後,會被導至站台管理頁面下,並顯示出所有的站台清單。在最下面的Deploy工作區之Deploy directory or WAR file located on server中,輸入站台資訊,例如以上述步驟,
Context Path (optional):
輸入站台名稱,如/WebAssessment
XML Configuration file URL:
輸入組構檔路徑,如C:\Inetput\wwwroot\WebAssessment\WebAssessment.xml或者netbeans專案開發完成的contex.xml亦可
WAR or Directory URL:
輸入虛擬站台路徑,如C:\Inetput\wwwroot\WebAssessment

7. 如整個站台以被包裝在一個war檔中,可直接利用此工作區的上傳功能傳入伺服器路徑之下。

My Blogger's Test!
心有多寬, 世界就有多大!!