Coverage Report - org.mule.providers.AbstractJndiConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractJndiConnector
0%
0/38
0%
0/5
1.75
 
 1  
 /*
 2  
  * $Id: AbstractJndiConnector.java 7976 2007-08-21 14:26:13Z 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.providers;
 12  
 
 13  
 import org.mule.config.i18n.CoreMessages;
 14  
 import org.mule.umo.lifecycle.InitialisationException;
 15  
 
 16  
 import java.util.Hashtable;
 17  
 import java.util.Map;
 18  
 
 19  
 import javax.naming.Context;
 20  
 import javax.naming.InitialContext;
 21  
 import javax.naming.NamingException;
 22  
 
 23  
 /**
 24  
  * This class acts as common baseclass for both Rmi & EjbConnector Resolves Jndi root for connector usage
 25  
  * 
 26  
  */
 27  0
 public abstract class AbstractJndiConnector extends AbstractConnector
 28  
 {
 29  
     protected String jndiInitialFactory;
 30  
 
 31  
     protected String jndiUrlPkgPrefixes;
 32  
 
 33  
     protected String jndiProviderUrl;
 34  
 
 35  
     protected Context jndiContext;
 36  
 
 37  0
     protected Map jndiProviderProperties = null;
 38  
 
 39  
     protected void initJndiContext() throws InitialisationException
 40  
     {
 41  0
         if (null == jndiContext)
 42  
         {
 43  0
             Hashtable props = new Hashtable();
 44  
 
 45  0
             if (null != jndiInitialFactory)
 46  
             {
 47  0
                 props.put(Context.INITIAL_CONTEXT_FACTORY, jndiInitialFactory);
 48  
             }
 49  
 
 50  0
             if (jndiProviderUrl != null)
 51  
             {
 52  0
                 props.put(Context.PROVIDER_URL, jndiProviderUrl);
 53  
             }
 54  
 
 55  0
             if (jndiUrlPkgPrefixes != null)
 56  
             {
 57  0
                 props.put(Context.URL_PKG_PREFIXES, jndiUrlPkgPrefixes);
 58  
             }
 59  
 
 60  0
             if (jndiProviderProperties != null)
 61  
             {
 62  0
                 props.putAll(jndiProviderProperties);
 63  
             }
 64  
             try
 65  
             {
 66  0
                 jndiContext = new InitialContext(props);
 67  
             }
 68  0
             catch (NamingException e)
 69  
             {
 70  0
                 throw new InitialisationException(e, this);
 71  0
             }
 72  
         }
 73  0
     }
 74  
 
 75  
     public Context getJndiContext(String jndiProviderUrl) throws InitialisationException
 76  
     {
 77  
         try
 78  
         {
 79  0
             setJndiProviderUrl(jndiProviderUrl);
 80  
 
 81  0
             initJndiContext();
 82  
         }
 83  0
         catch (Exception e)
 84  
         {
 85  0
             throw new InitialisationException(
 86  
                 CoreMessages.failedToCreate("AbstractJndiConnector"), e, this);
 87  0
         }
 88  
 
 89  0
         return jndiContext;
 90  
     }
 91  
 
 92  
     public Context getJndiContext()
 93  
     {
 94  
 
 95  0
         return jndiContext;
 96  
     }
 97  
 
 98  
     public void setJndiContext(Context jndiContext)
 99  
     {
 100  0
         this.jndiContext = jndiContext;
 101  0
     }
 102  
 
 103  
     public void setJndiInitialFactory(String jndiInitialFactory)
 104  
     {
 105  0
         this.jndiInitialFactory = jndiInitialFactory;
 106  0
     }
 107  
 
 108  
     public String getJndiInitialFactory()
 109  
     {
 110  0
         return jndiInitialFactory;
 111  
     }
 112  
 
 113  
     public void setJndiUrlPkgPrefixes(String jndiUrlPkgPrefixes)
 114  
     {
 115  0
         this.jndiUrlPkgPrefixes = jndiUrlPkgPrefixes;
 116  0
     }
 117  
 
 118  
     public String getJndiUrlPkgPrefixes()
 119  
     {
 120  0
         return jndiUrlPkgPrefixes;
 121  
     }
 122  
 
 123  
     public String getJndiProviderUrl()
 124  
     {
 125  0
         return jndiProviderUrl;
 126  
     }
 127  
 
 128  
     public void setJndiProviderUrl(String jndiProviderUrl)
 129  
     {
 130  0
         this.jndiProviderUrl = jndiProviderUrl;
 131  0
     }
 132  
 
 133  
     public Map getJndiProviderProperties()
 134  
     {
 135  0
         return jndiProviderProperties;
 136  
     }
 137  
 
 138  
     public void setJndiProviderProperties(Map jndiProviderProperties)
 139  
     {
 140  0
         this.jndiProviderProperties = jndiProviderProperties;
 141  0
     }
 142  
 }