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