001: package org.objectweb.celtix.tools.utils;
002:
003: import javax.wsdl.Binding;
004: import javax.wsdl.BindingInput;
005: import javax.wsdl.BindingOperation;
006: import javax.wsdl.BindingOutput;
007: import javax.wsdl.Definition;
008: import javax.wsdl.Operation;
009: import javax.wsdl.Port;
010: import javax.wsdl.PortType;
011: import javax.wsdl.extensions.ExtensionRegistry;
012: import javax.wsdl.factory.WSDLFactory;
013: import javax.wsdl.xml.WSDLReader;
014:
015: import org.objectweb.celtix.tools.common.ToolConstants;
016: import org.objectweb.celtix.tools.extensions.jaxws.JAXWSBinding;
017: import org.objectweb.celtix.tools.extensions.jaxws.JAXWSBindingDeserializer;
018: import org.objectweb.celtix.tools.extensions.jaxws.JAXWSBindingSerializer;
019: import org.objectweb.celtix.tools.extensions.jms.JMSAddress;
020: import org.objectweb.celtix.tools.extensions.jms.JMSAddressSerializer;
021: import org.objectweb.celtix.tools.extensions.xmlformat.XMLFormat;
022: import org.objectweb.celtix.tools.extensions.xmlformat.XMLFormatBinding;
023: import org.objectweb.celtix.tools.extensions.xmlformat.XMLFormatBindingSerializer;
024: import org.objectweb.celtix.tools.extensions.xmlformat.XMLFormatSerializer;
025: import org.objectweb.celtix.tools.extensions.xmlformat.XMLHttpAddress;
026: import org.objectweb.celtix.tools.extensions.xmlformat.XMLHttpSerializer;
027:
028: public class WSDLExtensionRegister {
029:
030: private WSDLFactory wsdlFactory;
031: private WSDLReader wsdlreader;
032:
033: public WSDLExtensionRegister(WSDLFactory factory, WSDLReader reader) {
034: wsdlFactory = factory;
035: wsdlreader = reader;
036: }
037:
038: public void registerExtenstions() {
039: ExtensionRegistry registry = wsdlreader.getExtensionRegistry();
040: if (registry == null) {
041: registry = wsdlFactory.newPopulatedExtensionRegistry();
042: }
043: registerJAXWSBinding(registry, Definition.class);
044: registerJAXWSBinding(registry, PortType.class);
045: registerJAXWSBinding(registry, Operation.class);
046:
047: registerJAXWSBinding(registry, Binding.class);
048: registerJAXWSBinding(registry, BindingOperation.class);
049:
050: registerJMSAddress(registry, Port.class);
051:
052: registerXMLFormat(registry, BindingInput.class);
053: registerXMLFormat(registry, BindingOutput.class);
054: registerXMLFormatBinding(registry, Binding.class);
055: registerXMLHttpAddress(registry, Port.class);
056:
057: wsdlreader.setExtensionRegistry(registry);
058: }
059:
060: private void registerXMLFormat(ExtensionRegistry registry, Class clz) {
061: registry.registerSerializer(clz, ToolConstants.XML_FORMAT,
062: new XMLFormatSerializer());
063:
064: registry.registerDeserializer(clz, ToolConstants.XML_FORMAT,
065: new XMLFormatSerializer());
066: registry.mapExtensionTypes(clz, ToolConstants.XML_FORMAT,
067: XMLFormat.class);
068: }
069:
070: private void registerXMLFormatBinding(ExtensionRegistry registry,
071: Class clz) {
072: registry.registerSerializer(clz,
073: ToolConstants.XML_BINDING_FORMAT,
074: new XMLFormatBindingSerializer());
075:
076: registry.registerDeserializer(clz,
077: ToolConstants.XML_BINDING_FORMAT,
078: new XMLFormatBindingSerializer());
079: registry.mapExtensionTypes(clz,
080: ToolConstants.XML_BINDING_FORMAT,
081: XMLFormatBinding.class);
082: }
083:
084: private void registerXMLHttpAddress(ExtensionRegistry registry,
085: Class clz) {
086: registry
087: .registerSerializer(clz,
088: ToolConstants.XML_HTTP_ADDRESS,
089: new XMLHttpSerializer());
090:
091: registry
092: .registerDeserializer(clz,
093: ToolConstants.XML_HTTP_ADDRESS,
094: new XMLHttpSerializer());
095: registry.mapExtensionTypes(clz, ToolConstants.XML_HTTP_ADDRESS,
096: XMLHttpAddress.class);
097: }
098:
099: private void registerJMSAddress(ExtensionRegistry registry,
100: Class clz) {
101: registry.registerSerializer(clz, ToolConstants.JMS_ADDRESS,
102: new JMSAddressSerializer());
103:
104: registry.registerDeserializer(clz, ToolConstants.JMS_ADDRESS,
105: new JMSAddressSerializer());
106: registry.mapExtensionTypes(clz, ToolConstants.JMS_ADDRESS,
107: JMSAddress.class);
108: }
109:
110: private void registerJAXWSBinding(ExtensionRegistry registry,
111: Class clz) {
112: registry.registerSerializer(clz, ToolConstants.JAXWS_BINDINGS,
113: new JAXWSBindingSerializer());
114:
115: registry.registerDeserializer(clz,
116: ToolConstants.JAXWS_BINDINGS,
117: new JAXWSBindingDeserializer());
118: registry.mapExtensionTypes(clz, ToolConstants.JAXWS_BINDINGS,
119: JAXWSBinding.class);
120: }
121:
122: }
|