1 55 package org.jboss.axis.soap; 56 57 import org.jboss.axis.message.DetailImpl; 58 import org.jboss.axis.message.NameImpl; 59 import org.jboss.axis.message.SOAPElementAxisImpl; 60 import org.jboss.axis.utils.ClassUtils; 61 62 import javax.xml.soap.Detail ; 63 import javax.xml.soap.Name ; 64 import javax.xml.soap.SOAPElement ; 65 import javax.xml.soap.SOAPException ; 66 import java.lang.reflect.Constructor ; 67 import java.lang.reflect.InvocationTargetException ; 68 69 80 public class SOAPFactoryImpl extends javax.xml.soap.SOAPFactory 81 { 82 83 private static Class elementClass; 84 private static Class detailClass; 85 private static Class nameClass; 86 87 static 88 { 89 try 90 { 91 String elementClass = System.getProperty(SOAPElement .class.getName(), SOAPElementAxisImpl.class.getName()); 92 SOAPFactoryImpl.elementClass = ClassUtils.forName(elementClass); 93 String detailClass = System.getProperty(Detail .class.getName(), DetailImpl.class.getName()); 94 SOAPFactoryImpl.detailClass = ClassUtils.forName(detailClass); 95 String nameClass = System.getProperty(Name .class.getName(), NameImpl.class.getName()); 96 SOAPFactoryImpl.nameClass = ClassUtils.forName(nameClass); 97 } 98 catch (ClassNotFoundException e) 99 { 100 throw new IllegalArgumentException ("SOAP implementation not found: " + e.getMessage()); 101 } 102 } 103 104 115 public SOAPElement createElement(Name name) throws SOAPException 116 { 117 try 118 { 119 Constructor ctor = elementClass.getConstructor(new Class []{Name .class}); 120 return (SOAPElement )ctor.newInstance(new Object []{name}); 121 } 122 catch (InvocationTargetException e) 123 { 124 Throwable te = e.getTargetException(); 125 if (te instanceof SOAPException ) 126 throw (SOAPException )te; 127 throw new SOAPException (e); 128 } 129 catch (Exception e) 130 { 131 throw new SOAPException (e); 132 } 133 } 134 135 146 public SOAPElement createElement(String localName) throws SOAPException 147 { 148 try 149 { 150 Constructor ctor = elementClass.getConstructor(new Class []{String .class}); 151 return (SOAPElement )ctor.newInstance(new Object []{localName}); 152 } 153 catch (InvocationTargetException e) 154 { 155 156 Throwable te = e.getTargetException(); 157 if (te instanceof SOAPException ) 158 throw (SOAPException )te; 159 160 throw new SOAPException (te); 161 } 162 catch (Exception e) 163 { 164 throw new SOAPException (e); 165 } 166 } 167 168 184 public SOAPElement createElement(String localName, String prefix, String uri) throws SOAPException 185 { 186 try 187 { 188 Constructor ctor = elementClass.getConstructor(new Class []{String .class, String .class, String .class}); 189 return (SOAPElement )ctor.newInstance(new Object []{localName, prefix, uri}); 190 } 191 catch (InvocationTargetException e) 192 { 193 194 Throwable te = e.getTargetException(); 195 if (te instanceof SOAPException ) 196 throw (SOAPException )te; 197 198 throw new SOAPException (e); 199 } 200 catch (Exception e) 201 { 202 throw new SOAPException (e); 203 } 204 } 205 206 public Detail createDetail() throws SOAPException 207 { 208 try 209 { 210 return (Detail )detailClass.newInstance(); 211 } 212 catch (Exception e) 213 { 214 throw new SOAPException (e); 215 } 216 } 217 218 public Name createName(String localName, String prefix, String uri) throws SOAPException 219 { 220 try 221 { 222 Constructor ctor = nameClass.getConstructor(new Class []{String .class, String .class, String .class}); 223 return (Name )ctor.newInstance(new Object []{localName, prefix, uri}); 224 } 225 catch (InvocationTargetException e) 226 { 227 228 Throwable te = e.getTargetException(); 229 if (te instanceof SOAPException ) 230 throw (SOAPException )te; 231 232 throw new SOAPException (e); 233 } 234 catch (Exception e) 235 { 236 throw new SOAPException (e); 237 } 238 } 239 240 public Name createName(String localName) throws SOAPException 241 { 242 try 243 { 244 Constructor ctor = nameClass.getConstructor(new Class []{String .class}); 245 return (Name )ctor.newInstance(new Object []{localName}); 246 } 247 catch (InvocationTargetException e) 248 { 249 250 Throwable te = e.getTargetException(); 251 if (te instanceof SOAPException ) 252 throw (SOAPException )te; 253 254 throw new SOAPException (e); 255 } 256 catch (Exception e) 257 { 258 throw new SOAPException (e); 259 } 260 } 261 } 262 | Popular Tags |