1
14
15 package com.liferay.portal.kernel.messaging.proxy;
16
17 import com.liferay.portal.kernel.util.MethodHandler;
18
19 import java.io.Serializable;
20
21 import java.lang.reflect.InvocationTargetException;
22 import java.lang.reflect.Method;
23
24
31 public class ProxyRequest implements Serializable {
32
33 public ProxyRequest(Method method, Object[] arguments) throws Exception {
34 _methodHandler = new MethodHandler(method, arguments);
35
36 _hasReturnValue = false;
37
38 if (method.getReturnType() != Void.TYPE) {
39 _hasReturnValue = true;
40 }
41
42 MessagingProxy messagingProxy = method.getAnnotation(
43 MessagingProxy.class);
44
45 if (messagingProxy == null) {
46 messagingProxy = method.getDeclaringClass().getAnnotation(
47 MessagingProxy.class);
48 }
49
50 if ((messagingProxy != null) &&
51 (messagingProxy.mode().equals(ProxyMode.SYNC))) {
52
53 _synchronous = true;
54 }
55 }
56
57 public Object execute(Object object) throws Exception {
58 try {
59 return _methodHandler.invoke(object);
60 }
61 catch (InvocationTargetException ite) {
62 Throwable t = ite.getCause();
63
64 if (t instanceof Exception) {
65 throw (Exception)t;
66 }
67 else {
68 throw new Exception(t);
69 }
70 }
71 }
72
73 public Object[] getArguments() {
74 return _methodHandler.getArguments();
75 }
76
77 public boolean hasReturnValue() {
78 return _hasReturnValue;
79 }
80
81 public boolean isSynchronous() {
82 return _synchronous;
83 }
84
85 private boolean _hasReturnValue;
86 private MethodHandler _methodHandler;
87 private boolean _synchronous;
88
89 }