Java 5

Java 5 Language Enhancements

The Java 5 language environment provides improves maintainability and increases programmer productivity.

Java 5 is fully exploited by Tolven and the use of its features is encouraged.

Generics

Generics reduce errors and overall yield much cleaner and more readable code. Generics are used extensively in Tolven and are, by convention, required for collections.

For example, the following is taken from org.tolven.rim.Act:

    public List<II> getId() {        if (id == null) {            id = new ArrayList<II>();        }        return this.id;    }		  

It should be obvious from the signature along and without additional documentation that the list returned will contain instances of the II (instance identifier) class. The compiler and runtime will verify that this is always true. See the Sun Generics Tutorial for more details.

Annotations

According to Java, annotations do not directly affect program semantics, but they do affect the way programs are treated by tools and libraries, which can in turn affect the semantics of the running program. In other words, annotations are meta-data.

Annotations are superior to XDoclet or XML “side-files” that easily get out of sync with the source code and require additional steps to validate. Annotations allow metadata to be type checked and symbolically validated along with the rest of the source code it annotates.

Tolven does not currently define any annotations, but makes extensive use of them, especially as they are defined by Enterprise Java Beans (see EJB3).

An example extracted from org.tolven.doc.bean.documentBean initializes the JAXB context when the bean is constructed.

@PostConstructpublic void init() {    setupJAXBContext();}

See the Sun Tutorial on Annotations for more information.

Enhanced For Loop

Using generics for loops are now more readable and maintainable. Much less clutter.

Here’s an example from the menu configuration bean org.tolven.app.bean.MenuBean. It processes a list of menu definitions back into the database. Type safety is intrinsic with the use of generics, and no casting is needed so no additional argument checking is required.

public void updateMenus( List<MenuStructure> menus) {    for (MenuStructure m : menus ) {        em.merge(m);    }}

Tolven uses this for loop syntax whenever applicable. While not banned, iterators are not currently used in Tolven.

Autoboxing

Autoboxing removes the need for routine conversion between primitive types and their object counterparts. Interestingly, the extensive use of autoboxing in Tolven almost seems transparent. One has to look hard to notice, for example, that a primitive type is required where an object is the only thing available. A simple example from the Tolven data generator:

public long countPeople( ) {    Query query = em.createQuery( "SELECT COUNT(c) FROM VirtualPerson c");	Long rslt = (Long) query.getSingleResult();	return rslt;}		  

The Sun tutorial on Autoboxing/Unboxing has additional details.

Back to the top
Back to the top

Support & Consulting

Tolven offers a number of training packages and access to an ongoing Webinar series to enable you to make the most of the Tolven Platform and application framework. For ongoing support and maintenance, we offer four levels of technical support to enable you to select what's right for your organization.

Visit TolvenHealth.com

In Production

The Tolven Platform is rapidly becoming the most widely adopted open source solution for healthcare information technology globally. Tolven clients in Europe, North America, and Asia are leveraging the breadth of solutions the Tolven technology can support to serve their needs.

See sample client descriptions

The Tolven Platform

The Tolven Platform takes advantage of a broad, flexible, and open source architecture that gives healthcare and life sciences professionals as well as patients the information they need in an open and extensible solution. The Tolven Platform and applications have global applicability.

Read more