Customizing ArcIMS Using the Java Connector and Python

Similar documents
servlets and Java JSP murach s (Chapter 2) TRAINING & REFERENCE Mike Murach & Associates Andrea Steelman Joel Murach

Installing ArcIMS 9.1 on Windows

ArcIMS 9. Customizing ArcIMS Using the Java Connector. GIS by ESRI

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1

PRODUCT DOCUMENTATION. Installing and Implementing Enterprise Contact Center Chat RELEASE 5.1

Configuring Tomcat for a Web Application

X100 ARCHITECTURE REFERENCES:

AppDev StudioTM 3.2 SAS. Migration Guide

UIMA Simple Server User Guide

Tapestry. Code less, deliver more. Rayland Jeans

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

MapXtreme Java Edition Install Guide

ArcGIS 9. Installing ArcIMS 9 on IBM AIX

ArcIMS Installation Guide. Sun Solaris

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Servlets by Example. Joe Howse 7 June 2011

SECTION II: JAVA SERVLETS

Enterprise Java Unit 1- Chapter 3 Prof. Sujata Rizal Introduction to Servlets

COPYRIGHTED MATERIAL

Topics Augmenting Application.cfm with Filters. What a filter can do. What s a filter? What s it got to do with. Isn t it a java thing?

MythoLogic: problems and their solutions in the evolution of a project

ArcIMS Installation Guide SGI IRIX

BlueDragon TM 7.0 Deploying CFML on J2EE Application Servers

Appendix A - Glossary(of OO software term s)

Tutorial: Developing a Simple Hello World Portlet

NetBeans IDE Field Guide

Web Application Architecture (based J2EE 1.4 Tutorial)

Using the VisualAge for Java WebSphere Test Environment

Introduction to Servlets. After which you will doget it

ArcIMS Installation Guide. Windows

A web application serving queries on renewable energy sources and energy management topics database, built on JSP technology

ThingWorx Relational Databases Connectors Extension User Guide

AutoVue Integration SDK & Sample Integration for Filesys DMS

CHAMELEON Project. Developer Guide. - Mobile Client - Server - UDDIe Registry. CHAMELEON Client and Server side

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

White Paper. Fabasoft Folio Portlet. Fabasoft Folio 2017 R1 Update Rollup 1

Introduction to XML. An Example XML Document. The following is a very simple XML document.

Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat

Java Card 3 Platform. Peter Allenbach Sun Microsystems, Inc.

SUN Enterprise Development with iplanet Application Server

Development and Implementation of a Container Based Integrated ArcIMS Application Joseph F. Giacinto, MCP

Introduction. Overview of the Course on Java. Overview of Part 1 of the Course

Session 8. Reading and Reference. en.wikipedia.org/wiki/list_of_http_headers. en.wikipedia.org/wiki/http_status_codes

Introduction to JSP and Servlets Training 5-days

Building the Enterprise

Hotfix 913CDD03 Visual Data Explorer and SAS Web OLAP Viewer for Java

Components and Application Frameworks

CS506 Web Design & Development Final Term Solved MCQs with Reference

Developing Java TM 2 Platform, Enterprise Edition (J2EE TM ) Compatible Applications Roles-based Training for Rapid Implementation

Introduction. Enterprise Java Instructor: Please introduce yourself Name Experience in Java Enterprise Edition Goals you hope to achieve

ByggSøk plan Project Structure And Build Process

Building Web Applications with SAS AppDev Studio TM 3.0

BEAProducts. ISV Partners Guide

Jakarta Struts: An MVC Framework

HYPERION SYSTEM 9 BI+ GETTING STARTED GUIDE APPLICATION BUILDER J2EE RELEASE 9.2

Writing Servlets and JSPs p. 1 Writing a Servlet p. 1 Writing a JSP p. 7 Compiling a Servlet p. 10 Packaging Servlets and JSPs p.

The DataNucleus REST API provides a RESTful interface to persist JSON objects to the datastore. All entities are accessed, queried and stored as

COURSE DETAILS: CORE AND ADVANCE JAVA Core Java

Java Programming Language

BEAWebLogic Server. Introduction to BEA WebLogic Server and BEA WebLogic Express

Using SAS Enterprise Guide with the WIK

SAS AppDev Studio TM 3.4 Eclipse Plug-ins. Migration Guide

COURSE SYLLABUS. Complete JAVA. Industrial Training (3 MONTHS) PH : , Vazhoor Road Changanacherry-01.

OpenText StreamServe 5.6 Document Broker Plus

Active Endpoints. ActiveVOS Platform Architecture Active Endpoints

Artix ESB. Configuring and Deploying Artix Solutions, Java Runtime. Making Software Work Together TM. Version 5.0, July 2007

Advanced Java Programming

WAS: WebSphere Appl Server Admin Rel 6

