1 26 27 package org.objectweb.jonas_lib.deployment.api; 28 29 import java.util.List ; 30 import java.util.Map ; 31 import java.util.Properties ; 32 import java.util.Vector ; 33 34 import javax.xml.namespace.QName ; 35 36 import org.objectweb.jonas_lib.deployment.xml.Handler; 37 import org.objectweb.jonas_lib.deployment.xml.InitParam; 38 39 40 51 public class HandlerDesc { 52 53 54 private String name; 55 56 57 private String className; 58 59 60 private Class clazz; 61 62 63 private Properties params = new Properties (); 64 65 66 private List headers = new Vector (); 67 68 69 private List roles = new Vector (); 70 71 72 private List portNames = new Vector (); 73 74 83 public HandlerDesc(ClassLoader classLoader, Handler handler) 84 throws DeploymentDescException { 85 86 name = handler.getHandlerName(); 87 88 className = handler.getHandlerClass(); 89 90 try { 91 clazz = classLoader.loadClass(className); 92 } catch (ClassNotFoundException e) { 93 throw new DeploymentDescException("handler class not found", e); 94 } 95 96 List iparams = handler.getInitParamList(); 98 try { 99 for (int i = 0; i < iparams.size(); i++) { 100 InitParam p = (InitParam) iparams.get(i); 102 103 if (p != null) { 104 params.put(p.getParamName(), p.getParamValue()); 105 } 106 } 107 } catch (NullPointerException e) { 108 throw new DeploymentDescException("parameter name missing", e); 109 } 110 111 List shl = handler.getSoapHeaderList(); 113 for (int i = 0; i < shl.size(); i++) { 114 org.objectweb.jonas_lib.deployment.xml.Qname sh = (org.objectweb.jonas_lib.deployment.xml.Qname) shl.get(i); 116 117 if (sh != null) { 118 QName qn = sh.getQName(); 119 headers.add(qn); 120 } 121 } 122 123 List srl = handler.getSoapRoleList(); 125 for (int i = 0; i < srl.size(); i++) { 126 String role = (String ) srl.get(i); 127 if (role != null) { 128 roles.add(role); 129 } 130 } 131 132 List pnl = handler.getPortNameList(); 134 for (int i = 0; i < pnl.size(); i++) { 135 String pn = (String ) pnl.get(i); 136 if (pn != null) { 137 portNames.add(pn); 138 } 139 } 140 } 141 142 147 public String getName() { 148 return name; 149 } 150 151 152 157 public String getHandlerClassName() { 158 return className; 159 } 160 161 166 public Class getHandlerClass() { 167 return clazz; 168 } 169 170 175 public Properties getInitParams() { 176 return params; 177 } 178 179 186 public String getInitParam(String pname) { 187 return params.getProperty(pname); 188 } 189 190 195 public List getSOAPHeaders() { 196 return headers; 197 } 198 199 205 public List getSOAPRoles() { 206 return roles; 207 } 208 209 215 public List getPortNames() { 216 return portNames; 217 } 218 219 226 public boolean equals(Object other) { 227 if (other == null) { 228 return false; 229 } 230 if (!(other instanceof HandlerDesc)) { 231 return false; 232 } 233 HandlerDesc ref = (HandlerDesc) other; 234 if (!name.equals(ref.getName())) { 235 return false; 236 } 237 if (!clazz.getName().equals(ref.getHandlerClass().getName())) { 238 return false; 239 } 240 if (!params.equals(ref.getInitParams())) { 241 return false; 242 } 243 if (!headers.equals(ref.getSOAPHeaders())) { 244 return false; 245 } 246 if (!roles.equals(ref.getSOAPRoles())) { 247 return false; 248 } 249 if (!portNames.equals(ref.getPortNames())) { 250 return false; 251 } 252 return true; 254 } 255 256 259 public String toString() { 260 StringBuffer sb = new StringBuffer (); 261 sb.append("\n" + getClass().getName()); 262 sb.append("\ngetName()=" + getName()); 263 sb.append("\ngetClassname()=" + getHandlerClassName()); 264 sb.append("\ngetSOAPRoles()=" + getSOAPRoles()); 265 sb.append("\ngetSOAPHeaders()=" + getSOAPHeaders()); 266 sb.append("\ngetInitParams()=" + getInitParams()); 267 sb.append("\ngetPortNames()=" + getPortNames()); 268 return sb.toString(); 269 } 270 271 } 272 | Popular Tags |