001: /*
002: * The Apache Software License, Version 1.1
003: *
004: *
005: * Copyright (c) 2002 The Apache Software Foundation. All rights
006: * reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: *
012: * 1. Redistributions of source code must retain the above copyright
013: * notice, this list of conditions and the following disclaimer.
014: *
015: * 2. Redistributions in binary form must reproduce the above copyright
016: * notice, this list of conditions and the following disclaimer in
017: * the documentation and/or other materials provided with the
018: * distribution.
019: *
020: * 3. The end-user documentation included with the redistribution,
021: * if any, must include the following acknowledgment:
022: * "This product includes software developed by the
023: * Apache Software Foundation (http://www.apache.org/)."
024: * Alternately, this acknowledgment may appear in the software itself,
025: * if and wherever such third-party acknowledgments normally appear.
026: *
027: * 4. The names "WSIF" and "Apache Software Foundation" must
028: * not be used to endorse or promote products derived from this
029: * software without prior written permission. For written
030: * permission, please contact apache@apache.org.
031: *
032: * 5. Products derived from this software may not be called "Apache",
033: * nor may "Apache" appear in their name, without prior written
034: * permission of the Apache Software Foundation.
035: *
036: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
037: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
038: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
039: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
040: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
041: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
042: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
043: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
044: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
045: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
046: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
047: * SUCH DAMAGE.
048: * ====================================================================
049: *
050: * This software consists of voluntary contributions made by many
051: * individuals on behalf of the Apache Software Foundation and was
052: * originally based on software copyright (c) 2001, 2002, International
053: * Business Machines, Inc., http://www.apache.org. For more
054: * information on the Apache Software Foundation, please see
055: * <http://www.apache.org/>.
056: */
057:
058: package customfactory.client;
059:
060: import java.util.Enumeration;
061: import java.util.Vector;
062:
063: import javax.wsdl.WSDLException;
064: import javax.wsdl.extensions.ExtensibilityElement;
065: import javax.wsdl.extensions.ExtensionDeserializer;
066: import javax.wsdl.extensions.ExtensionRegistry;
067: import javax.wsdl.extensions.ExtensionSerializer;
068: import javax.wsdl.extensions.UnknownExtensionDeserializer;
069: import javax.wsdl.extensions.UnknownExtensionSerializer;
070: import javax.xml.namespace.QName;
071:
072: import org.apache.wsif.logging.Trc;
073: import org.apache.wsif.wsdl.extensions.ejb.EJBBindingSerializer;
074: import org.apache.wsif.wsdl.extensions.format.FormatBindingSerializer;
075: import org.apache.wsif.wsdl.extensions.java.JavaBindingSerializer;
076:
077: import com.ibm.wsdl.extensions.PopulatedExtensionRegistry;
078:
079: /**
080: * This is utility class that allows to aggregate multiple
081: * extensions registries into one. By default all standard WSDL4J
082: * extensions are made available.
083: *
084: * @author Alekander Slominski
085: * @author Sanjiva Weerawarana
086: * @author Owen Burroughs <owenb@apache.org>
087: * @author Ant Elder <antelder@apache.org>
088: * @author Jeremy Hughes <hughesj@apache.org>
089: * @author Mark Whitlock <whitlock@apache.org>
090: */
091:
092: class MyPrivateCompositeExtensionRegistry extends ExtensionRegistry {
093: private static final long serialVersionUID = 1L;
094: private Vector extRegs = new Vector();
095:
096: MyPrivateCompositeExtensionRegistry() {
097: Trc.entry(this );
098:
099: // Add (de)serializers for Java, EJB and Format extensions to the
100: // PopulatedExetensionRegistry and add the registry to our list
101: 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(Class parentType,
119: Class extensionType, ExtensionSerializer es) {
120: throw new RuntimeException(getClass()
121: + " does not allow to register serializers");
122: }
123:
124: public void registerDeserializer(Class parentType,
125: QName elementType, ExtensionDeserializer ed) {
126: throw new RuntimeException(getClass()
127: + " does not allow to register deserializers");
128: }
129:
130: public ExtensionSerializer querySerializer(
131: Class parentType,
132: QName extensionType)
133: throws WSDLException {
134: Trc.entry(this , parentType, extensionType);
135:
136: ExtensionSerializer ser;
137: Enumeration enum = extRegs.elements();
138: while (enum.hasMoreElements()) {
139: ExtensionRegistry reg = (ExtensionRegistry) enum.nextElement();
140: try {
141: ser = reg.querySerializer(parentType, extensionType);
142: // Check that we're not looking at the default serializer
143: ExtensionSerializer def = reg.getDefaultSerializer();
144: if (ser != null && !(ser.equals(def))) {
145: Trc.exit(ser);
146: return ser;
147: }
148: } catch (WSDLException ex) {
149: Trc.exception(ex);
150: throw ex;
151: }
152: }
153: ser = new UnknownExtensionSerializer();
154: Trc.exit();
155: return ser;
156: }
157:
158: public ExtensionDeserializer queryDeserializer(
159: Class parentType,
160: QName elementType)
161: throws WSDLException {
162: Trc.entry(this , parentType, elementType);
163:
164: ExtensionDeserializer deser;
165: Enumeration enum = extRegs.elements();
166: while (enum.hasMoreElements()) {
167: ExtensionRegistry reg = (ExtensionRegistry) enum.nextElement();
168: try {
169: deser = reg.queryDeserializer(parentType, elementType);
170: // Check that we're not looking at the default deserializer
171: ExtensionDeserializer def = reg.getDefaultDeserializer();
172: if (deser != null && !(deser.equals(def))) {
173: Trc.exit(deser);
174: return deser;
175: }
176: } catch (WSDLException ex) {
177: Trc.exception(ex);
178: throw ex;
179: }
180: }
181: deser = new UnknownExtensionDeserializer();
182: Trc.exit(deser);
183: return deser;
184: }
185:
186: public ExtensibilityElement createExtension(
187: Class parentType,
188: QName elementType)
189: throws WSDLException {
190: Trc.entry(this, parentType, elementType);
191:
192: ExtensibilityElement ee;
193: Enumeration enum = extRegs.elements();
194: while (enum.hasMoreElements()) {
195: ExtensionRegistry reg = (ExtensionRegistry) enum.nextElement();
196: try {
197: ee = reg.createExtension(parentType, elementType);
198: Trc.exit(ee);
199: return ee;
200: } catch (WSDLException ignored) {
201: Trc.ignoredException(ignored);
202: }
203: }
204: ee = super.createExtension(parentType, elementType);
205: Trc.exit(ee);
206: return ee;
207: }
208: }
|