Saturday, April 16, 2011

Re: Access Service Layer inside RequestFactory EntityLocator

Example Code: 

// service layer decorator

public class AppServiceLayerDecorator extends ServiceLayerDecorator {

// ....

        @Override
public <T extends Locator<?, ?>> T createLocator(Class<T> clazz) {

HttpServletRequest request = RequestFactoryServlet
.getThreadLocalRequest();
ApplicationContext context = WebApplicationContextUtils
.getWebApplicationContext(request.getSession()
.getServletContext());

return context.getBean(clazz);
}
}

// request factory

public class AppRequestFactoryServlet extends RequestFactoryServlet {

private static final long serialVersionUID = -3364570784675688621L;

public AppRequestFactoryServlet() {
this(new DefaultExceptionHandler(), new AppServiceLayerDecorator());
}

public AppRequestFactoryServlet(ExceptionHandler exceptionHandler,
ServiceLayerDecorator... serviceDecorators) {
super(exceptionHandler, serviceDecorators);
}

}

// web.xml

         <servlet>
<servlet-name>requestFactoryServlet</servlet-name>
<servlet-class>in.verse.calldesk.server.AppRequestFactoryServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>requestFactoryServlet</servlet-name>
<url-pattern>/gwtRequest</url-pattern>
</servlet-mapping>

Thanks,

--
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


Real Estate