1 16 17 package org.apache.axis.handlers; 18 19 import org.apache.axis.AxisFault; 20 import org.apache.axis.Handler; 21 import org.apache.axis.MessageContext; 22 import org.apache.axis.components.logger.LogFactory; 23 import org.apache.axis.utils.LockableHashtable; 24 import org.apache.commons.logging.Log; 25 import org.w3c.dom.Document ; 26 import org.w3c.dom.Element ; 27 28 import javax.xml.namespace.QName ; 29 import java.util.Enumeration ; 30 import java.util.Hashtable ; 31 import java.util.List ; 32 33 34 42 public abstract class BasicHandler implements Handler { 43 private static Log log = 44 LogFactory.getLog(BasicHandler.class.getName()); 45 46 protected boolean makeLockable = false; 47 protected Hashtable options; 48 protected String name; 49 50 51 55 protected void setOptionsLockable(boolean makeLockable) { 56 this.makeLockable = makeLockable; 57 } 58 59 protected void initHashtable() 60 { 61 if (makeLockable) { 62 options = new LockableHashtable(); 63 } else { 64 options = new Hashtable(); 65 } 66 } 67 68 73 74 75 public void init() 76 { 77 } 78 79 public void cleanup() 80 { 81 } 82 83 public boolean canHandleBlock(QName qname) 84 { 85 return false; 86 } 87 88 public void onFault(MessageContext msgContext) 89 { 90 } 91 92 95 public void setOption(String name, Object value) { 96 if ( options == null ) initHashtable(); 97 options.put( name, value ); 98 } 99 100 110 public boolean setOptionDefault(String name, Object value) { 111 boolean val = (options == null || options.get(name) == null) && value != null; 112 if (val) { 113 setOption(name, value); 114 } 115 return val; 116 } 117 118 121 public Object getOption(String name) { 122 if ( options == null ) return( null ); 123 return( options.get(name) ); 124 } 125 126 129 public Hashtable getOptions() { 130 return( options ); 131 } 132 133 public void setOptions(Hashtable opts) { 134 options = opts; 135 } 136 137 140 public void setName(String name) 141 { 142 this.name = name; 143 } 144 145 148 public String getName() 149 { 150 return name; 151 } 152 153 public Element getDeploymentData(Document doc) { 154 log.debug("Enter: BasicHandler::getDeploymentData"); 155 156 Element root = doc.createElementNS("", "handler"); 157 158 root.setAttribute( "class", this.getClass().getName() ); 159 options = this.getOptions(); 160 if ( options != null ) { 161 Enumeration e = options.keys(); 162 while ( e.hasMoreElements() ) { 163 String k = (String ) e.nextElement(); 164 Object v = options.get(k); 165 Element e1 = doc.createElementNS("", "option" ); 166 e1.setAttribute( "name", k ); 167 e1.setAttribute( "value", v.toString() ); 168 root.appendChild( e1 ); 169 } 170 } 171 log.debug("Exit: BasicHandler::getDeploymentData"); 172 return( root ); 173 } 174 175 public void generateWSDL(MessageContext msgContext) throws AxisFault 176 { 177 } 178 179 184 public List getUnderstoodHeaders() { 185 return null; 186 } 187 } 188 | Popular Tags |