001
014
015 package com.liferay.portal.kernel.messaging.proxy;
016
017 import com.liferay.portal.kernel.spring.aop.InvocationHandlerFactory;
018
019 import java.lang.reflect.InvocationHandler;
020 import java.lang.reflect.Method;
021
022
025 public class MessagingProxyInvocationHandler implements InvocationHandler {
026
027 public static InvocationHandlerFactory getInvocationHandlerFactory() {
028 return _invocationHandlerFactory;
029 }
030
031 public MessagingProxyInvocationHandler(BaseProxyBean baseProxyBean) {
032 _baseProxyBean = baseProxyBean;
033 }
034
035 @Override
036 public Object invoke(Object proxy, Method method, Object[] args)
037 throws Throwable {
038
039 ProxyRequest proxyRequest = new ProxyRequest(method, args);
040
041 if (proxyRequest.isSynchronous() ||
042 ProxyModeThreadLocal.isForceSync()) {
043
044 return _baseProxyBean.synchronousSend(proxyRequest);
045 }
046 else {
047 _baseProxyBean.send(proxyRequest);
048
049 return null;
050 }
051 }
052
053 private static final InvocationHandlerFactory _invocationHandlerFactory =
054 new InvocationHandlerFactory() {
055
056 @Override
057 public InvocationHandler createInvocationHandler(Object obj) {
058 return new MessagingProxyInvocationHandler((BaseProxyBean)obj);
059 }
060
061 };
062
063 private final BaseProxyBean _baseProxyBean;
064
065 }