1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.transport.ejb; |
12 | |
|
13 | |
import org.mule.api.MuleContext; |
14 | |
import org.mule.api.endpoint.ImmutableEndpoint; |
15 | |
import org.mule.transport.rmi.RmiConnector; |
16 | |
import org.mule.util.ClassUtils; |
17 | |
|
18 | |
import java.lang.reflect.Method; |
19 | |
import java.net.UnknownHostException; |
20 | |
import java.rmi.Remote; |
21 | |
import java.rmi.RemoteException; |
22 | |
|
23 | |
import javax.ejb.EJBObject; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public class EjbConnector extends RmiConnector |
30 | |
{ |
31 | |
public static final String EJB = "ejb"; |
32 | |
|
33 | |
|
34 | |
public static final int EJB_SERVICECLASS_INVOCATION_FAILED = 2; |
35 | |
|
36 | |
public EjbConnector(MuleContext context) |
37 | |
{ |
38 | 0 | super(context); |
39 | 0 | } |
40 | |
|
41 | |
public String getProtocol() |
42 | |
{ |
43 | 0 | return EJB; |
44 | |
} |
45 | |
|
46 | |
public Remote getRemoteObject(ImmutableEndpoint endpoint) throws RemoteException, UnknownHostException |
47 | |
{ |
48 | |
EJBObject remoteObj; |
49 | |
|
50 | |
try |
51 | |
{ |
52 | 0 | Object ref = getRemoteRef(endpoint); |
53 | |
|
54 | 0 | Method method = ClassUtils.getMethod(ref.getClass(), "create", null); |
55 | |
|
56 | 0 | remoteObj = (EJBObject)method.invoke(ref); |
57 | |
} |
58 | 0 | catch (Exception e) |
59 | |
{ |
60 | 0 | throw new RemoteException("Remote EJBObject lookup failed for '" + endpoint.getEndpointURI(), e); |
61 | 0 | } |
62 | |
|
63 | 0 | return remoteObj; |
64 | |
} |
65 | |
} |