Coverage Report - org.mule.impl.container.JndiContextHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
JndiContextHelper
67%
4/6
100%
4/4
1.5
 
 1  
 /*
 2  
  * $Id: JndiContextHelper.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 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 CPAL v1.0
 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 java.util.Hashtable;
 14  
 import java.util.Map;
 15  
 
 16  
 import javax.naming.Context;
 17  
 import javax.naming.InitialContext;
 18  
 import javax.naming.NamingException;
 19  
 
 20  
 /**
 21  
  * Common code for initialising the JNDI context.
 22  
  */
 23  
 public final class JndiContextHelper
 24  
 {
 25  
     /** Do not instanciate. */
 26  
     private JndiContextHelper ()
 27  0
     {
 28  
         // no-op
 29  0
     }
 30  
 
 31  
     /**
 32  
      * Create a new initial context.
 33  
      * 
 34  
      * @param environment JNDI properties or <code>null</code>. In the latter case
 35  
      *            a default constructor of <code>InitialContext</code> will be
 36  
      *            called with standard JNDI lookup properties semantics.
 37  
      * @return jndi context
 38  
      * @throws NamingException if there was a JNDI error
 39  
      */
 40  
     public static Context initialise(final Map environment) throws NamingException
 41  
     {
 42  
         Context context;
 43  10
         if (environment != null && environment.size() > 0)
 44  
         {
 45  6
             context = new InitialContext(new Hashtable(environment));
 46  
         }
 47  
         else
 48  
         {
 49  4
             context = new InitialContext();
 50  
         }
 51  
 
 52  10
         return context;
 53  
     }
 54  
 }