Guice AOP and the Java Persistence API

The Java Persistence API provides a programming language framework for managing relational data through entity management and ORM APIs. Libraries like Hibernate and Guice Persist implement the services defined in the JPA specification. The result is an abstraction layer that manages the underlying concerns of a relational database while providing a consistent API that doesn’t vary from one database to another.

However, even with a database abstraction layer, there are instances where the concerns of the database are also the concerns of the programmer. Moreover, these concerns can affect a number of areas in an application, and addressing them often leads to code duplication.

Aspect-oriented programming (AOP) is a programming paradigm that addresses cross-cutting concerns and eliminates the need for code duplication. Guice has built-in support for method interception that brings the AOP programming paradigm to life.

Read more on Guice AOP and the Java Persistence API

The Guava EventBus on Guice

Guava’s EventBus provides a publish-subscribe event mechanism which allows objects to communicate with each other via the Observer Pattern. The EventBus shies away from the traditional “Event Listener” pattern seen in Java where an object implements a particular interface and then explicitly subscribes itself with another object.

In a recent project we chose to use the EventBus in conjunction with Guice (a dependency injection library) and have had a lot of success with it. Specifically, objects in our system only have to express what events they care about without being required to explicitly register with the EventBus or any other object. Read more on The Guava EventBus on Guice…

Porting Android Code to BlackBerry

After completing an Android application, we were asked to port it to BlackBerry. The Android code follows the Presenter First design pattern; therefore, we initially assumed that we would be able to re-use all the models. However, porting even the non-UI code was surprisingly difficult: The BlackBerry JVM is based on Java ME (a limited subset of the standard Java SE); therefore,

Read more on Porting Android Code to BlackBerry…