KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > security > iiop > ORBHelper


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2004 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: ORBHelper.java,v 1.1 2004/12/13 16:27:30 benoitf Exp $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.jonas.security.iiop;
26
27 import javax.naming.Context JavaDoc;
28 import javax.naming.InitialContext JavaDoc;
29 import javax.naming.NamingException JavaDoc;
30 import javax.rmi.PortableRemoteObject JavaDoc;
31
32 import org.omg.CORBA.ORB JavaDoc;
33
34
35 /**
36  * Gets the ORB (java:comp/ORB)
37  * @author Florent Benoit
38  */

39 public class ORBHelper {
40
41     /**
42      * ORB to use
43      */

44     private static ORB JavaDoc orb = null;
45
46
47     /**
48      * Utility class. No constructor.
49      */

50     private ORBHelper() {
51
52     }
53
54     /**
55      * @return an ORB
56      * @throws Csiv2InterceptorException if the ORB cannot be retrieved
57      */

58     public static ORB JavaDoc getOrb() throws Csiv2InterceptorException {
59         if (orb != null) {
60             return orb;
61         }
62
63         // Get orb for building Any
64
Context JavaDoc ictx = null;
65         try {
66             ictx = new InitialContext JavaDoc();
67         } catch (NamingException JavaDoc ne) {
68             throw new Csiv2InterceptorException("Cannot instatiate InitialContext", ne);
69         }
70
71         try {
72             orb = (ORB JavaDoc) PortableRemoteObject.narrow(ictx.lookup("java:comp/ORB"), ORB JavaDoc.class);
73         } catch (NamingException JavaDoc ne) {
74             throw new Csiv2InterceptorException("Cannot lookup java:comp/ORB", ne);
75         }
76         return orb;
77     }
78
79
80 }
81
Popular Tags