1 57 58 package org.apache.wsif.base; 59 60 import java.util.Enumeration; 61 import java.util.Vector; 62 63 import javax.wsdl.WSDLException; 64 import javax.wsdl.extensions.ExtensibilityElement; 65 import javax.wsdl.extensions.ExtensionDeserializer; 66 import javax.wsdl.extensions.ExtensionRegistry; 67 import javax.wsdl.extensions.ExtensionSerializer; 68 import javax.wsdl.extensions.UnknownExtensionDeserializer; 69 import javax.wsdl.extensions.UnknownExtensionSerializer; 70 import javax.xml.namespace.QName; 71 72 import org.apache.wsif.logging.Trc; 73 import org.apache.wsif.wsdl.extensions.ejb.EJBBindingSerializer; 74 import org.apache.wsif.wsdl.extensions.format.FormatBindingSerializer; 75 import org.apache.wsif.wsdl.extensions.java.JavaBindingSerializer; 76 77 import com.ibm.wsdl.extensions.PopulatedExtensionRegistry; 78 79 91 92 class PrivateCompositeExtensionRegistry extends ExtensionRegistry { 93 private static final long serialVersionUID = 1L; 94 private Vector extRegs = new Vector(); 95 96 PrivateCompositeExtensionRegistry() { 97 Trc.entry(this); 98 99 PopulatedExtensionRegistry per = new PopulatedExtensionRegistry(); 102 JavaBindingSerializer javaBindingSerializer = new JavaBindingSerializer(); 103 javaBindingSerializer.registerSerializer(per); 104 FormatBindingSerializer formatSerializer = new FormatBindingSerializer(); 105 formatSerializer.registerSerializer(per); 106 EJBBindingSerializer ejbBindingSerializer = new EJBBindingSerializer(); 107 ejbBindingSerializer.registerSerializer(per); 108 extRegs.add(per); 109 Trc.exit(); 110 } 111 112 public void addExtensionRegistry(ExtensionRegistry reg) { 113 Trc.entry(this, reg); 114 extRegs.add(reg); 115 Trc.exit(); 116 } 117 118 public void registerSerializer( 119 Class parentType, 120 Class extensionType, 121 ExtensionSerializer es) { 122 throw new RuntimeException( 123 getClass() + " does not allow to register serializers"); 124 } 125 126 public void registerDeserializer( 127 Class parentType, 128 QName elementType, 129 ExtensionDeserializer ed) { 130 throw new RuntimeException( 131 getClass() + " does not allow to register deserializers"); 132 } 133 134 public ExtensionSerializer querySerializer( 135 Class parentType, 136 QName extensionType) 137 throws WSDLException { 138 Trc.entry(this, parentType, extensionType); 139 140 ExtensionSerializer ser; 141 Enumeration enum = extRegs.elements(); 142 while (enum.hasMoreElements()) { 143 ExtensionRegistry reg = (ExtensionRegistry) enum.nextElement(); 144 try { 145 ser = reg.querySerializer(parentType, extensionType); 146 ExtensionSerializer def = reg.getDefaultSerializer(); 148 if (ser != null && !(ser.equals(def))) { 149 Trc.exit(ser); 150 return ser; 151 } 152 } catch (WSDLException ex) { 153 Trc.exception(ex); 154 throw ex; 155 } 156 } 157 ser = new UnknownExtensionSerializer(); 158 Trc.exit(); 159 return ser; 160 } 161 162 public ExtensionDeserializer queryDeserializer( 163 Class parentType, 164 QName elementType) 165 throws WSDLException { 166 Trc.entry(this, parentType, elementType); 167 168 ExtensionDeserializer deser; 169 Enumeration enum = extRegs.elements(); 170 while (enum.hasMoreElements()) { 171 ExtensionRegistry reg = (ExtensionRegistry) enum.nextElement(); 172 try { 173 deser = reg.queryDeserializer(parentType, elementType); 174 ExtensionDeserializer def = reg.getDefaultDeserializer(); 176 if (deser != null && !(deser.equals(def))) { 177 Trc.exit(deser); 178 return deser; 179 } 180 } catch (WSDLException ex) { 181 Trc.exception(ex); 182 throw ex; 183 } 184 } 185 deser = new UnknownExtensionDeserializer(); 186 Trc.exit(deser); 187 return deser; 188 } 189 190 public ExtensibilityElement createExtension( 191 Class parentType, 192 QName elementType) 193 throws WSDLException { 194 Trc.entry(this, parentType, elementType); 195 196 ExtensibilityElement ee; 197 Enumeration enum = extRegs.elements(); 198 while (enum.hasMoreElements()) { 199 ExtensionRegistry reg = (ExtensionRegistry) enum.nextElement(); 200 try { 201 ee = reg.createExtension(parentType, elementType); 202 Trc.exit(ee); 203 return ee; 204 } catch (WSDLException ignored) { 205 Trc.ignoredException(ignored); 206 } 207 } 208 ee = super.createExtension(parentType, elementType); 209 Trc.exit(ee); 210 return ee; 211 } 212 213 } 214 | Popular Tags |