1 package org.sapia.ubik.rmi.server; 2 3 import java.lang.reflect.Method ; 4 5 import org.sapia.ubik.net.ServerAddress; 6 import org.sapia.ubik.rmi.server.invocation.CallBackInvokeCommand; 7 import org.sapia.ubik.rmi.server.invocation.InvokeCommand; 8 9 10 21 public class RemoteRefEx extends RemoteRef { 22 static final long serialVersionUID = 1L; 23 24 public RemoteRefEx() { 25 } 26 27 35 public RemoteRefEx(OID oid, ServerAddress serverAddress) { 36 super(oid, serverAddress); 37 } 38 39 42 public Object invoke(Object proxy, Method toCall, Object [] params) 43 throws Throwable { 44 Object toReturn = null; 45 46 if (_callBack && 47 Hub.clientRuntime.isCallback(_serverAddress.getTransportType())) { 48 if (Log.isDebug()) { 49 Log.debug(getClass(), "invoking (callback): " + toCall); 50 } 51 52 if (_pool == null) { 53 super.initPool(false); 54 } 55 56 toReturn = ClientRuntime.invoker.dispatchInvocation(_vmId, _pool, 57 new CallBackInvokeCommand(_oid, toCall.getName(), params, 58 toCall.getParameterTypes(), _serverAddress.getTransportType())); 59 } else { 60 if (Log.isDebug()) { 61 Log.debug(getClass(), "invoking (no callback): " + toCall); 62 } 63 64 if (_pool == null) { 65 super.initPool(false); 66 } 67 68 toReturn = ClientRuntime.invoker.dispatchInvocation(_vmId, _pool, 69 new InvokeCommand(_oid, toCall.getName(), params, 70 toCall.getParameterTypes(), _serverAddress.getTransportType())); 71 } 72 73 if (toReturn == null) { 74 return toReturn; 75 } else if (toReturn instanceof Throwable ) { 76 if (toReturn instanceof ShutdownException) { 77 onShutdown(proxy, toCall, params); 78 } 79 80 Throwable err = (Throwable ) toReturn; 81 err.fillInStackTrace(); 82 throw err; 83 } 84 85 return toReturn; 86 } 87 88 protected Object onShutdown(Object proxy, Method toCall, Object [] params) 89 throws Throwable { 90 throw new ShutdownException(); 91 } 92 } 93 | Popular Tags |