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;
 }
  public Object invoke(InvocationRequest invocation) throws Throwable {
    // Create a security context for the invocation
    establishSecurityContext(invocation);

    InvocationResponse value = (InvocationResponse) super.invoke(invocation);
    if (value.getResponse() instanceof ManagementView) {
      // Replace the ManagementView with its proxy
      value.setResponse(mgtViewProxy);
    }
    if (value.getResponse() instanceof DeploymentManager) {
      // Replace the DeploymentManager with its proxy
      value.setResponse(deployMgrProxy);
    }

    return value;
  }