Frameworks
This is a collection of information about common frameworks used in DHIS 2.
Hibernate
Hibernate is a persistance framework for Java objects. It abstracts away an underlying database and maps POJOs to specific tables. Hibernate supports standard CRUD operations and has powerful querying facilities.
DHIS 2 uses Hibernate to become database independent and in order to make the Java code cleaner with regard to persistence. All the model objects in DHIS 2 are POJOs, and persistence is handled by a set of stores (for example DataStore) with Hibernate implementations (HibernateDataStore).
Using Hibernate in DHIS 2 is simple: Just include a dependency to dhis-support-hibernate in your project. POJOs are mapped to tables in various hibernate mapping files (e.g. DataValue.hbm.xml), where one can choose to specify table and column names and types.
See more info on Hibernate.
Spring
Spring is a lightweight container. In DHIS 2 it is used to wire classes together. Typically it is used to selected which implementation of an interface to use in different classes. The wiring is externalized into special beans.xml files, which enable us to rewire the entire system without having to recompile any classes. When the system starts, the configuration files are read by Spring which then creates different objects and wire them together using public set methods.
Most DHIS 2 modules have a beans.xml located in src/main/resources/META-INF/dhis.
See more info on Spring.
WebWork and Velocity
WebWork is a framework for making web GUIs. The default GUI implementation in DHIS 2 is a web implementation. WebWork maps specific URLs to Action classes, which prepare data for display on a web page. The resulting data is rendered by Velocity templates, which offers a simple syntax for referring to variables, loops, macros and the like. This way the presentation logic is completely separated from the system, and the actual views are organized in the Velocity templates.
See more info on WebWork.
JUnit
JUnit is used to provide unit tests. JUnit is integrated directly into the Maven build tool, so all unit tests are run as part of the build process.
All JUnit tests of a project reside in src/test/java, with resources located in src/test/resources.
See more info on JUnit.