RequestFactory, ServiceLocator and Spring
I am trying to find a good solution to integrate the RequestFactory
with Spring. I implemented this ServiceLocator (no exception handling
included for simplicity):
public class SpringServiceLocator implements ServiceLocator {
@Override
public Object getInstance(Class<?> clazz) {
HttpServletRequest request =
RequestFactoryServlet.getThreadLocalRequest();
ApplicationContext context =
WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
return context.getBean(clazz);
}
}
I annotate my RequestContext with the GWT @Service annotation (not the
Spring one). Example below:
@Service(locator = SpringServiceLocator.class, value =
AddressService.class)
public interface AddressRequest extends RequestContext {
// Get address by id
Request<AddressProxy> get(Long id);
}
When I fire the Address request using RequestFactory, the
SpringServiceLocator locates the AddressServiceImpl.class and returns
an instance. The method "public Address get(Long id)" is called and
returns a new instance of an Address object.
So it works... but is there a better way? Is the lookup in
getInstance() to slow, could anything be cached, etc. Any input is
welcome.
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home