1 16 17 package org.springframework.remoting.support; 18 19 import java.lang.reflect.InvocationTargetException ; 20 21 31 public abstract class RemoteInvocationBasedExporter extends RemoteExporter { 32 33 private RemoteInvocationExecutor remoteInvocationExecutor = new DefaultRemoteInvocationExecutor(); 34 35 36 42 public void setRemoteInvocationExecutor(RemoteInvocationExecutor remoteInvocationExecutor) { 43 this.remoteInvocationExecutor = remoteInvocationExecutor; 44 } 45 46 49 public RemoteInvocationExecutor getRemoteInvocationExecutor() { 50 return remoteInvocationExecutor; 51 } 52 53 54 69 protected Object invoke(RemoteInvocation invocation, Object targetObject) 70 throws NoSuchMethodException , IllegalAccessException , InvocationTargetException { 71 72 if (logger.isDebugEnabled()) { 73 logger.debug("Applying " + invocation); 74 } 75 try { 76 return getRemoteInvocationExecutor().invoke(invocation, targetObject); 77 } 78 catch (NoSuchMethodException ex) { 79 if (logger.isDebugEnabled()) { 80 logger.warn("Could not find target method for " + invocation, ex); 81 } 82 throw ex; 83 } 84 catch (IllegalAccessException ex) { 85 if (logger.isDebugEnabled()) { 86 logger.warn("Could not access target method for " + invocation, ex); 87 } 88 throw ex; 89 } 90 catch (InvocationTargetException ex) { 91 if (logger.isDebugEnabled()) { 92 logger.debug("Target method failed for " + invocation, ex.getTargetException()); 93 } 94 throw ex; 95 } 96 } 97 98 110 protected RemoteInvocationResult invokeAndCreateResult(RemoteInvocation invocation, Object targetObject) { 111 try { 112 Object value = invoke(invocation, targetObject); 113 return new RemoteInvocationResult(value); 114 } 115 catch (Throwable ex) { 116 return new RemoteInvocationResult(ex); 117 } 118 } 119 120 } 121 | Popular Tags |