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