PRIMIX SOLUTIONS. Core Labs. Tapestry : Java Web Components Whitepaper

Crystal Reports XI Release 2

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps.

Agent Interaction SDK Java Developer Guide. About the Code Examples

Agent-Enabling Transformation of E-Commerce Portals with Web Services

EUSurvey Installation Guide

SAS Integration Technologies Server Administrator s Guide

Just Get it Written: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

ESPRIT Project N Work Package H User Access. Survey

Servlets1. What are Servlets? Where are they? Their job. Servlet container. Only Http?

Oracle9i Application Server Architecture and Com

Demonstrated Node Configuration for the Central Data Exchange Node

J2EE Interview Questions

SAS 9.2 Foundation Services. Administrator s Guide

DESIGN AND IMPLEMENTATION OF SAGE DISPLAY CONTROLLER PROJECT

Web-based technology for cheminformatics

<put document name here> 1/13

EUSurvey OSS Installation Guide

SCO Vision2K 2.1. What s in this release

XMLInput Application Guide

J2EE Packaging and Deployment

OpenOffice.org as a platform for developers

Session 8. Introduction to Servlets. Semester Project

NAMGIS Core manual. September 21, 2008

Excel4apps Wands 5 Architecture Excel4apps Inc.

Introduction... xv SECTION 1: DEVELOPING DESKTOP APPLICATIONS USING JAVA Chapter 1: Getting Started with Java... 1

CodeCharge Studio Java Deployment Guide Table of contents

How to use J2EE default server

Enterprise Java Unit 1-Chapter 2 Prof. Sujata Rizal Java EE 6 Architecture, Server and Containers

The End of the Beginning: Deploying Applications to WebLogic Server Using JDeveloper and WLS Console. Don t get it right, just get it written.

HttpServlet ( Class ) -- we will extend this class to handle GET / PUT HTTP requests

Enhydra 6.2 Application Architecture. Tanja Jovanovic

Transcription:

Customizing ArcIMS Using the Java Connector and Python Randal Goss The ArcIMS Java connector provides the most complete and powerful object model for creating customized ArcIMS Web sites. Java, however, with its code/compile/run development model, lacks the ease of use of scripting languages for rapid development and prototyping of Web applications. To leverage the power of the Java connector with the rapid development cycle of scripting languages, we are utilizing the Python scripting language. Python is a relatively simple but powerful cross platform programming language that, in addition to running in Windows, was ported to Java. Python in Java, frequently referred to as Jython, is fully integrated with the Java environment allowing the programmer to use and even write Java classes and applets. This paper explores the process of incorporating Jython into JavaServer Pages or Servlets to quickly deploy highly customized ArcIMS Web sites. Providing data to the users, the people who need it to make key business or policy decisions, has historically been one the the fundamental challenges of GIS professionals. As a result, GIS systems have evolved from monolithic proprietary systems to client server environments supported on standardized data models. One component of this evolution is the incorporation of GIS information into web based clients such as web browsers, or Java based applets. The dissemination of GIS information inside of an interactive client that can be deployed on a web browser is very effective. It can allow users, with little or no training, to view, query, and perform various analysis upon the GIS data. ArcIMS, ESRI's internet Map Server, fulfills the server role discussed above. It communicates with clients using a standardized XML schema (ArcXML), thus allowing for tremendous variability in the type and function of clients. ESRI has provided ArcIMS users with several standard clients including the HTML Client, and the Java Client. Both of these clients offer a broad base of functionality to the user and are quite effective for the purpose that they were developed. Although these clients can be customized, the amount of time required to make significant changes begins to increase disproportionately with an increasing level of customization due to the size and complexity of the original application. Consequently, ESRI has provided several connectors to the ArcIMS server that can be used to build custom clients meeting specific needs. These include the ActiveX connector, the Cold Fusion connector, and the Java Connector. Of the three, the Java connector is arguably the best supported connector for ArcIMS and provides and object model that wraps much of the functionality of ArcXML. As users become accustomed to GIS, especially with respect to web clients, they will begin to request very specific customizations which solve niche needs. These solutions generally involve the integration of GIS visualization with data entry, storage, and retrieval. Although these applications might only impact a small number of individuals, they can result in highly productive tools. Unfortunately, the development of custom clients is generally time consuming and can be cost prohibitive when they only address the needs of a small number of people. To make development under these circumstances cost effective, what is necessary is a platform meeting the following criteria:

