Configurating DiF

DiF provides several configuration options. Let's see a description of each of them.

Web Application configuration: Web.xml

In a typical web.xml for a DiF2 application the following is a valid sample template:

<?xml version="1.0"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd">
    <description>Application Description</description>

    <!-- Page DIF Listener -->
    <servlet>
        <servlet-name>page</servlet-name>
        <servlet-class>pt.digitalis.dif.listeners.HttpListener</servlet-class>
    </servlet>

    <!-- AJAX DIF Listener -->
    <servlet>
        <servlet-name>ajax</servlet-name>
        <servlet-class>pt.digitalis.dif.listeners.AJAXListener</servlet-class>
    </servlet>

    <!-- Docs DIF Listener -->
    <servlet>
        <servlet-name>doc</servlet-name>
        <servlet-class>pt.digitalis.dif.listeners.DocumentListener</servlet-class>
    </servlet>

    <!-- Asset DIF Listener -->
    <servlet>
        <servlet-name>asset</servlet-name>
        <servlet-class>pt.digitalis.dif.listeners.AssetListener</servlet-class>
    </servlet>

    <!-- Chart tag servlet -->
    <servlet>
        <servlet-name>chart</servlet-name>
        <servlet-class>pt.digitalis.dif.presentation.views.jsp.taglibs.chart.ChartServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>page</servlet-name>
        <url-pattern>/page/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>ajax</servlet-name>
        <url-pattern>/ajax/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>doc</servlet-name>
        <url-pattern>/doc/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>asset</servlet-name>
        <url-pattern>/asset/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>chart</servlet-name>
        <url-pattern>/chart/*</url-pattern>
    </servlet-mapping>

    <!-- Servlet Filter -->
    <filter>
        <filter-name>RESTFilter</filter-name>
        <filter-class>pt.digitalis.dif.listeners.RESTRequestsFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>RESTFilter</filter-name>
        <url-pattern>/page/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>RESTFilter</filter-name>
        <url-pattern>/ajax/*</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>RESTFilter</filter-name>
        <url-pattern>/doc/*</url-pattern>
    </filter-mapping>

    <!-- Mappings -->

    <mime-mapping>
        <extension>html</extension>
        <mime-type>text/html</mime-type>
    </mime-mapping>
    <mime-mapping>
        <extension>txt</extension>
        <mime-type>text/plain</mime-type>
    </mime-mapping>

    <!-- Tag Librarys -->

    <jsp-config>
        <taglib>
            <taglib-uri>/difcore</taglib-uri>
            <taglib-location>/WEB-INF/dif-core.tld</taglib-location>
        </taglib>
    </jsp-config>
    <login-config>
        <auth-method>BASIC</auth-method>
    </login-config>
    
    <listener>
        <listener-class>pt.digitalis.dif.startup.DIFWebAppStartup</listener-class>
    </listener>    
</web-app>

As you can see there are basically two points of interest:

DiF Listener servlet HttpListener

All DiF web application must have this servlet.
It is the listener that receives and delegates the execution of all services.

Chart renderer servlet ChartServlet

If the chart component is used this servlet must be enabled. If not, can be disabled. It creates the image representation of the requested charts.

Must only be used by the chart component, not directly since the internal logic of chart data retrieval is implemented in the chart component and may change without further notice.

DiF basic configuration file (dif2.properties)

This file contains the basic configurations that the DiF needs to get it's core modules up and running. The configuration system is not used for these configurations since they are so basic that the configuration module is not available to DiF when these are required.

For a better view of the point in time when this is read, not even the IoC is available, which, is the provider for all module implementations of DiF's features. One of these configurations is precisely how the IoC will find it's modules.

Let's see a complete list of the options available in this file:

  • iocImplementation: The IoC implementation to use. Default to "guice". At the moment only Google Guice is available.
  • logLevel: The log level. Default to "warn". See all levels here.
  • moduleParser: How DiF will search for new modules. Default to "fast". See all search methods here.
  • messagesLocation: Where/how to look for message files. Defaults to "messages_folder". See all options here.

Location of the file

DiF searches the file in any classpath listed directory. Normally we place this in the Application Server's configuration directory. I.e.: $JBOSS_HOME/server/default/conf.

In theory you could include this file in your WAR/EAR application. This is perfectly possible, but not advised, since it will make it impossible to override these configurations in the deployment environment, for instance, to change active the debug log level.

Sample dif2.properties

loglevel=info
moduleparser=fast

defaultlanguage=en
messagelocation=messages_folder

Configuration Points

DiF uses the Configuration-utils module for configuration/preferences. There are several classes on DiF's modules that save their preferences with this system and allow configuration through it.

The editing of the configurations can be done in several ways:

  • Direct repository access: Check out how to do this here.
  • Through the Administration interface. NOT IMPLEMENTED YET!!!

Here's a list of these classes:

  • DIFStartupConfigurationParameters: General configurations:
    • defaultLanguage: Defaults to "en"
    • secondsForSessionCollection: Defaults to"30"
    • sessionInactivity: Defaults to "120000"
    • sessionTimeout: Defaults to "600000"
  • HTTPControllerConfiguration: HTTP Controller configurations:
    • dynamicErrorStageID: Defaults to "errorstage"
    • staticErrorPage: Defaults to "internal/staticErrorPage.jsp"
    • loginStageID: Defaults to "loginstage"
    • logoutStageID: Defaults to "logoutstage"
    • changePAsswordID: Defaults to "changepasswordstage"
    • homeStageID: Defaults to "homestage"
    • listenerName: Defaults to "listener"
    • listenerChartName: Defaults to "chart"
    • listenerDocName: Defaults to "doc"

Back to User Guide index