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  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.lifecycle.InitialisationException;
 11  
 import org.mule.config.i18n.CoreMessages;
 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  
  * This class acts as common baseclass for both Rmi & EjbConnector Resolves Jndi root for connector usage
 22  
  * 
 23  
  */
 24  
 public abstract class AbstractJndiConnector extends AbstractConnector
 25  
 {
 26  
     protected String jndiInitialFactory;
 27  
 
 28  
     protected String jndiUrlPkgPrefixes;
 29  
 
 30  
     protected String jndiProviderUrl;
 31  
 
 32  
     protected Context jndiContext;
 33  
 
 34  0
     protected Map jndiProviderProperties = null;
 35  
 
 36  
     public AbstractJndiConnector(MuleContext context)
 37  
     {
 38  0
         super(context);
 39  0
     }
 40  
 
 41  
     protected void initJndiContext() throws InitialisationException
 42  
     {
 43  0
         if (null == jndiContext)
 44  
         {
 45  0
             Hashtable props = new Hashtable();
 46  
 
 47  0
             if (null != jndiInitialFactory)
 48  
             {
 49  0
                 props.put(Context.INITIAL_CONTEXT_FACTORY, jndiInitialFactory);
 50  
             }
 51  
 
 52  0
             if (jndiProviderUrl != null)
 53  
             {
 54  0
                 props.put(Context.PROVIDER_URL, jndiProviderUrl);
 55  
             }
 56  
 
 57  0
             if (jndiUrlPkgPrefixes != null)
 58  
             {
 59  0
                 props.put(Context.URL_PKG_PREFIXES, jndiUrlPkgPrefixes);
 60  
             }
 61  
 
 62  0
             if (jndiProviderProperties != null)
 63  
             {
 64  0
                 props.putAll(jndiProviderProperties);
 65  
             }
 66  
             try
 67  
             {
 68  0
                 jndiContext = new InitialContext(props);
 69  
             }
 70  0
             catch (NamingException e)
 71  
             {
 72  0
                 throw new InitialisationException(e, this);
 73  0
             }
 74  
         }
 75  0
     }
 76  
 
 77  
     public Context getJndiContext(String jndiProviderUrl) throws InitialisationException
 78  
     {
 79  
         try
 80  
         {
 81  0
             setJndiProviderUrl(jndiProviderUrl);
 82  
 
 83  0
             initJndiContext();
 84  
         }
 85  0
         catch (Exception e)
 86  
         {
 87  0
             throw new InitialisationException(
 88  
                 CoreMessages.failedToCreate("AbstractJndiConnector"), e, this);
 89  0
         }
 90  
 
 91  0
         return jndiContext;
 92  
     }
 93  
 
 94  
     public Context getJndiContext()
 95  
     {
 96  
 
 97  0
         return jndiContext;
 98  
     }
 99  
 
 100  
     public void setJndiContext(Context jndiContext)
 101  
     {
 102  0
         this.jndiContext = jndiContext;
 103  0
     }
 104  
 
 105  
     public void setJndiInitialFactory(String jndiInitialFactory)
 106  
     {
 107  0
         this.jndiInitialFactory = jndiInitialFactory;
 108  0
     }
 109  
 
 110  
     public String getJndiInitialFactory()
 111  
     {
 112  0
         return jndiInitialFactory;
 113  
     }
 114  
 
 115  
     public void setJndiUrlPkgPrefixes(String jndiUrlPkgPrefixes)
 116  
     {
 117  0
         this.jndiUrlPkgPrefixes = jndiUrlPkgPrefixes;
 118  0
     }
 119  
 
 120  
     public String getJndiUrlPkgPrefixes()
 121  
     {
 122  0
         return jndiUrlPkgPrefixes;
 123  
     }
 124  
 
 125  
     public String getJndiProviderUrl()
 126  
     {
 127  0
         return jndiProviderUrl;
 128  
     }
 129  
 
 130  
     public void setJndiProviderUrl(String jndiProviderUrl)
 131  
     {
 132  0
         this.jndiProviderUrl = jndiProviderUrl;
 133  0
     }
 134  
 
 135  
     public Map getJndiProviderProperties()
 136  
     {
 137  0
         return jndiProviderProperties;
 138  
     }
 139  
 
 140  
     public void setJndiProviderProperties(Map jndiProviderProperties)
 141  
     {
 142  0
         this.jndiProviderProperties = jndiProviderProperties;
 143  0
     }
 144  
 }