It should facilitate rapid application development and the use of reusable components. It must support dynamic data driven applications, those that can seamlessly integrate the GIS component with the relational database component. Ideally, it should be cross platform, running on all of the ArcIMS platforms. It must be easily learned. There are many possible scripting solutions, each with their own specific strengths and weaknesses. However, there was one solution which seemed ideally suited for ArcIMS development. This solution was the utilization of the ArcIMS Java Connector with a combination of Java and a version of the Python scripting language which runs inside of the Java Virtual Machine(JVM). This version of python is commonly referred to as Jpython or Jython. The benefits realized by deploying this combination are: The developer can rapidly prototype an application, and later optimize performance by converting performance limiting code to pure Java. Jython is simple to use and quick to learn, yet it is very powerful and well suited for larger projects The Java Connector is an excellent connector to the ArcIMS server. It supports cross platform applications and encapsulates most of the functionality of ArcXML. There is a seamless integration between Java and Jython. Jython can use and extend Java Classes, while Java can incorporate classes written in Jython. The java environment provides the Java Database Connectivity (JDBC) for standardized cross platform access to most database management systems. Jython further simplifies database access with the zxjdbc module. The python scripting language is used by the ArcGIS 9 Geoprocessor. This can reduce developer training costs, as a single language can be used for both ArcGIS automation and ArcIMS web site development. The jython interpreter can be used interactively to explore the Java Connector data model. This can be a useful tool for learning and experimenting with the object model, and also for administration of the server. It is important to note that jython scripts execute slower that native Java classes. This loss in performance, however, does not tend to impact the performance of an ArcIMS application as the expense of rendering a map is significantly more than executing a script. In many cases, using a scripting language will have little to no impact on the performance of an ArcIMS web site. If a script component did, however, become a limiting factor in the performance of a site, it would be a simple matter to re-write the script directly in Java. The remainder of this paper will focus on the procedure for installing jython, configuring it for use within a java servlet container, and then preparing a simple example to demonstrate the simplicity and strength of the platform. This article assumes that the user has successfully installed a Java Runtime Environment (JRE), ArcIMS, and a servlet container. The examples presented were run with JRE 1.4.2, ArcIMS 4.01, and Jakarta-Tomcat 3.3.1a. They reference an ArcIMS service called `TestService`. Also, the examples are presented for users running Microsoft Windows 2000 or higher operating system. Obtaining and Installing Jython Jython is an OpenSource project, therefore can be downloaded from www.jython.org

and installed without charge. The current release implements the Python 2.1 specification and requires a JVM greater than version 1.x. Jython will not run on the JVM version 1.5. There is, however, a new version under development which will be compatible with JVM 1.5. Installation can be a bit tricky, although there is ample information on the web site to troubleshoot most problems. In most cases, to install jython, download the jython21.class file and run the following command: java -cp. jython-21 This should start a graphical installer which will then prompt the user for additional information. Once jython is installed, the interpreter can be started by executing the jython.bat file located in the installation directory. This will start an interactive session of the jython interpreter. Commands can be entered at the command line (prefaced by `>>>`) and are executed when the enter key is pressed. A python script can be executed simply by providing the name of the script as an argument to the jython.bat command. For example, to run a script file titled sample.py the command would be jython.bat sample.py. Connecting Jython to ArcIMS To use jython in conjunction with ArcIMS, the ArcIMS Java Connector library must be available. These libraries are located on the ArcIMS CD or in the installation directory of ArcIMS. Within the installation directory they can be found in the <ArcIMS HOME>\ArcIMS\Middleware\Java_Connector subdirectory. The libraries can be transferred by copying all of the.jar files in this subdirectory into the lib\ext subdirectory of the JRE. For example, if the Java Software Development Kit is installed to c:\j2sdk1.4.2_03, then they should be copied to c:\j2sdk1.4.2_03\jre\lib\ext\. Once the libraries have been copied, the jython connection to ArcIMS can be tested. The first step is to import packages from the ESRI Java Connector. Refer to the ESRI Java Documents for additional documentation on the packages in the Java Connector. This example utilizes the `com.esri.aims.mtier.io` package which contains the ConnectionProxy class and the `com.esri.aims.mtier.model.map` package which contains the Map, Legend, and Layers objects. The Map, Legend, and Layers objects define most of the components of an ArcIMS service. >>> from com.esri.aims.mtier.io import * >>> from com.esri.aims.mtier.model.map import * Now that the packages are imported, the next step is to establish a connection with the ArcIMS Server. For this example, the server IP address is 10.10.8.43, the ArcIMS service is TestService. The server is listening on the default port of 5300. >>> con=connectionproxy() >>> con.setconnectiontype("tcp") >>> con.sethost("10.10.8.43") >>> con.setport(5300) >>> con.setservice("testservice") Once the connection is established, the Map class can be used to request an image from the server. The following sequence of commands creates a new map, sets the width and height to 400 and 600 pixels respectively, initializes the map service, and generates a new image. The image URL is printed after the geturl method.

