1
2
3
4
5
6
7
8 package it.imolinfo.jbi4ejb.runtime;
9
10 import it.imolinfo.jbi4ejb.Logger;
11 import it.imolinfo.jbi4ejb.LoggerFactory;
12 import it.imolinfo.jbi4ejb.descriptor.ProviderServiceDescriptor;
13 import it.imolinfo.jbi4ejb.exception.EJBInvokeException;
14 import it.imolinfo.jbi4ejb.jbi.Messages;
15 import it.imolinfo.jbi4ejb.processor.transform.StringSource;
16 import it.imolinfo.jbi4ejb.runtime.ejbproxy.StatelessEJBProxy;
17
18 import java.lang.reflect.InvocationTargetException;
19 import java.lang.reflect.Method;
20
21 import org.apache.commons.lang.builder.ReflectionToStringBuilder;
22 import org.codehaus.xfire.MessageContext;
23 import org.codehaus.xfire.fault.XFireFault;
24 import org.codehaus.xfire.service.invoker.Invoker;
25
26
27
28
29
30
31 public class ProviderServiceInvoker implements Invoker {
32
33
34 private static final Logger LOG
35 = LoggerFactory.getLogger(ProviderServiceInvoker.class);
36 private static final Messages MESSAGES
37 = Messages.getMessages(ProviderServiceInvoker.class);
38
39
40 private ProviderServiceDescriptor serviceDescriptor;
41
42
43
44
45
46
47 public ProviderServiceInvoker(
48 final ProviderServiceDescriptor serviceDescriptor) {
49 this.serviceDescriptor = serviceDescriptor;
50 }
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 public Object invoke(final Method method, final Object[] args,
66 final MessageContext messageContext) throws XFireFault {
67
68 LOG.debug(">>>>> invoke - begin");
69
70 StatelessEJBProxy ejbProxy = serviceDescriptor.getEjbProxy();
71
72 Object result = null;
73
74 try {
75
76 result = ejbProxy.invokeMethod(method, args);
77 if (LOG.isDebugEnabled()) {
78 LOG.debug("Result: " + ReflectionToStringBuilder.toString(result));
79 }
80 } catch (IllegalAccessException e) {
81
82
83
84
85
86 } catch (InvocationTargetException e) {
87
88 String msg = "Error in invoking the method: " + method + " on the remote object: " + ejbProxy.getRemoteInterfaceClassName();
89 LOG.error(e.getMessage());
90 throw new XFireFault(msg, e.getCause(), XFireFault.SOAP11_SERVER);
91
92 } catch (EJBInvokeException ex) {
93
94
95 String msg = "Error in invoking the method: " + method + " on the remote object: " + ejbProxy.getRemoteInterfaceClassName();
96 LOG.error(ex.getMessage());
97 throw new XFireFault(msg, ex.getCause(), XFireFault.SOAP11_SERVER);
98 } finally {
99 LOG.debug(">>>>> invoke - end");
100 }
101 return result;
102 }
103
104 }