1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
Using PostGIS Geometry Types with EJB2 -- Proof of Concept
----------------------------------------------------------
Copyright (C) 2006 by the Geodetix s.r.l. Company. See
http://www.geodetix.it/ for further information.
Version 1.0.0 (2006/08/29)
Table of Contents
-----------------
0. Licensing
1. Introduction
2. Directory Contents
3. Software Requirements
4. Installation
5. Running
6. Code Details
0. Licensing
------------
The "Using PostGIS Geometry Types with EJB2 -- Proof of Concept" software is
a short collection of examples related to the use of PostGIS Java API with
the EJB 2.x technology.
Copyright (C) 2006 by the Geodetix s.r.l. Company. See
http://www.geodetix.it/ for further information.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1. Introduction
---------------
Our software is a simple proof-of-concept application illustrating how the
PostGIS provided Java geometric types could be integrated with a set of
Enterprise Java Bean 2.x components.
To achieve such a goal, an attribute of type org.postgis.Geometry has been
added to a BMP (Bean managed Persistence) Entity Bean. Furthermore, by using
the DAO (Data Access Object) Pattern, the persistence code has been clearly
separated from the business logic.
Not to add further complexity, some proper programming behaviours were omitted.
For example the use of PostGIS geometric types directly inside the Entity Bean
code could be avoided by using a WKT compliant string attribute. Another issue
is about security: table creational methods exposed in the
com.geodetix.geo.ejb.GeometryBean home interface should be protected by
a proper role-base security policy, to avoid normal users deleting database
tables.
Nevertheless our application, even if quite simple, still holds a lot of
generality and some of the implemented patterns or components are readily
usable in real-world applications.
2. Directory Contents
---------------------
./ Build scripts (build.*), README and licensing information
./src Java source packages and files
./resources EJB specific configuration files
./lib JAR libraries needed to compile and run
3. Software Requirements
------------------------
We here list all third-party libraries with their versions tested to work
with the application.
PostGIS JDBC driver version 1.1.3
http://www.postgis.org/
PostgreSQL JDBC driver version 8.1-404 jdbc3
http://jdbc.postgresql.org/
XDoclet lib version 1.2.3
http://xdoclet.sourceforge.net
Apache ANT version 1.6.5
http://ant.apache.org/
JBOSS Application Server version 4.0.4.GA-Patch1
http://www.jboss.org/
Note that our tool is application server agnostic and could be easily ported
to any EJB 2.x compliant Container by modifying the provided deployment
ant file which is, in turn, written for the JBoss Application Server.
4. Installation
---------------
After downloading (and compiling, if necessary) all of the required software,
follow these steps:
- copy the PostGIS driver (postgis_1.1.3.jar) into the ./lib/commonlib
directory
- copy the PostgreSQL driver (postgresql-8.1-404.jdbc3.jar) into the
./lib/compiletimelib directory
- copy the XDoclet libraries (contained in xdoclet-lib-1.2.3.tgz) into the
./lib/xdocletlib directory
- install Apache ANT (follow the installation istructions provided
with the tool)
- install the JBoss Application Server
- make sure that your JBOSS_HOME environment variable correctly points to
the JBoss installation directory (i.e. /opt/jboss-4.0.4.GA)
- create a new PostGIS database according to what specified in the
./resources/build.properties with the "database.name", "database.login",
"database.password" properties (eventually change them to fit your needs).
5. Running
----------
Start the JBoss application server with the provided scripts
(run.bat or run.sh).
From the main application directory (./) execute these commands:
> ant install-JDBC-driver
This command installs the PostgreSQL driver into JBoss
> ant install-DataSource
This command installs the DataSource Connector into JBoss
> ant javadoc
This command generates the application API documentation into the ./javadoc
directory (use index.html to start).
> ant deploy
Installs the application into JBoss
> ant run-client
Allows to test the installed application
6. Code Details
---------------
The main components made available in the application are:
- GeometryBean.java
It is an entity bean containing a geometrical attribute of org.postgis.Geometry
type which could contain every geometrical type (i.e. POINT, LINESTRING, etc.).
The user can choose wether to create a NON-OpenGIS or an OpenGIS-compliant
bean. The first ones can contain different geometric types in the same table
with undefined SRID (-1), while the second ones can only contain object of the
same type and SRID in one table;
- PostgisGeometryDaoIml.java
A DAO (Data Access Object) implementing persistence operations for the
GeometryBean EJB in a PostGIS database;
- GeometryFacadeBean.java
A stateless session bean implementing the interface between the geometric
entity beans and the client applications;
- Client.java
It is a simple client executing some tests thus illustrating the use of the
provided API.
Further informations could be gathered from the source code and by reading the
javadoc API documentation.
|