Archive for the tag 'google guice'

Okt 15 2009

Solve the circular reference problem with Guice and Spring

Published by under Guice,Spring

  


The problem

Just imagine you run into a case where two objects are dependent on each other. The following picture and code snippet shows one such relationship.

Technorati Tags: circular reference dependencies, google guice, Java, Spring

2 responses so far

Feb 21 2008

Hibernate with Guice – Part II



Welcome back to Part II about using Hibernate with Guice. If you just stepped in, i recommend first to read Part I here.


Part II – Adding Guice to the Hibernate-Application

This application uses Guice’s Dependency Injection to create the HibernateConnection-instance and the OrdersDAO-instance. You can see that HibernateUtil don’t need STATICs anymore. Access to HibernateUtil is wrapped through a HibernateConnection which is created in a ConnectionProvider as a Singleton. Providers are acting as Factories in creating and returning Objects.

Technorati Tags: google guice, Hibernate, Java, mysql, NetBeans

5 responses so far

Feb 21 2008

Hibernate with Guice – Part I

Published by under Guice,Hibernate,Java



In this Blog you will see how to add Google-Guice functionality to a Hibernate-Application. In Part I i will introduce a simple Hibernate-Application. In Part II you can see how this Application will be transformed for using Guice.

Note:
This was my first attempt working with Guice, so i think there are many points which can be improved.

But first for these peoples who doesn’t know what is Guice, Guice is a new lightweight Java 5 Dependency Injection Framework. It is working with Annotations. You should not compare Guice with Spring. Guice focus is on Dependency Injection, where Spring has become popular in the Java community as an alternative, replacement, or even addition to the Enterprise JavaBean model. Google produced Guice for one of their biggest applications – AdWords!

Download-links to all files are available at the end of this posting. Comments are included in the source-listings.

Technorati Tags: google guice, Hibernate, Java, mysql, NetBeans

5 responses so far