that doesn't work. I have tried that. If you throw an Exception in
onBeforeRequestDeserialized, the Exception never gets translated into
the GWT protocol as that code is lower down the stack and instead GWT
receives an InvocationException and doesn't know what happened.
overriding processCall is to high up and you get no translation
either.
To do what you are suggested, a new method in RPC called invokeMethod
would need to be created like so
(these two lines from RPC.java invokeAndEncodeResponse)....
Object result = serviceMethod.invoke(target, args);
responsePayload = encodeResponseForSuccess(serviceMethod,
result,
serializationPolicy);
invokeAndEncodeResponse method would call that new method and I could
override that and then GWT would be translating the exception
correctly for me, BUT GWT does not have this. I have submitted this
change years ago but to no avail as I would LOVE to override that
method.....I guess spring is the only way if only I can get some
example code.
On Oct 3, 7:00 am, Lothar Kimmeringer <[EMAIL PROTECTED]> wrote:
> deanhiller schrieb:
>
> > BEFORE methods are even called, I want to chech if there is a User
> > object in the Session(ie. user is logged in). If there is not, the
> > Session probably expired and I want to throw a NotLoggedInException on
> > every one of these methods(but not in the method itself).
>
> By looking into RemoteServiceServlet I see a couple of ways
> that should be possible (I haven't tried, so I might be
> wrong ;-)
>
> /**
> * Override this method to examine the serialized version of the request
> * payload before it is deserialized into objects. The default implementation
> * does nothing and need not be called by subclasses.
> */
> protected void onBeforeRequestDeserialized(String serializedRequest);
>
> Overwriting this method allow you to throw the NotLoggedInException
> for every method that is going to be called.
>
> If you want to throw the execption only for a list of methods
> (e.g. to allow the login without creating a second servlet),
> you might overwrite processCall instead. Here an example of how I
> think it should be possible:
>
> public String processCall(String payload) throws SerializationException{
> try {
> RPCRequest rpcRequest = RPC.decodeRequest(payload, this.getClass(), this);
> if (!rpcRequest.getMethod().getName().equals("checkLogin")){
> if (!isValidSession){
> throw new NotLoggedInException();
> }
> }
> }
> catch(SerializationException se){
> throw se;
> }
> catch(Exception e){}
> return super.processCall(payload);
>
> }
>
> NotLoggedInException must be derived from SerializableException
>
> > I would
> > prefer this is reusable in an abstract class that implements
> > RemoteServiceServlet and any GWT Servlet any team creates here will
> > extend that and inherit this functionality since all the
> > authentication stuff is the same for all our services.
>
> Above should be usable in an abstract way, you can define the
> list of allowed methods by using e.g. annotations or a list
> of strings being set in the init-method of the derived servlets.
>
> The only thing missing is a class implemeting AsyncCallback that
> overwrites onFailure and checks for the NotLoggedInException to
> "redirect" to the login-panel automatically.
>
> Regards, Lothar
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---