| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
package org.apache.camel.spring.util; |
| 18 |
|
|
| 19 |
|
import org.aopalliance.intercept.MethodInvocation; |
| 20 |
|
import org.apache.camel.Exchange; |
| 21 |
|
import org.apache.camel.Expression; |
| 22 |
|
|
| 23 |
|
import java.lang.reflect.AccessibleObject; |
| 24 |
|
import java.lang.reflect.InvocationTargetException; |
| 25 |
|
import java.lang.reflect.Method; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
1 |
public class MethodInfo { |
| 31 |
|
private Class type; |
| 32 |
|
private Method method; |
| 33 |
|
private Expression parametersExpression; |
| 34 |
|
|
| 35 |
1 |
public MethodInfo(Class type, Method method, Expression parametersExpression) { |
| 36 |
1 |
this.type = type; |
| 37 |
1 |
this.method = method; |
| 38 |
1 |
this.parametersExpression = parametersExpression; |
| 39 |
1 |
} |
| 40 |
|
|
| 41 |
|
public MethodInvocation createMethodInvocation(final Object pojo, final Exchange messageExchange) { |
| 42 |
1 |
final Object[] arguments = (Object[]) parametersExpression.evaluate(messageExchange); |
| 43 |
1 |
return new MethodInvocation() { |
| 44 |
|
public Method getMethod() { |
| 45 |
0 |
return method; |
| 46 |
|
} |
| 47 |
|
|
| 48 |
|
public Object[] getArguments() { |
| 49 |
0 |
return arguments; |
| 50 |
|
} |
| 51 |
|
|
| 52 |
|
public Object proceed() throws Throwable { |
| 53 |
1 |
return invoke(method, pojo, arguments, messageExchange); |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
public Object getThis() { |
| 57 |
0 |
return pojo; |
| 58 |
|
} |
| 59 |
|
|
| 60 |
1 |
public AccessibleObject getStaticPart() { |
| 61 |
0 |
return method; |
| 62 |
|
} |
| 63 |
|
}; |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
public Class getType() { |
| 67 |
0 |
return type; |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
public Method getMethod() { |
| 71 |
0 |
return method; |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
public Expression getParametersExpression() { |
| 75 |
0 |
return parametersExpression; |
| 76 |
|
} |
| 77 |
|
|
| 78 |
|
protected Object invoke(Method mth, Object pojo, Object[] arguments, Exchange exchange) throws IllegalAccessException, InvocationTargetException { |
| 79 |
1 |
return mth.invoke(pojo, arguments); |
| 80 |
|
} |
| 81 |
|
} |