1 17 18 package org.apache.james.core; 19 20 import org.apache.avalon.framework.configuration.Configuration; 21 import org.apache.avalon.framework.configuration.ConfigurationException; 22 import org.apache.mailet.MailetConfig; 23 import org.apache.mailet.MailetContext; 24 25 import java.util.Iterator ; 26 27 32 public class MailetConfigImpl implements MailetConfig { 33 34 37 private MailetContext mailetContext; 38 39 42 private String name; 43 44 50 private Configuration configuration; 51 52 55 public MailetConfigImpl() { 56 } 57 58 66 public String getInitParameter(String name) { 67 try { 68 String result = null; 69 70 final Configuration[] values = configuration.getChildren( name ); 71 for ( int i = 0; i < values.length; i++ ) { 72 if (result == null) { 73 result = ""; 74 } else { 75 result += ","; 76 } 77 Configuration conf = values[i]; 78 result += conf.getValue(); 79 } 80 return result; 81 } catch (ConfigurationException ce) { 82 throw new RuntimeException ("Embedded configuration exception was: " + ce.getMessage()); 83 } 84 85 } 86 87 92 public Iterator getInitParameterNames() { 93 return new Iterator () { 94 Configuration[] children; 95 int count = 0; 96 { 97 children = configuration.getChildren(); 98 } 99 100 public boolean hasNext() { 101 return count < children.length; 102 } 103 104 public Object next() { 105 return children[count++].getName(); 106 } 107 108 public void remove() { 109 throw new UnsupportedOperationException ("remove not supported"); 110 } 111 }; 112 } 113 114 121 public String getInitAttribute(String name) { 122 return configuration.getAttribute(name, null); 123 } 124 125 130 public MailetContext getMailetContext() { 131 return mailetContext; 132 } 133 134 139 public void setMailetContext(MailetContext newContext) { 140 mailetContext = newContext; 141 } 142 143 148 public void setConfiguration(Configuration newConfiguration) { 149 configuration = newConfiguration; 150 } 151 152 157 public String getMailetName() { 158 return name; 159 } 160 161 166 public void setMailetName(String newName) { 167 name = newName; 168 } 169 } 170 | Popular Tags |