1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.ksb.messaging.serviceproxies;
17
18 import org.kuali.rice.core.api.config.property.ConfigContext;
19 import org.kuali.rice.core.api.exception.RiceRuntimeException;
20 import org.kuali.rice.core.api.util.ClassLoaderUtils;
21 import org.kuali.rice.core.api.util.ContextClassLoaderProxy;
22 import org.kuali.rice.ksb.api.bus.Endpoint;
23 import org.kuali.rice.ksb.api.messaging.AsynchronousCallback;
24 import org.kuali.rice.ksb.messaging.MessageServiceInvoker;
25 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
26 import org.kuali.rice.ksb.util.KSBConstants;
27
28 import java.io.Serializable;
29 import java.lang.reflect.Proxy;
30 import java.util.List;
31
32
33
34
35
36
37
38
39
40 public class SynchronousServiceCallProxy extends AsynchronousServiceCallProxy {
41
42 private SynchronousServiceCallProxy(List<Endpoint> endpoints, AsynchronousCallback callback,
43 Serializable context, String value1, String value2) {
44 super(endpoints, callback, context, value1, value2);
45 }
46
47 public static Object createInstance(List<Endpoint> endpoints, AsynchronousCallback callback,
48 Serializable context, String value1, String value2) {
49 if (endpoints == null || endpoints.isEmpty()) {
50 throw new RuntimeException("Cannot create service proxy, no service(s) passed in.");
51 }
52 try {
53 return Proxy.newProxyInstance(ClassLoaderUtils.getDefaultClassLoader(), ContextClassLoaderProxy
54 .getInterfacesToProxy(endpoints.get(0).getService()), new SynchronousServiceCallProxy(
55 endpoints, callback, context, value1, value2));
56 } catch (Exception e) {
57 throw new RiceRuntimeException(e);
58 }
59 }
60
61 @Override
62 protected void executeMessage(PersistedMessageBO message) {
63 if (!Boolean.valueOf(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.Config.MESSAGING_OFF))) {
64 new MessageServiceInvoker(message).run();
65 }
66 }
67 }