1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.geronimo.ews.ws4j2ee.wsutils;
18
19 import org.apache.axis.MessageContext;
20
21 import javax.naming.InitialContext;
22 import javax.naming.NamingException;
23 import javax.rmi.PortableRemoteObject;
24
25 /***
26 * <p>This class provide acsess to the JAX-RPC runtime dynamic information
27 * to the WS4J2ee runtime.</p>
28 *
29 * @author Srinath Perera(hemapani@opensource.lk)
30 */
31 public class JaxRpcRuntime {
32 private static MessageContext MSG_CONTEXT = null;
33
34 public static void setMessageContext(MessageContext msgcontext) {
35 MSG_CONTEXT = msgcontext;
36 }
37
38 public static MessageContext getMessageContext(MessageContext msgcontext) {
39 return MSG_CONTEXT;
40 }
41
42 public static Object getRemoteHome(String jndiname, Class homeclass) throws J2EEFault {
43 try {
44 InitialContext context = new InitialContext();
45 Object objref = context.lookup(jndiname);
46 return PortableRemoteObject.narrow(objref, homeclass);
47 } catch (ClassCastException e) {
48 e.printStackTrace();
49 throw new J2EEFault(e);
50 } catch (NamingException e) {
51 e.printStackTrace();
52 throw new J2EEFault(e);
53 }
54 }
55 }