01: /*
02: * ChainBuilder ESB
03: * Visual Enterprise Integration
04: *
05: * Copyright (C) 2007 Bostech Corporation
06: *
07: * This program is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License as published by the
09: * Free Software Foundation; either version 2 of the License, or (at your option)
10: * any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15: * for more details.
16: *
17: * You should have received a copy of the GNU General Public License along with
18: * this program; if not, write to the Free Software Foundation, Inc.,
19: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: *
21: *
22: * $Id: HttpConfigSerializer.java 8702 2007-08-23 21:02:31Z mpreston $
23: */
24: package com.bostechcorp.cbesb.runtime.component.http.wsdl;
25:
26: import java.io.PrintWriter;
27:
28: import javax.jbi.messaging.MessageExchange.Role;
29: import javax.wsdl.Definition;
30: import javax.wsdl.WSDLException;
31: import javax.wsdl.extensions.ExtensibilityElement;
32: import javax.wsdl.extensions.ExtensionRegistry;
33: import javax.wsdl.extensions.ExtensionSerializer;
34: import javax.xml.namespace.QName;
35:
36: import com.ibm.wsdl.util.xml.DOMUtils;
37:
38: public class HttpConfigSerializer implements ExtensionSerializer {
39:
40: /*
41: * (non-Javadoc)
42: *
43: * @see javax.wsdl.extensions.ExtensionSerializer#marshall(java.lang.Class,
44: * javax.xml.namespace.QName,
45: * javax.wsdl.extensions.ExtensibilityElement, java.io.PrintWriter,
46: * javax.wsdl.Definition, javax.wsdl.extensions.ExtensionRegistry)
47: */
48: public void marshall(Class parentType, QName elementType,
49: ExtensibilityElement extension, PrintWriter pw,
50: Definition def, ExtensionRegistry extReg)
51: throws WSDLException {
52:
53: HttpConfig config = (HttpConfig) extension;
54: if (config != null) {
55: String tagName = DOMUtils.getQualifiedValue(
56: HttpConfigExtension.NS_URI_CBHTTP,
57: HttpConfigExtension.ELEM_ENDPOINT, def);
58: pw.print(" <" + tagName);
59: DOMUtils
60: .printAttribute(
61: HttpConfigExtension.ROLE,
62: config.getRole() == Role.CONSUMER ? HttpConfigExtension.ROLE_CONSUMER
63: : HttpConfigExtension.ROLE_PROVIDER,
64: pw);
65: if (config.getDefaultMep() != null) {
66: DOMUtils.printAttribute(
67: HttpConfigExtension.DEFAULT_MEP, config
68: .getDefaultMep().toString(), pw);
69: }
70: if (config.getDefaultOperation() != null) {
71: DOMUtils.printQualifiedAttribute(
72: HttpConfigExtension.DEFAULT_OPERATION, config
73: .getDefaultOperation(), def, pw);
74: }
75:
76: if (config.getWsdlResource() != null) {
77: DOMUtils.printAttribute(
78: HttpConfigExtension.WSDL_RESOURCE, config
79: .getWsdlResource(), pw);
80: }
81:
82: pw.print("/>");
83: }
84: }
85:
86: }
|