View Javadoc

1   /*
2    * $Id: PartnerLinkTypeExtensionRegistry.java,v 1.1 2004/12/15 14:18:21 patforna Exp $
3    *
4    * Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
5    * Berne University of Applied Sciences
6    * School of Engineering and Information Technology
7    * All rights reserved.
8    */
9   package bexee.wsdl.extensions.partnerlinktype;
10  
11  import java.util.Set;
12  
13  import javax.wsdl.Definition;
14  import javax.wsdl.WSDLException;
15  import javax.wsdl.extensions.ExtensibilityElement;
16  import javax.wsdl.extensions.ExtensionDeserializer;
17  import javax.wsdl.extensions.ExtensionRegistry;
18  import javax.wsdl.extensions.ExtensionSerializer;
19  import javax.wsdl.extensions.UnknownExtensionDeserializer;
20  import javax.wsdl.extensions.UnknownExtensionSerializer;
21  import javax.wsdl.factory.WSDLFactory;
22  import javax.xml.namespace.QName;
23  
24  import bexee.wsdl.extensions.partnerlinktype.impl.PartnerLinkTypeImpl;
25  
26  /***
27   * This is merely a helper class which pre-registers a deserializer and a
28   * serializer for the PartnerLinkType elements (BPEL extension to WSDL).
29   * 
30   * @author Pawel Kowalski
31   * @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:21 $
32   */
33  public class PartnerLinkTypeExtensionRegistry extends ExtensionRegistry {
34  
35      private ExtensionRegistry registry;
36  
37      private boolean delegateInitialized = false;
38  
39      /***
40       * Create new <code>PartnerLinkTypeExtensionRegistry</code> instance.
41       * 
42       * @throws WSDLException
43       */
44      public PartnerLinkTypeExtensionRegistry() throws WSDLException {
45  
46          WSDLFactory factory = WSDLFactory.newInstance();
47          registry = factory.newPopulatedExtensionRegistry();
48  
49          delegateInitialized = true;
50          setDefaultSerializer(new UnknownExtensionSerializer());
51          setDefaultDeserializer(new UnknownExtensionDeserializer());
52  
53          // Create a serializer and deserializer.
54          PartnerLinkTypeDeserializer pLinkTypeSerDeser = new PartnerLinkTypeDeserializer();
55  
56          // Register the deserializer.
57          registerDeserializer(Definition.class,
58                  PartnerLinkTypeConstants.PLINK_TYPE_QNAME, pLinkTypeSerDeser);
59  
60          // Register the serializer.
61          //
62          registerSerializer(Definition.class,
63                  PartnerLinkTypeConstants.PLINK_TYPE_QNAME, pLinkTypeSerDeser);
64  
65          // Map the implementation class to the extension type.
66          //
67          mapExtensionTypes(Definition.class,
68                  PartnerLinkTypeConstants.PLINK_TYPE_QNAME,
69                  PartnerLinkTypeImpl.class);
70  
71      }
72  
73      /*
74       * (non-Javadoc)
75       * 
76       * @see javax.wsdl.extensions.ExtensionRegistry#createExtension(java.lang.Class,
77       *      javax.xml.namespace.QName)
78       */
79      public ExtensibilityElement createExtension(Class arg0, QName arg1)
80              throws WSDLException {
81          return registry.createExtension(arg0, arg1);
82      }
83  
84      /*
85       * (non-Javadoc)
86       * 
87       * @see java.lang.Object#equals(java.lang.Object)
88       */
89      public boolean equals(Object arg0) {
90          return registry.equals(arg0);
91      }
92  
93      /*
94       * (non-Javadoc)
95       * 
96       * @see javax.wsdl.extensions.ExtensionRegistry#getAllowableExtensions(java.lang.Class)
97       */
98      public Set getAllowableExtensions(Class arg0) {
99          return registry.getAllowableExtensions(arg0);
100     }
101 
102     /*
103      * (non-Javadoc)
104      * 
105      * @see javax.wsdl.extensions.ExtensionRegistry#getDefaultDeserializer()
106      */
107     public ExtensionDeserializer getDefaultDeserializer() {
108         return registry.getDefaultDeserializer();
109     }
110 
111     /*
112      * (non-Javadoc)
113      * 
114      * @see javax.wsdl.extensions.ExtensionRegistry#getDefaultSerializer()
115      */
116     public ExtensionSerializer getDefaultSerializer() {
117         return registry.getDefaultSerializer();
118     }
119 
120     /*
121      * (non-Javadoc)
122      * 
123      * @see java.lang.Object#hashCode()
124      */
125     public int hashCode() {
126         return registry.hashCode();
127     }
128 
129     /*
130      * (non-Javadoc)
131      * 
132      * @see javax.wsdl.extensions.ExtensionRegistry#mapExtensionTypes(java.lang.Class,
133      *      javax.xml.namespace.QName, java.lang.Class)
134      */
135     public void mapExtensionTypes(Class arg0, QName arg1, Class arg2) {
136         registry.mapExtensionTypes(arg0, arg1, arg2);
137     }
138 
139     /*
140      * (non-Javadoc)
141      * 
142      * @see javax.wsdl.extensions.ExtensionRegistry#queryDeserializer(java.lang.Class,
143      *      javax.xml.namespace.QName)
144      */
145     public ExtensionDeserializer queryDeserializer(Class arg0, QName arg1)
146             throws WSDLException {
147         return registry.queryDeserializer(arg0, arg1);
148     }
149 
150     /*
151      * (non-Javadoc)
152      * 
153      * @see javax.wsdl.extensions.ExtensionRegistry#querySerializer(java.lang.Class,
154      *      javax.xml.namespace.QName)
155      */
156     public ExtensionSerializer querySerializer(Class arg0, QName arg1)
157             throws WSDLException {
158         return registry.querySerializer(arg0, arg1);
159     }
160 
161     /*
162      * (non-Javadoc)
163      * 
164      * @see javax.wsdl.extensions.ExtensionRegistry#registerDeserializer(java.lang.Class,
165      *      javax.xml.namespace.QName,
166      *      javax.wsdl.extensions.ExtensionDeserializer)
167      */
168     public void registerDeserializer(Class arg0, QName arg1,
169             ExtensionDeserializer arg2) {
170         registry.registerDeserializer(arg0, arg1, arg2);
171     }
172 
173     /*
174      * (non-Javadoc)
175      * 
176      * @see javax.wsdl.extensions.ExtensionRegistry#registerSerializer(java.lang.Class,
177      *      javax.xml.namespace.QName,
178      *      javax.wsdl.extensions.ExtensionSerializer)
179      */
180     public void registerSerializer(Class arg0, QName arg1,
181             ExtensionSerializer arg2) {
182         registry.registerSerializer(arg0, arg1, arg2);
183     }
184 
185     /*
186      * (non-Javadoc)
187      * 
188      * @see javax.wsdl.extensions.ExtensionRegistry#setDefaultDeserializer(javax.wsdl.extensions.ExtensionDeserializer)
189      */
190     public void setDefaultDeserializer(ExtensionDeserializer extDeserializer) {
191 
192         // this is necessary because the superclass calls this method
193         // but it and doesn't know that the registry is a delegate and is thus
194         // not yet initialized
195         //
196         if (delegateInitialized) {
197             registry.setDefaultDeserializer(extDeserializer);
198         }
199     }
200 
201     /*
202      * (non-Javadoc)
203      * 
204      * @see javax.wsdl.extensions.ExtensionRegistry#setDefaultSerializer(javax.wsdl.extensions.ExtensionSerializer)
205      */
206     public void setDefaultSerializer(ExtensionSerializer extSerializer) {
207 
208         // this is necessary because the superclass calls this method
209         // but it and doesn't know that the registry is a delegate and is thus
210         // not yet initialized
211         //
212         if (delegateInitialized) {
213             registry.setDefaultSerializer(extSerializer);
214         }
215     }
216 
217     /*
218      * (non-Javadoc)
219      * 
220      * @see java.lang.Object#toString()
221      */
222     public String toString() {
223         return registry.toString();
224     }
225 }