>>> map=map() >>> map.setheight(400) >>> map.setwidth(600) >>> map.initmap(con,750,0,0,0,0) >>> map.refresh() >>> map.getmapoutput().geturl() 'http://10.10.8.43/output/iwhrs_localhost996014746657.jpg' Classes in Jython Taking this a step further, a class can be written in jython that subclasses the Java Connector's Map class and connects to a given service when the class is instantiated. from com.esri.aims.mtier.io import * from com.esri.aims.mtier.model.map import * class ImsMap(Map): def init (self,service): con=connectionproxy() con.setconnectiontype("tcp") con.sethost("10.10.8.43") con.setport(5300) con.setservice(service) self.con=con def startmap(self): Map.setHeight(self,400) Map.setWidth(self,600) Map.initMap(self,con,750,0,0,0,0) Map.refresh(self) return Map.getMapOutput(self).getURL() >>> map=imsmap("testservice") >>> map.startmap() 'http://10.10.8.43/output/iwhrs_localhost996014746663.jpg' >>> map.getmapunits() 'feet' Notice that the getmapunits method was inherited from the Java Connector's Map class. This seamless integration between jython and Java is perhaps its greatest strength. As noted before, Java classes can be directly subclasses by jython, while classes written in Jython can be subclassed by Java. Another advantage is the fact that casting of objects is managed implicitly by the jython interpreter. This helps to keep the jython scripts simple and legible. Jython and Tomcat To develop an ArcIMS web application using jython, jython and the ArcIMS connector must be deployed on a servlet container. The following example uses the Apache Jakarta-Tomcat servlet container, which is the reference implementation of the Java Servlet and Java Server Page specifications. There are essentially four steps for deploying jython and the ArcIMS java connector on Jakarta-Tomcat, they are: 1. Create a new context for the web site. This example creates the context `sample` including the following directory structure:

<path to jakarta>\webapps\sample <path to jakarta>\webapps\sample\web-inf <path to jakarta>\webapps\sample\web-inf\lib 2. Copy the jython.jar library module, and the ArcIMS Java Connector jar files into the sample contexts lib subdirectory (<path to jakarta>\webapps\sample\web- INF\lib). 3. Create a `web.xml` deployment descriptor file that defines a PyServlet descriptor mapping. At a minimum, the deployment descriptor file should contain: <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> <web-app> <servlet> <servlet-name> pyservlet </servlet-name> <servlet-class> org.python.util.pyservlet </servlet-class> </servlet> <servlet-mapping> <servlet-name> pyservlet </servlet-name> <url-pattern>*.py</url-pattern> </servlet-mapping> </web-app> 4. Write the python servlets. The following sample servlet, GetImsMap.py, should be deployed in the context's root directory (\webapps\sample): from javax.servlet.http import HttpServlet from com.esri.aims.mtier.io import * from com.esri.aims.mtier.model.map import * class GetImsMap(HttpServlet): def doget(self,req,res): out=res.writer res.contenttype="text/html" map=imsmap("sampleservice") print>>out, "<html><body>" print>>out, "<img src="+map.startmap() print>>out, "></body></html>" class ImsMap(Map): def init (self,service): con=connectionproxy() con.setconnectiontype("tcp")

con.sethost("10.10.8.43") con.setport(5300) con.setservice(service) self.con=con def startmap(self): Map.setHeight(self,400) Map.setWidth(self,600) Map.initMap(self,self.con,750,0,0,0,0) Map.refresh(self) return Map.getMapOutput(self).getURL() To run the servlet that was just created, make sure that the servlet container and ArcIMS server is running, start a browser and enter the url: http://<server address>:8080/sample/getimsmap.py If everything is working correctly, an image of the ArcIMS service should be visible in the web browser. My sample is depicted below: We have, with the help of a small java applet (ROSA http://www.maptools.org/rosa/index.phtml), been able to create an extended Java Connector library and basic template that encapsulates most of the required functionality of a GIS client. Deploying a customized ArcIMS client using jython and these tools requires little effort, and is much more amenable to customization than the heavier clients provided by ESRI. An example of this tool, presented below, lets the

user modify the table depicted on the left, and will modify the map symbology as the underlying data is changed. By incorporating our extended classes, the map frame and its functions were developed with less than two hundred lines of python code. Conclusion The combined use of jython and java provides developers with an excellent choice for development of ArcIMS web sites. Its simplicity and flexibility make it ideal for prototyping and rapidly deploying customized ArcIMS web sites. There are many other possibilities regarding the configuration or deployment of jython servlets, such as the creation and deployment of WAR archives, or the incorporation of the standard python libraries in the web site, but these topics are beyond the scope of this paper. Interested readers are encouraged to visit the jython web site. Several technical books have also been published on the use and configuration of jython. Links to these books are also presented on the jython web site. Randal Goss Kimley-Horn and Associates, Inc. 8711 Perimeter Park Blvd. Suite 4 Jacksonville, FL 32216 Phone (904) 998-2084 Fax (904) 998-2197