Coverage Report - org.naftulin.configmgr.content.JndiRecordImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
JndiRecordImpl
69%
11/16
0%
0/2
0
 
 1  
 package org.naftulin.configmgr.content;
 2  
 
 3  
 import java.util.LinkedList;
 4  
 import java.util.List;
 5  
 
 6  
 import org.naftulin.configmgr.ConfigurationManagerException;
 7  
 import org.naftulin.configmgr.parsers.ConfigEntryParser;
 8  
 import org.naftulin.configmgr.parsers.JndiParserImpl;
 9  
 
 10  
 /**
 11  
  * Represents a jndi entry, with it's key, name-value pairs and parser class.
 12  
  * Intended to mirror master configuration rules for external configuration.
 13  
  * The external configuraton xml is:
 14  
  * <pre>
 15  
  *         &lt;jndi key="the key"
 16  
                 initialContextFactory="optional contenxt factory" 
 17  
                 jndiName="jdni name"                
 18  
  * 
 19  
  * &gt;
 20  
                 &lt;param name="key1" value="value1" /&gt;
 21  
                 .....
 22  
                 &lt;param name="keyn" value="valuen" /&gt;
 23  
         &lt;/jndi&gt;
 24  
  * </pre>
 25  
  * 
 26  
  * @author Henry Henry
 27  
  * @since 1.3
 28  
  */
 29  10
 public class JndiRecordImpl extends AbstractRecordImpl {
 30  
         private String initialContextFactory;
 31  
         private String jndiName;
 32  5
         private final List<NameValuePairImpl> nameValuePairs = new LinkedList<NameValuePairImpl>();
 33  
         private ConfigEntryParser parser;
 34  
 
 35  
         
 36  
         public List<NameValuePairImpl> getNameValuePairs() {
 37  5
                 return nameValuePairs;
 38  
         }
 39  
 
 40  
         /**
 41  
          * Adds a name-value pair as it is read from the master configuration.
 42  
          * @param nv the name value pair.
 43  
          */
 44  
         public void addNameValuePair(final NameValuePairImpl nv) {
 45  5
                 nameValuePairs.add(nv);
 46  5
         }
 47  
 
 48  
         public String getInitialContextFactory() {
 49  5
                 return initialContextFactory;
 50  
         }
 51  
 
 52  
         public void setInitialContextFactory(final String initialContextFactory) {
 53  5
                 this.initialContextFactory = initialContextFactory;
 54  5
         }
 55  
 
 56  
         public String getJndiName() {
 57  5
                 return jndiName;
 58  
         }
 59  
 
 60  
         public void setJndiName(final String jndiName) {
 61  5
                 this.jndiName = jndiName;
 62  5
         }
 63  
 
 64  
         
 65  
         public synchronized ConfigEntryParser getParser() throws ConfigurationManagerException {
 66  0
                 if (parser == null) {
 67  0
                         parser = new JndiParserImpl(jndiName, initialContextFactory,  nameValuePairs);
 68  
                 }
 69  0
                 return parser;
 70  
         }
 71  
 
 72  
         
 73  
         
 74  
         /**
 75  
          * Since it is not a file-based cofiguration, we need to overwrite the method.
 76  
          * @return false
 77  
          */
 78  
         public boolean isGetUrlForFile() {
 79  0
                 return false;
 80  
         }
 81  
 
 82  
         public String getFileName() {
 83  0
                 return "jndi name : " + jndiName + " initial Context Factory " + initialContextFactory;                
 84  
         }
 85  
 }