public static InvocationResponse marshallException(
      Invocation invocation, Throwable exception, Map responseContext) throws Throwable {
    if (invocation.getMetaData(IsLocalInterceptor.IS_LOCAL, IsLocalInterceptor.IS_LOCAL) == null)
      throw exception;

    InvocationResponse response = new InvocationResponse();
    response.setContextInfo(responseContext);

    response.addAttachment(
        IsLocalInterceptor.IS_LOCAL_EXCEPTION, new MarshalledObjectForLocalCalls(exception));

    return response;
  }
 public static InvocationResponse marshallResponse(
     Invocation invocation, Object rtn, Map responseContext) throws java.io.IOException {
   InvocationResponse response;
   // marshall return value
   if (rtn != null
       && invocation.getMetaData(IsLocalInterceptor.IS_LOCAL, IsLocalInterceptor.IS_LOCAL)
           != null) {
     response = new InvocationResponse(new MarshalledObjectForLocalCalls(rtn));
   } else {
     response = new InvocationResponse(rtn);
   }
   response.setContextInfo(responseContext);
   return response;
 }