GenericServiceImplementation
(GenericServiceImplementation@groupWiki:gwtwidgets) 360 Hits - Changes: 1 - Last Change: 2007-01-28 20:11:57 by Herbert Poul (Kahless) - [ History ] [ Latest changes ]Page in Progress This page IS NOT finished.. you propably want to ignore it.. no idea if it will ever become useful .. but.. well .. it's just a collection of thoughts so i don't forget how i implemented my generic gwt services ;) This page describes how i built a generic service which automatically executes and returns named hibernate queries.The idea is pretty much based on the IBM developerworks article: Don't repeat the DAO! just adopted for the use with GWT.
Technology
For this to work i used- GWT (of course)
- Spring to manage my RemoteServiceServlet's
- Hibernate to access my data
- CGLIB to create a dynamic proxy.
Goal
The goal is pretty simply… Write as few code as possible.. for many data access operations this should be quite easy esspecially if you only need to fetch non-sensitive data where more or less no business logic is involved but only a simple hibernate query like 'from Config' which would return all 'Config' objects in the database.There are at least two java classes (actually… interfaces) which we need to create for GWT: one which extends RemoteService and is implemented by our servlet and one containing all AsyncCallback methods - but this should be all we need.BaseInformationService
public interface BaseInformationService extends RemoteService { /** * Returns a list of all configurations. * @gwt.typeArgs <net.sphene.spacecombat.beans.auto.Config> */ public List listConfig(); }
BaseInformationServiceAsync
public interface BaseInformationServiceAsync { public void listConfig(AsyncCallback callback); }
Configuration
The only information which is actually needed for retrieving a simple list of 'Config' objects is the hibernate query. This can be simply configured as named query within any hibernate mapping file (or as annotation):<query name="BaseInformationService.listConfig">from Config</query>Implementation
Since i were not able to create a proxy solely through spring configuration i created a FactoryBean which uses CGILIB to create a dynamic proxy which extends GWT's RemoteServiceServlet and implements any GWT service i want it to.TODO finish this !
| 0 Comments |
|---|
| You need to be logged in to post a Comment ! |