Introduction
The Data Access Component (DAC) plays a new role in the FEWS system. It allows webservices that are deployed in the same servlet container as the DAC to communicate directly with the FEWS central database.The DAC makes use of the FEWS OpenAPI to communicate with the attached webservices.
The main functionality of the DAC is given below.
- Allow webservice deployed in a Servlet container such as Tomcat to access the FEWS central database directly or through an instance of the DataStore component. Through the DataStore component it will be possible to access the following information:
- read / write timeseries
- read / log messages
- read FEWS configuration
- run workflows
Design
The Design of the FEWS data access component is directly linked to the FEWS database model. For more information on the design of the FEWS database model we refer to documentation of the Master Controller database.
The Data Access Components will make use of existing components such as the DataStore component currently used by the FEWS client instances (OC, FSS) and the ExtendedDataSource components used to connect to de Master Controller database.
Data Access Component
Is a java class that is configured as a Global Resource in a Servlet container and will be initialized as a Singleton for each database connection. The Data Access Component will implement an interface that will allow webservices to access the FEWS DataStore. In the future this interface can be expanded to provide more convenience methods and to reduce code duplication. All resources used by the Data Access Component will be added to the Tomcat class path. This way it is possible for other webservices deployed in the same Servlet container to access and use the DataStore without having to include all FEWS data access resources.
Each instance of the Data Access Component represents one database connection for one FEWS region.
DataStore
This component will be initialized once the Data Access Component is initialized. A DataStore requires an instance of a ExternalDataSource (connection to MC database) and a reference to a cache directory for storing the datastore cache files. This information is configured in the Global Resource of the Data Access Component.
ExternalDataSource
This is a component required by the DataStore. This component will be configured as a separate Global Resource within the Servlet container. Only one ExternalDataSource instance is allowed per Master Controller database.
FEWS Webservice
A FEWS webservice component that uses the Data Access Component can do so by performing a lookup from the InitialContext. Each webservice can use the FEWS configuration present in the central database. It is up to the webservice itself to decide how it wishes to publish the available information to the outside world. This can either be done by publishing Capabilities in the same way OGC standards do this (WMS, WFS, WaterML) or by configuration such as the FewsPiService does this.
Security
To secure access to the Data Access Component or to individual webservices there are standards provided by the Servlet container. We will make use of these standards wherever and whenever required.
Installation
Here follows a list of applications that need to be installed in order to use the DAC:
Java
Download the latest stable release for the JRE (version 1.6.23 or higher).
Tomcat
Download the latest stable release for Tomcat (version 6.0.35 or higher).
Fews bin + region home
Install a Fews bin directory and Region Home directory as you would for an Operator Client. Make sure these directories are accessible from the Tomcat installation. In the Region Home directory copy the files 'clientConfig.xml' and 'log4j.properties' shown below. Change the values in example to match the values of your system.
clientConfig.xml:
<?xml version="1.0" encoding="UTF-8"?> <clientConfiguration xmlns="http://www.wldelft.nl/fews" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wldelft.nl/fews http://fews.wldelft.nl/schemas/version1.0/clientConfig.xsd"> <databaseServer> <!—Keuze uit: postgresql, oracle of sqlserver --> <dbServerType>postgresql</dbServerType> <dbServerName>db_serverhostname</dbServerName> <dbServerPort>db_port </dbServerPort> <dbInstanceName>database name</dbInstanceName> <dbInstanceUser>user</dbInstanceUser> <!-- <dbInstancePassword>clear text password</dbInstancePassword> --> <dbInstanceEncryptedPassword>encrypted password</dbInstanceEncryptedPassword> </databaseServer> </clientConfiguration>
log4j.properties
# This configuration file should be placed in the FEWS region home directory in order for DAC to load it. # Change the <region_name> to match name of actual region. log4j.debug=true log4j.rootLogger=INFO, DAC # Define all the appenders log4j.appender.DAC=org.apache.log4j.DailyRollingFileAppender log4j.appender.DAC.File=${catalina.base}/logs/DAC_<fews_home_dir>.log log4j.appender.DAC.Append=true log4j.appender.DAC.Encoding=UTF-8 # Roll-over the log once per day log4j.appender.DAC.DatePattern='.'yyyy-MM-dd'.log'