Chapter 6. Location Aware Services application development 213
6.3 Location Aware Services Java application
development
Location Aware Services is not limited to portlet development Everyplace Toolkit
for WebSphere Studio can also be used to develop Java applications that use
the Location Aware Services API.
6.3.1 Summary of Java application development
Developing a Java Location Aware Services application involves these steps:
1. Add all the JAR files in <WebSphere>LAS/las/lib into your project.
2. Find the atlas.properties file and add it to your project.
3. Modify the atlas.properties file (Example 6-1 on page 214). This is a global
file for the Atlas Location Aware Services middleware. By default, Atlas loads
this file from com.ibm.atlas.properties file, but may be pointed to directly by
the system property ATLAS_PROPERTIES.
4. Modify the servicePropertiesRoot to point to the folder where the Location
Aware Services adapter properties files are located. Location Aware Services
adapter properties files are located in the directory
<WebSphere>/LAS/las/service_properties.
5. Modify the trace and log level accordingly. Setting trace on and to high will
slow down the system performances.
6. Set useConsoleLog or useConsoleTrace to true causes the log and trace
messages to be written to the Portal server log and trace file, or the
messages will be written in the file specified by logFileName and
traceFileName properties.
7. ClientName and Password are clear text values used to gain access to
services when no corresponding properties are provided in individual service
properties file.
8. Atlas gives a default service failover policy file. But you could write your own
service failover policy class, which implements the ServiceFailoverPolicy
interface to define how the system should behave when a service fails. If you
define your own service failover class for a particular service, this should be
specified by the <service-type>FailoverPolicyClass.
9. Specify the proxy the service adapters have to use by the HTTPProxy
property.
214 IBM WebSphere Everyplace Access V5, Volume IV: Advanced Topics
Example 6-1 Sample atlas.properties file
logDirectory=C:\\WebSphere\\LAS\\logs
logFileName=atlas.log traceFileName=atlas.trace
registryClassname=com.ibm.atlas.system.PropertiesFileServiceRegistry
servicePropertiesRoot=C:\\WebSphere\\LAS\\las\\service_properties
useConsoleLog=false
useConsoleTrace=false
# Set to one of 'warn', 'info' or 'error'.
logLevel = warn
#Set to one of "high", "medium", "low", or "none".
traceLevel = none
clientName = dummy
clientPassword = dummy
defaultUserLanguagePreference = en
#<service-type>FailoverPolicyClass =
#
# Specifies the default failover policy class. If not set, defaults to
# com.ibm.atlas.system.DefaultServiceFailoverPolicy.
#
#defaultFailoverPolicyClass =
#Coordinate reference system classes
CRS.WGS84.className = com.ibm.atlas.geometry.WGS84ReferenceSystem
CRS.EPSG:4326.className = com.ibm.atlas.geometry.WGS84ReferenceSystem
HTTPProxy=
10.Modify the service properties and the properties file of the service provider.
The properties file must be located in the directory as specified in the
atlas.properties file. For the adapters provided along with Location Aware
Services, the properties file are under the directory
<WebSphere>/LAS/las/service_properties.
11.The properties file is used by the Location Aware Services Engine to select
the appropriate adapter depending on the serviceType and serviceName
(service provider). Also, this properties file specifies the location of the
initPropertiesFile. Example 6-2 shows the service properties file for the
mapping service provided by Webraska.
12.The service provider properties file contains information required by the
adapter. The parameters in the properties file depend on the service provider.
Example 6-3 on page 215 shows the Webraska adapter’s properties file.
Example 6-2 Mapping Service properties
serviceType = mapping
className = com.ibm.atlas.adapters.webraska.WebraskaMappingService
serviceName = webraska-na.MappingService
initPropertiesFile = webraska-na/init.properties
Chapter 6. Location Aware Services application development 215
Example 6-3 Webraska service init properties
server = dummy.webraska.com
path = /gns
clientName = demo clientPassword = demo
connectionTimeout = -1
#geolang = en
13.Initialize the service as shown in Example 6-4.
Example 6-4 Initializing the service
GeocodingService geocodingService = new GeocodingService(geoProps);
MappingService mappingService = new MappingService(mapProps);
This command invokes the Atlas core components, which connects to the
appropriate service provider using the property files. The code allocates two
Location Aware Services that are used in the application: geocoding and
mapping. The Location Aware Services provide access to multiple providers
of the location services. Location Aware Services searches among the
registered services for the one that fits the specifications provided in the
properties file, such as the geography, and returns the first match.
GeocodingService is defined in the package com.ibm.atlas.Geocoding.
GeocodingService determines the location of the given address.
MappingService is defined in the package com.ibm.atlas.Mapping.
MappingService returns a map of the given location.
14.The Construct and Address object is used by GeocodingService to obtain the
location. The address is defined in the package com.ibm.atlas.GeoCoding.
This class represents an address and is loosely based on RFC 2426 and
ISO/ISE 11180.
Note: To learn about the different parameters that are required by the
adapters that are provided by WebSphere Everyplace Access, see the
InfoCenter (select Location Aware Services
Managing
Administrative Services
Properties for Service Provider
Configuration Profile).

Get IBM WebSphere Everyplace Access V5 Handbook for Developers and Administrators Volume IV: Advanced Topics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.