View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }