KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > container > JndiContextHelper


1 /*
2  * $Id: JndiContextHelper.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.impl.container;
12
13 import javax.naming.Context JavaDoc;
14 import javax.naming.InitialContext JavaDoc;
15 import javax.naming.NamingException JavaDoc;
16
17 import java.util.Hashtable JavaDoc;
18 import java.util.Map JavaDoc;
19
20 /**
21  * Common code for initialising the JNDI context.
22  *
23  * @author <a HREF="mailto:aperepel@gmail.com">Andrew Perepelytsya</a>
24  */

25 public class JndiContextHelper
26 {
27     /**
28      * Create a new initial context.
29      *
30      * @param environment JNDI properties or <code>null</code>. In the latter case
31      * a default constructor of <code>InitialContext</code> will be
32      * called with standard JNDI lookup properties semantics.
33      * @return jndi context
34      * @throws NamingException if there was a JNDI error
35      */

36     public static Context JavaDoc initialise(final Map JavaDoc environment) throws NamingException JavaDoc
37     {
38         Context JavaDoc context;
39         if (environment != null && environment.size() > 0)
40         {
41             context = new InitialContext JavaDoc(new Hashtable JavaDoc(environment));
42         }
43         else
44         {
45             context = new InitialContext JavaDoc();
46         }
47
48         return context;
49     }
50 }
51
Popular Tags