Tuesday, January 3, 2012

Re: Overriding processCall to intercept RPC calls

yeah i was thinking about doing that but im going to have to call that static method for every rpc method, which I have around 15.  Thanks I will consider changing it to this.

On Tue, Jan 3, 2012 at 2:00 PM, Jens <jens.nehlmeier@gmail.com> wrote:
Instead of this I would just extend RemoteServiceServlet and add a public static method that makes the session available to everyone (just like RequestFactoryServlet does), e.g.

public static HttpSession getThreadLocalSession() {
  return getThreadLocalRequest().getSession();
}

Then in your service method:

public boolean isUserLoggedIn() throws IllegalArgumentException {
  HttpSession session = YourExtendedRemoteServiceServlet.getThreadLocalSession();
  if(session.isNew()) {
    throw new IllegalArgumentException("Logged out");
  }
}


That way you actually see the session check at the correct place and not hidden in your RemoteServiceServlet implementation.

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/7pjmY6KxjVcJ.

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.

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

No comments:

Post a Comment