[jboss-dev-forums] [Design of EJB 3.0] - Determine whether an invocation is local or remote

anil.saldhana@jboss.com do-not-reply at jboss.com
Wed Mar 26 23:25:49 EDT 2008


For ejb3 security integration, it is important for me to figure out whether an invocation is remote or local such that I can pick the appropriate security context. For remote invocation, I pick the one from the invocation.

Well, one solution would be if invocation.getsecuritycontext == null, then it is local.  But I am unsure this would be the best.

Looking at the ejb3 codebase and considering various usecases, this is the code that I have copy/pasted to determine whether an invocation is local.


  |  /**
  |     * Check whether an invocation is local or remote
  |     * @param mi method invocation
  |     * @return true - local call
  |     */
  |    public boolean isLocalCall(MethodInvocation mi)
  |    { 
  |       InvokerLocator locator = (InvokerLocator) mi.getMetaData(InvokeRemoteInterceptor.REMOTING, InvokeRemoteInterceptor.INVOKER_LOCATOR);
  |       return locator == null ||
  |           mi.getMetaData(IsLocalInterceptor.IS_LOCAL,IsLocalInterceptor.IS_LOCAL) != null;
  |    }
  | 

Another alternative would be setting a flag on the invocation.

Carlo, can you suggest a better solution?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4139144#4139144

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4139144



More information about the jboss-dev-forums mailing list