01: /**
02: * JOnAS: Java(TM) Open Application Server
03: * Copyright (C) 1999-2004 Bull S.A.
04: * Contact: jonas-team@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * 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: Utility.java 6072 2005-01-12 14:40:21Z pelletib $
23: * --------------------------------------------------------------------------
24: */package org.objectweb.jonas_ejb.svc;
25:
26: import javax.ejb.spi.HandleDelegate;
27: import javax.naming.InitialContext;
28: import javax.naming.NamingException;
29: import javax.rmi.PortableRemoteObject;
30:
31: import org.omg.CORBA.ORB;
32:
33: /**
34: * Utility class for System Value Classes
35: * @author pelletib
36: */
37: public class Utility {
38:
39: /**
40: * orb instance
41: */
42: private static ORB orb = null;
43:
44: /**
45: * Handledelegate
46: */
47: private static HandleDelegate hdlDel = null;
48:
49: /**
50: * private constructor
51: */
52: private Utility() {
53: }
54:
55: /**
56: * Get the Handle Delegate implementation, registered in java:comp
57: * @return The HandleDelegate object.
58: * @throws NamingException Cannot get the HandleDelegate
59: */
60: public static HandleDelegate getHandleDelegate()
61: throws NamingException {
62: if (hdlDel == null) {
63: InitialContext ictx = new InitialContext();
64: hdlDel = (HandleDelegate) ictx
65: .lookup("java:comp/HandleDelegate");
66: }
67: return hdlDel;
68: }
69:
70: /**
71: * Get the Handle Delegate implementation, registered in java:comp
72: * @return The HandleDelegate object.
73: * @throws NamingException Cannot get the HandleDelegate
74: */
75: public static ORB getORB() throws NamingException {
76: InitialContext ictx = new InitialContext();
77: orb = (ORB) PortableRemoteObject.narrow(ictx
78: .lookup("java:comp/ORB"), ORB.class);
79: return orb;
80: }
81: }
|