Jan, It looks like the code you've implemented comes from the comments in this unit test class, which has access to both client and server code:
http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/requestfactory/server/testing/InProcessRequestTransport.java?spec=svn9374&r=9374 But in application code, as you've discovered, you can't call ServiceLayer.create in the client. The way I've added a ServiceLayerDecorator is to extend RequestFactoryServlet and override the no-arg constructor to add my custom decorator: public class MyRequestFactoryServlet extends RequestFactoryServlet { public MyRequestFactoryServlet() { this(new DefaultExceptionHandler(), new MySLD()); } public MyRequestFactoryServlet(ExceptionHandler exceptionHandler, ServiceLayerDecorator... serviceDecorators) { super(exceptionHandler, serviceDecorators); } } Don't forget to register MyRequestFactoryServlet in web.xml in place of RequestFactoryServlet. HTH, /dmc On Thu, Jan 6, 2011 at 3:22 AM, Jan Swaelens <[email protected]> wrote: > I am experimenting with the RequestFactory and came to a point where I > want to create my own ServiceLayerDecorator. > > I have read trough the available documentation and found that I need > to hook my custom service layer decorator up by calling this method > with an instance of my decorator: 'ServiceLayer.create()'. > > The code which I have implemented looks like this: > > ServiceLayer serviceLayer = ServiceLayer.create(new > MyServiceLayerDecorator()); > SimpleRequestProcessor processor = new > SimpleRequestProcessor(serviceLayer); > final EventBus eventBus = new SimpleEventBus(); > MyRequestFactory f = > RequestFactoryMagic.create(MyRequestFactory.class); > f.initialize(eventBus, new InProcessRequestTransport(processor)); > > Now, I tried to run with this code implemented in the 'onModuleLoad' > which is not working (it is referencing server classes and giving the > expected 'source not found for class ABC' errors). I came up with the > idea to implement the code there because my old request factory > initialisation code was also located there. > > I am wondering where I need to invoke the 'ServiceLayer.create' > related code in order to get this working. > > Thanks a lot for your help! > > -- > You received this message because you are subscribed to the Google Groups > "Google Web Toolkit" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-web-toolkit?hl=en. > > -- David Chandler Developer Programs Engineer, Google Web Toolkit w: http://code.google.com/ b: http://googlewebtoolkit.blogspot.com/ t: @googledevtools -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
