Integrating PrimeFaces with GuiceyFruit on JPA
Following suggestions from James Stratchan and Catagay Civici, I set my foot to integrate GuiceyFruit with JPA for the PrimeFaces tutorial I wrote. You could download the example hosted there and try it. Here are the steps I followed on that Book-Store example and ended up with a cool working code.
1) Add the following repository to pom.xml
<repository>
<id>guiceyfruit.release</id>
<name>GuiceyFruit Release Repository</name>
<url>http://guiceyfruit.googlecode.com/svn/repo/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
2) Add the following dependencies
<dependency>
<groupId>org.guiceyfruit</groupId>
<artifactId>guiceyfruit-jpa</artifactId>
<version>2.0-beta-7</version>
</dependency>
3) Comment/remove the following dependency
<!--dependency>
<groupId>com.google.code.guice</groupId>
<artifactId>guice</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
</dependency-->
4) Open the dataservice bould concrete implementation (e.g. BookStoreImpl in the example) and replace @Inject with @javax.persistence.PeristenceContext.
public class BookStoreImpl implements BookStore { @PersistenceContext() private EntityManager em; }
5) Open the WEB-INF/web.xml and modify the context-param ‘optimus.CONFIG_MODULES’ like this
<context-param>
<param-name>optimus.CONFIG_MODULES</param-name>
<param-value>com.ts.pfaces.core.BookStoreModule
,org.primefaces.optimus.persistence.JPAModule
,org.guiceyfruit.jpa.JpaModule
</param-value>
</context-param>
And voila it works!