KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > wsif > wsdl > extensions > jms > JMSFaultPropertySerializer


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2002 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "WSIF" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, 2002, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package org.apache.wsif.wsdl.extensions.jms;
59
60 import java.io.Serializable JavaDoc;
61
62 import javax.wsdl.Definition;
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.xml.namespace.QName JavaDoc;
69
70 import org.apache.wsif.logging.Trc;
71 import org.w3c.dom.Element JavaDoc;
72
73 import com.ibm.wsdl.Constants;
74 import com.ibm.wsdl.util.xml.DOMUtils;
75
76 /**
77  * WSDL Jms extension
78  *
79  * @author Mark Whitlock <whitlock@apache.org>
80  */

81 public class JMSFaultPropertySerializer
82     implements ExtensionSerializer, ExtensionDeserializer, Serializable JavaDoc {
83
84     private static final long serialVersionUID = 1L;
85
86     /**
87      * @see ExtensionSerializer#marshall(Class, QName, ExtensibilityElement,
88      * PrintWriter, Definition, ExtensionRegistry)
89      */

90     public void marshall(
91         Class JavaDoc parentType,
92         QName JavaDoc elementType,
93         javax.wsdl.extensions.ExtensibilityElement extension,
94         java.io.PrintWriter JavaDoc pw,
95         javax.wsdl.Definition def,
96         javax.wsdl.extensions.ExtensionRegistry extReg)
97         throws javax.wsdl.WSDLException {
98         Trc.entry(parentType, elementType, extension, pw, def, extReg);
99
100         if (extension == null) {
101             Trc.exit();
102             return;
103         }
104
105         JMSFaultProperty jmsFaultProperty = (JMSFaultProperty) extension;
106         String JavaDoc tagName =
107             DOMUtils.getQualifiedValue(
108                 JMSConstants.NS_URI_JMS,
109                 "faultProperty",
110                 def);
111         pw.print(" <" + tagName);
112
113         /**
114          * handle attributes
115          */

116         if (jmsFaultProperty.getName() != null) {
117             DOMUtils.printAttribute(
118                 JMSConstants.ATTR_NAME,
119                 jmsFaultProperty.getName(),
120                 pw);
121         }
122
123         if (jmsFaultProperty.getType() != null) {
124             DOMUtils.printQualifiedAttribute(
125                 JMSConstants.ATTR_TYPE,
126                 jmsFaultProperty.getType(),
127                 def,
128                 pw);
129         }
130
131         if (jmsFaultProperty.getValue() != null) {
132             DOMUtils.printAttribute(
133                 JMSConstants.ATTR_VALUE,
134                 jmsFaultProperty.getValue(),
135                 pw);
136         }
137
138         if (jmsFaultProperty.getPart() != null) {
139             DOMUtils.printAttribute(
140                 JMSConstants.ATTR_PART,
141                 jmsFaultProperty.getPart(),
142                 pw);
143         }
144
145         Boolean JavaDoc required = extension.getRequired();
146         if (required != null) {
147             DOMUtils.printQualifiedAttribute(
148                 Constants.Q_ATTR_REQUIRED,
149                 required.toString(),
150                 def,
151                 pw);
152         }
153
154         pw.println("/>");
155
156         Trc.exit();
157     }
158
159     /**
160      * Registers the serializer.
161      */

162     public void registerSerializer(ExtensionRegistry registry) {
163         Trc.entry(this, registry);
164
165         // faultProperty
166
registry.registerSerializer(
167             JMSFaultIndicator.class,
168             JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY,
169             this);
170         registry.registerDeserializer(
171             JMSFaultIndicator.class,
172             JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY,
173             this);
174         registry.mapExtensionTypes(
175             JMSFaultIndicator.class,
176             JMSConstants.Q_ELEM_JMS_FAULT_PROPERTY,
177             JMSFaultProperty.class);
178
179         Trc.exit();
180     }
181
182     /**
183      * @see ExtensionDeserializer#unmarshall(Class, QName, Element, Definition,
184      * ExtensionRegistry)
185      */

186     public ExtensibilityElement unmarshall(
187         Class JavaDoc parentType,
188         QName JavaDoc elementType,
189         Element el,
190         Definition def,
191         ExtensionRegistry extReg)
192         throws WSDLException {
193         Trc.entry(this, parentType, elementType, el, def, extReg);
194
195         JMSFaultProperty jmsFaultProperty =
196             (JMSFaultProperty) extReg.createExtension(parentType, elementType);
197
198         String JavaDoc name = DOMUtils.getAttribute(el, JMSConstants.ATTR_NAME);
199         if (name != null) {
200             jmsFaultProperty.setName(name);
201         }
202
203         QName JavaDoc type =
204             DOMUtils.getQualifiedAttributeValue(
205                 el,
206                 JMSConstants.ATTR_TYPE,
207                 JMSConstants.ELEM_FAULT_PROPERTY,
208                 false);
209         if (type != null) {
210             jmsFaultProperty.setType(type);
211         }
212
213         String JavaDoc value = DOMUtils.getAttribute(el, JMSConstants.ATTR_VALUE);
214         if (value != null) {
215             jmsFaultProperty.setValue(value);
216         }
217
218         String JavaDoc part = DOMUtils.getAttribute(el, JMSConstants.ATTR_PART);
219         if (part != null) {
220             jmsFaultProperty.setPart(part);
221         }
222
223         Trc.exit(jmsFaultProperty);
224         return jmsFaultProperty;
225     }
226 }
Popular Tags