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 java.io.Serializable; |
19 | |
import java.lang.reflect.Proxy; |
20 | |
import java.util.List; |
21 | |
|
22 | |
import org.kuali.rice.core.config.ConfigContext; |
23 | |
import org.kuali.rice.core.exception.RiceRuntimeException; |
24 | |
import org.kuali.rice.core.resourceloader.ContextClassLoaderProxy; |
25 | |
import org.kuali.rice.core.util.ClassLoaderUtils; |
26 | |
import org.kuali.rice.ksb.messaging.AsynchronousCallback; |
27 | |
import org.kuali.rice.ksb.messaging.MessageServiceInvoker; |
28 | |
import org.kuali.rice.ksb.messaging.PersistedMessage; |
29 | |
import org.kuali.rice.ksb.messaging.RemotedServiceHolder; |
30 | |
import org.kuali.rice.ksb.util.KSBConstants; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
public class SynchronousServiceCallProxy extends AsynchronousServiceCallProxy { |
41 | |
|
42 | |
private SynchronousServiceCallProxy(List<RemotedServiceHolder> serviceDefs, AsynchronousCallback callback, |
43 | |
Serializable context, String value1, String value2) { |
44 | 0 | super(serviceDefs, callback, context, value1, value2); |
45 | 0 | } |
46 | |
|
47 | |
public static Object createInstance(List<RemotedServiceHolder> serviceDefs, AsynchronousCallback callback, |
48 | |
Serializable context, String value1, String value2) { |
49 | 0 | if (serviceDefs == null || serviceDefs.isEmpty()) { |
50 | 0 | throw new RuntimeException("Cannot create service proxy, no service(s) passed in."); |
51 | |
} |
52 | |
try { |
53 | 0 | return Proxy.newProxyInstance(ClassLoaderUtils.getDefaultClassLoader(), ContextClassLoaderProxy |
54 | |
.getInterfacesToProxyIncludeSpring(serviceDefs.get(0).getService()), new SynchronousServiceCallProxy( |
55 | |
serviceDefs, callback, context, value1, value2)); |
56 | 0 | } catch (Exception e) { |
57 | 0 | throw new RiceRuntimeException(e); |
58 | |
} |
59 | |
} |
60 | |
|
61 | |
@Override |
62 | |
protected void executeMessage(PersistedMessage message) { |
63 | 0 | if (!new Boolean(ConfigContext.getCurrentContextConfig().getProperty(KSBConstants.MESSAGING_OFF))) { |
64 | 0 | new MessageServiceInvoker(message).run(); |
65 | |
} |
66 | 0 | } |
67 | |
} |