1 /** 2 * Copyright (C) 2001-2004 3 * - France Telecom R&D 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * 19 * Authors: P. Dechamboux, S. Chassande-Barrioz 20 * 21 */ 22 23 package org.objectweb.perseus.jndi; 24 25 import org.objectweb.perseus.jndi.ContextImpl; 26 27 import javax.naming.Context; 28 import javax.naming.InitialContext; 29 import javax.naming.NamingException; 30 31 /** 32 * Naming Manager 33 * this singleton class must exist in each jonas server. 34 */ 35 public class NamingManager { 36 37 private InitialContext ictx = null; 38 39 private static NamingManager unique = null; 40 41 public static NamingManager getInstance() throws NamingException { 42 if (unique == null) 43 unique = new NamingManager(); 44 return unique; 45 } 46 47 /** 48 * Create the naming manager. 49 * useful to create InitialContext because it may throw an exception. 50 */ 51 private NamingManager() throws NamingException { 52 // Create the initial context 53 ictx = new InitialContext(); 54 } 55 56 /** 57 * return the initialContext 58 */ 59 public InitialContext getInitialContext() { 60 return ictx; 61 } 62 63 /** 64 * Create a new Context 65 */ 66 public Context createContext(String namespace) throws NamingException { 67 return new ContextImpl(namespace); 68 } 69 70 } 71