You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 16 Next »

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>

<!-- The JMSServer section is only required for the writing of timeseries
     For a read only instance this section must be omitted. -->
     <jmsServer>
        <!-- JBOSS version -->
        <appServerType>jboss7</appServerType>
        <!-- JBOSS server name or IP -->
        <appServerName>L00560</appServerName>
        <!-- Listener port of JBOSS. Depends on JBOSS version used -->
        <appServerPort>4447</appServerPort>
        <!-- Root element of JNDI queue -->
        <rootJNDI>/TEST/REGION/MC00/</rootJNDI>        
    </jmsServer>
</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'

Data Access Component

Copy the following two files to the <Tomcat_installation>/lib directory:

  • Dac.jar (provided by Deltares)
  • log4j-<version>.jar (retrieve from Fews-bin directory)

Now update the Tomcat server configuration file; <Tomcat_installation>/conf/server.xml as described below:

Add DacLifecycleListener
Between the element tags <Host> ... </Host> add the following lines:

<Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
...
   <!-- Class that listens to Tomcat lifecycle events in order to shutdown DataAccessComponent -->
   <Listener className="nl.wldelft.fews.system.data.dac.DacLifecycleListener"  />
...
</Host>

Add DAC as 'global resource'
Between the element tags <GlobalNamingResources> ... </GlobalNamingResources> add the following lines (update where necessary):

<!—
Definieer DAC global resource in het bestand server.xml. Paden moeten absolute zijn:
windows: d:/fews/bin of d:/fews/hhnk_da; linux: /fews/bin of /fews/hhnk_da
-->
<GlobalNamingResources>
...
<Resource name="global_resource_naam" auth="Container"
            type="nl.wldelft.fews.system.data.dac.DataAccessComponent"
            factory="nl.wldelft.fews.system.data.dac.DacBeanFactory"
            regionHome="absoluut pad naar fews_home_dir"
            binPath="absoluut pad naar fews_bin_dir" />

</GlobalNamingResources>

Webservice (Umaquo example)

In the <Tomcat_installation> directory create a subdirectory 'fews'. Copy the war file containing the webservice application into this sub directory. Now create a Context XML configuration file for this webservice. Give this XML file an appropriate name that reflects the purpose of this webservice, as this is also the name you will see in the Tomcat Manager application list (eg. <fews_region_home>.xml).

The content of this file will vary depending on the implementation of your webservice.

However the following elements are required for all webservices:

ResourceLink : allows the webservice to connect to the global resource configured in server.xml.
Loader : allows the webservice to share the class loader used by the DAC
Parameter resouceId: the webservice must know the id of the global resource to retrieve
Also make sure that the value for docBase points to your webservice war file in the fews subdirectory.

<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<!-- Location of specific AI war file. (Can be a symlink) -->
<Context docBase="${catalina.home}/fews/UmAquo.war" antiJARLocking="true" crossContext="true" >
    <!— 'clientConfigFileId' verwijst naar een FEWS configuratie bestand in de FEWS configuratie folder 'PiClientConfigFiles'. -->
     <Parameter name="clientConfigFileId" value="umaquo.properties" override="false"/>
    <!—resourceId moet gelijk zijn aan 'name' van 'ResourceLink' hieronder -->
     <Parameter name="resourceId" value=" resourcelink_naam " override="false"/>
     <Parameter name="serviceName" value="MetusDataService" override="false"/>
     <Parameter name="namespaceUri" value="http://umaquo.wldelft.nl" override="false"/>
     <Parameter name="portName" value="MetusDataServiceSoap" override="false"/>
    <!—  'umaquo_config_naam' is gelijk aan de bestandsnaam van dit configuratiebestand zonder toevoeging '.xml' -->
     <Parameter name="wsdl" value="http://localhost:8083/umaquo_config_naam/umaquo?wsdl" override="false"/>
    <!—  zet 'naam resoucelink'  gelijk aan 'naam global resouce'. 'naam global resource' moet gelijk zijn aan de DAC rousouce naam in het bestand 'server.xml'-->
     <ResourceLink name="resoucelink_naam"
                  global="global_resource_naam"
                  type="nl.wldelft.fews.system.data.dac.DataAccessComponent"/>

     <Loader loaderClass="nl.wldelft.fews.system.data.dac.DacClassLoader" delegate="true"/>

To deploy the webservice copy the Context XML configuration file to the <Tomcat_installation>/conf/Catalina/localhost directory.

  • No labels