KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > ejb > EjbConnector


1 /*
2  * $Id: EjbConnector.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.ejb;
12
13 import org.mule.providers.rmi.RmiConnector;
14 import org.mule.umo.endpoint.UMOImmutableEndpoint;
15 import org.mule.util.ClassUtils;
16
17 import javax.ejb.EJBObject JavaDoc;
18 import java.lang.reflect.Method JavaDoc;
19 import java.net.UnknownHostException JavaDoc;
20 import java.rmi.Remote JavaDoc;
21 import java.rmi.RemoteException JavaDoc;
22
23 /**
24  * Provides Connection configurstion for EJB endpoints
25  */

26
27 public class EjbConnector extends RmiConnector
28 {
29     // Errorcodes
30
public static final int EJB_SERVICECLASS_INVOCATION_FAILED = 2;
31
32     public String JavaDoc getProtocol()
33     {
34         return "ejb";
35     }
36
37     public Remote JavaDoc getRemoteObject(UMOImmutableEndpoint endpoint) throws RemoteException JavaDoc, UnknownHostException JavaDoc
38     {
39         EJBObject JavaDoc remoteObj;
40
41         try
42         {
43             Object JavaDoc ref = getRemoteRef(endpoint);
44
45             Method JavaDoc method = ClassUtils.getMethod("create", null, ref.getClass());
46
47             remoteObj = (EJBObject JavaDoc)method.invoke(ref, ClassUtils.NO_ARGS);
48         }
49         catch (Exception JavaDoc e)
50         {
51             throw new RemoteException JavaDoc("Remote EJBObject lookup failed for '" + endpoint.getEndpointURI(), e);
52         }
53
54         return remoteObj;
55     }
56 }
57
Popular Tags