1 54 55 package org.jboss.axis.handlers; 56 57 import org.jboss.axis.AxisFault; 58 import org.jboss.axis.Handler; 59 import org.jboss.axis.MessageContext; 60 import org.jboss.axis.utils.LockableHashtable; 61 import org.jboss.logging.Logger; 62 import org.w3c.dom.Document ; 63 import org.w3c.dom.Element ; 64 65 import javax.xml.namespace.QName ; 66 import java.util.Enumeration ; 67 import java.util.Hashtable ; 68 import java.util.List ; 69 70 71 80 public abstract class BasicHandler implements Handler 81 { 82 private static Logger log = Logger.getLogger(BasicHandler.class.getName()); 83 84 protected boolean makeLockable = false; 85 protected Hashtable options; 86 protected String name; 87 88 89 93 protected void setOptionsLockable(boolean makeLockable) 94 { 95 this.makeLockable = makeLockable; 96 } 97 98 protected void initHashtable() 99 { 100 if (makeLockable) 101 { 102 options = new LockableHashtable(); 103 } 104 else 105 { 106 options = new Hashtable(); 107 } 108 } 109 110 114 public void init() 115 { 116 } 117 118 public void cleanup() 119 { 120 } 121 122 public boolean canHandleBlock(QName qname) 123 { 124 return false; 125 } 126 127 public void onFault(MessageContext msgContext) 128 { 129 } 130 131 134 public abstract void invoke(MessageContext msgContext) throws AxisFault; 135 136 139 public void setOption(String name, Object value) 140 { 141 if (options == null) initHashtable(); 142 options.put(name, value); 143 } 144 145 155 public boolean setOptionDefault(String name, Object value) 156 { 157 boolean val = (options == null || options.get(name) == null) && value != null; 158 if (val) 159 { 160 setOption(name, value); 161 } 162 return val; 163 } 164 165 168 public Object getOption(String name) 169 { 170 if (options == null) return (null); 171 return (options.get(name)); 172 } 173 174 177 public Hashtable getOptions() 178 { 179 return (options); 180 } 181 182 public void setOptions(Hashtable opts) 183 { 184 options = opts; 185 } 186 187 190 public void setName(String name) 191 { 192 this.name = name; 193 } 194 195 198 public String getName() 199 { 200 return name; 201 } 202 203 public Element getDeploymentData(Document doc) 204 { 205 log.debug("Enter: BasicHandler::getDeploymentData"); 206 207 Element root = doc.createElementNS("", "handler"); 208 209 root.setAttribute("class", this.getClass().getName()); 210 options = this.getOptions(); 211 if (options != null) 212 { 213 Enumeration e = options.keys(); 214 while (e.hasMoreElements()) 215 { 216 String k = (String )e.nextElement(); 217 Object v = options.get(k); 218 Element e1 = doc.createElementNS("", "option"); 219 e1.setAttribute("name", k); 220 e1.setAttribute("value", v.toString()); 221 root.appendChild(e1); 222 } 223 } 224 log.debug("Exit: BasicHandler::getDeploymentData"); 225 return (root); 226 } 227 228 public void generateWSDL(MessageContext msgContext) throws AxisFault 229 { 230 } 231 232 237 public List getUnderstoodHeaders() 238 { 239 return null; 240 } 241 } 242 | Popular Tags |