FileDocCategorySizeDatePackage
InvokeRemoteInterceptor.javaAPI DocJBoss 4.2.13865Fri Jul 13 21:02:26 BST 2007org.jboss.aspects.remoting

InvokeRemoteInterceptor

public class InvokeRemoteInterceptor extends Object implements org.jboss.aop.advice.Interceptor, Serializable
Checks to see if this object is local in VM
author
Bill Burke
version
$Revision: 59458 $

Fields Summary
private static final Logger
log
private static final long
serialVersionUID
public static final InvokeRemoteInterceptor
singleton
public static final String
REMOTING
public static final String
INVOKER_LOCATOR
public static final String
SUBSYSTEM
Constructors Summary
Methods Summary
public java.lang.StringgetName()


       return "InvokeRemoteInterceptor"; 
public java.lang.Objectinvoke(org.jboss.aop.joinpoint.Invocation invocation)

      InvokerLocator locator = (InvokerLocator)invocation.getMetaData(REMOTING, INVOKER_LOCATOR);
      if (locator == null)
      {
         throw new RuntimeException("No InvokerLocator supplied.  Can't invoke remotely!");
      }
      String subsystem = (String)invocation.getMetaData(REMOTING, SUBSYSTEM);
      if (subsystem == null) subsystem = "AOP";
      Client client = new Client(locator, subsystem);
      
      try 
      {
         client.connect();
         org.jboss.aop.joinpoint.InvocationResponse response = (org.jboss.aop.joinpoint.InvocationResponse)client.invoke(invocation, null);
         invocation.setResponseContextInfo(response.getContextInfo());
         return response.getResponse();
      }
      catch (Exception e)
      {
         StackTraceElement[] serverStackTrace;
         if (e.getCause() != null)
            serverStackTrace = e.getCause().getStackTrace();
         else
            serverStackTrace = e.getStackTrace();
         
         Exception clientException = new Exception();
         StackTraceElement[] clientStackTrace = clientException.getStackTrace();
         StackTraceElement[] completeStackTrace = new StackTraceElement[serverStackTrace.length + clientStackTrace.length];
         System.arraycopy(serverStackTrace, 0, completeStackTrace, 0, serverStackTrace.length);
         System.arraycopy(clientStackTrace, 0, completeStackTrace, serverStackTrace.length, clientStackTrace.length);
         
         if (e.getCause() != null)
            e.getCause().setStackTrace(completeStackTrace);
         else
            e.setStackTrace(completeStackTrace);
         
         throw e;
      }
      finally
      {
         client.disconnect();
      }
   
java.lang.ObjectreadResolve()

      return singleton;