persistence integration with Guice

9 views
Skip to first unread message

transmeta01

unread,
Feb 7, 2011, 11:15:29 PM2/7/11
to classic dev
Hi Cristian,

I did some spikes on the project for the persistence managed by Guice.
It looks like the project will have to use Guice 3.0 to be able to
benefit from the merging of warp-persist and Guice.

Currently, integration with RESTeasy and Guice seems to be okay. It's
not tested yet as the resources classes are not implemented, in most
part, yet. So far the resources class are detected and initialized by
Guice and RESTeasy.

Try and see if you can find a maven repo for the guice 3.0*RC* wiht
the sources and javadocs if possible. I have been trying to analyse
the code source and javadocs for 2.0.1, but it does not seem to be
available here : http://guice-maven.googlecode.com/svn/trunk. Find it
for the 3.0 version.

I am working on a completely new user experience design and coding it
in GWT.

Regards
Richard

Cristian Olaru

unread,
Feb 10, 2011, 2:07:01 AM2/10/11
to class...@googlegroups.com
Hi Richard.

Please let me know the status of REST services implementation. Can you create a simple Test class to show how the REST service is called. The @Transaction annotations are working? Do you tested with Guice 3 already?

Because now the services/DAO is in a stabile state I want to concentrate on the REST tests. I will adapt the services/DAO/entities based on the input that I will get from REST services.

Regards..
--
Cristian Olaru
weblog: http://olaru.blogspot.com
mobile: 0743163039

Richard Mutezintare

unread,
Feb 10, 2011, 11:46:37 AM2/10/11
to class...@googlegroups.com
Hi Cristina, 

The resource implementation is at the very beginning. You can see that for now I only have skeleton code with comments. I will get back to you within the next few hours about that. For testing, we can use the RESTeasy client framework. You can mock the service needed by the resources or use the actual services implementation. 

I did a spike last night with Guice 3.0-RC2. I keep getting a `No JPA implementation bound` exception. There is little to no documentation of how this thing work. I checked to see if it could be missing dependencies of Hibernate, maybe, that is not detected at compile time. But that does not seem to be the case. I will send a message on the googgle-guice-dev mailing list.

I will write and push some code to jump start the resources implementation. 

Regards
Richard

Richard Mutezintare

unread,
Feb 10, 2011, 11:48:07 AM2/10/11
to class...@googlegroups.com
Sorry, I meant Cristian, the auto-complete feature of my phone is not really so good.

Cristian Olaru

unread,
Feb 11, 2011, 6:48:06 AM2/11/11
to class...@googlegroups.com
Hi Richard!

Maibe is not working with JPA 2.0. I tried a lot to make Guice work with declarative transactions but I didn't manage to do this. With Spring the things are very clear in this domain. I will wait for a result from you. And I will try to implement the Message service in this time.

Regards...

Richard Mutezintare

unread,
Feb 11, 2011, 10:59:04 AM2/11/11
to class...@googlegroups.com
Hi Cristian, I find it hard to believe that Guice cannot work with JPA 1.0 or 2.0. The reason why you are not getting the transaction to work most likely due to the fact that we have not managed to have Guice handle our EntityManager (implementation). 


One thing that you could try is integration with Hibernate (using xml, but I would prefer to use properties files) and see if that works. Since our transactions are application managed, I don't see any problem with that. 


I know Spring may have a better documentation, but I want to keep service code clean of any framework as much as possible. 

Try straight up hibernate integration and let me know how it goes.

Regards
Richard

Cristian Olaru

unread,
Feb 14, 2011, 1:50:05 AM2/14/11
to class...@googlegroups.com
Hi Richard.

I integrate guice,  resteasy-guice, wideplay.warp at the versions  from pom.xml. The  @Transactional annotation is working now.
See the  UserResourceTest as a sample of a resource test. JPA 1 is working with a persistence file stored in /src/test/resources/META-INF/persistence.xml. See that JPA 1 is used.

I integrate jetty so the tests can be executed in maven build process - I introduce all this resource tests in the integration phase (even if this tests are end 2 end tests). I keep the rest in unit tests maven build phase even some of them are integration tests.

I deleted some classes that you created for integrating persistence. If you need something you can merge them from previous revision.

I will continue to add end 2 end tests.

Regards...

Richard Mutezintare

unread,
Feb 14, 2011, 8:26:52 AM2/14/11
to class...@googlegroups.com

Thank you for the update. I will have a look and get back to you shortly.

Richard

sent from android 2.2

On Feb 14, 2011 1:50 AM, "Cristian Olaru" <col...@gmail.com> wrote:
> Hi Richard.
>
>>>> Sorry, I meant *Cristian*, the auto-complete feature of my phone is not

Cristian Olaru

unread,
Feb 14, 2011, 8:52:17 AM2/14/11
to class...@googlegroups.com
Hi Richard.

I updated UserResourceTest like here: http://docs.jboss.org/resteasy/docs/1.1.GA/userguide/html/RESTEasy_Client_Framework.html
I have a interface for UserResource used on both for server and client sides - in this way you can use the domain objects (User, Order, etc) on the client side - no need to compose manually JSON messages.

I will commit in this evening this changes.

Regards...

Richard Mutezintare

unread,
Feb 14, 2011, 9:46:42 AM2/14/11
to class...@googlegroups.com
The domain object are in package /shared, this makes them visible to GWT code as well as the server code. The server must be able to handle request for other clients, not just the GWT code and for that to happen, I choose not to use the GWT RPC mechanism, which would mean that all clients to the service would have to use GWT RPC to communicate with the service. I choose not to use GWT RPC to bypass that limitation. Also the client and server would have to serialize and de-serialize data from the wire...Using JSON as a format give the greatest flexibility.

GWT can work with JSON or XML very easily and on the server side, I see you annotated the entited class with JAXB binding, that too make handling the serialization and de-serialization simple.

I will get back to you with more after I look more in details the code.

Regards
Reply all
Reply to author
Forward
0 new messages