BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News OpenXava 4.0 Supports JPA 2.0 and Dependency Injection

OpenXava 4.0 Supports JPA 2.0 and Dependency Injection

This item in japanese

Bookmarks

The latest version of Java based model-driven development framework OpenXava supports JPA 2.0 and Dependency Injection. OpenXava version 4.0 was released in November and version 4.0.1 was released last week. The new version also includes improvements in Groovy support.

OpenXava framework supports Java application development based on the domain classes written in Java or Groovy classes annotated with JPA. The main components of the framework are:

  • Business Component: Business components are the core components to create applications in OpenXava. A business component is a Java class (or an Entity defined in XML) that contains all the information about a business concept that you require to create applications for it.
  • Controller: A controller is a set of actions where an action is a button or link that a user can click. They define the actions that user can do with the business component in the application. One controller can be assigned to several business components.
  • Application: An OpenXava application is a set of modules. A module joins a business component with one or more controllers.

You can use Dependency Injection (JSR-330) in action classes to inject a session object into a field of the Action class. JPA 2.0 is used for the data persistence. OpenXava version 4.0.1, recently released, also supports callback methods with some new callback annotations (@PreCreate, @PostCreate, @PreDelete) so the developers can use JPA inside the classes. For example, using @PreCreate annotation you can perform logic that will be executed before persisting the object. It allows to perform entity manager operations and queries that are not allowed in JPA callbacks.

The new Groovy support can be used to write different OpenXava components like JPA entities, actions, and the test cases. InfoQ caught up with Javier Paniza of OpenXava project team, to learn more about the new release and future enhancements of the framework.

Can you expand on the new Groovy support?

Since version 4.0 you can write all the code of your OpenXava (OX) application using Groovy instead of Java, you can even mix Java and Groovy code in the same application, so you can start adding Groovy to your existing applications little by little.

Integrating Groovy in OpenXava has been a very easy task, given that Groovy was specially designed to be integrated with Java. However, the added value for the OpenXava developer is very big, because the simplified syntax of Groovy. Until version 2.0, OpenXava used a XML syntax for defining business components, this syntax allowed a short learning curve of OX, even for non-Java programmer. When we started to use Java for defining business components, the flexibility of the framework was improved, but we lost some simplicity. With Groovy we go back to a simpler syntax without losing flexibility.

One important difference between OpenXava with Groovy and Grails is that in OpenXava you write your code using standard Java technologies. That is, you write JPA entities with Groovy, and you use dependency injection (JSR-330) with Groovy. You use Groovy but at the Java style, not at the RoR style. This allows you to take the domain code (the JPA entities) from your existing Java application (even from a Seam or Spring Roo application), put them into an OpenXava application, and get an AJAX application in no time at all. Then you can start to add Groovy little by little in your application.

Responding to a question on the application security support (in the areas of authentication, authorization, auditing etc) by the framework, Javier said OpenXava doesn't directory provide any security support but it has a good support for Java portals (JSR-168/286), including visual style integration. OpenXava generates portlet applications whose portlets have the look & feel of the container portal. So, if you combine OpenXava (the application modules) with Liferay (security and navigation) you get a complete application platform for free. If using a Java portal is not an option for you, just add security to your OpenXava application using the standard techniques, tools and frameworks available for securing Java Web applications.

What is the future roadmap of the project in terms of new features and enhancements?

We have started a new way of incremental improvements, that is, instead of having a 5.0 version in two years, we'll have versions 4.1, 4.2, 4.3, each several months apart. In general we'll continue improving the user interface and adding new features for developers. For 4.1 release, we expect to add HTML5/CSS3 and JSR-303 (Bean validation) support, and possibly some improvements of list search capacities.

 

Rate this Article

Adoption
Style

BT