Java Database Application Library


Get JDAL (Java Database Application Library) at SourceForge.net. Fast, secure and Free Open Source software downloads

JDAL Core Spring Namespace

Since version 1.2.1, JDAL Core support a Spring custom namespace, in order to simplify application context configuration. Although JDAL configuration itself is quite simple, this is not the case of other modules as Swing and Vaadin, which require the definition of a considerable quantity of beans.

The JDAL Core namespace, http://www.jdal.org/schema/jdal , defines just one element, service, which lets declare jointly a DAO and a persitent service for one entity.

In previous versions DAO and persistent service declaration for the entity org.example.Entity was made as follows:

<bean id="entityDao" class="info.joseluismartin.dao.jpa.JpaDao">
    <constructor-arg value="org.example.Entity"/>
    <property name="criteriaBuilderMap">
        <map key-type="java.lang.String" value-type="info.joseluismartin.dao.jpa.JpaCriteriaBuilder">
           <entry key="entityFilter" value-ref="entityCriteriaBuilder"/>
        </map>
    </property>
</bean>
 
<bean id="entityCriteriaBuilder" class="org.example.dao.EntityCriteriaBuilder"/>
 
<bean id="entityService" class="info.joseluismartin.logic.PersistentManager">
    <property name="dao" ref="entityDao"/>
</bean>

With the new JDAL Spring namespace the same declaration shrinks to:

<jdal:service entity="org.example.Entity">
    <jdal:criteria name="entityFilter" builder="entityCriteriaBuilder" />
</jdal:service>    
 
<bean id="entityCriteriaBuilder" class="org.example.dao.EntityCriteriaBuilder"/>

The service element supports the following attributes:

Within service element an unbounded sequence of criteria elements may be defined. These elements specify the CriteriaBuilders that will initialize DAO CriteriaBuilders map.

The criteria element supports the following attributes:

As usual, you need to declare the JDAL namespace into the $lt;beans> element of the application context prior to its use. Defining a prefix for the namespace and schema localization as the rest of Spring namespaces.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jdal="http://www.jdal.org/schema/jdal" 
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.jdal.org/schema/jdal http://www.jdal.org/schema/jdal/jdal-core.xsd"
        default-init-method="init">
 
</beans>