KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > common > wsdl1 > JbiEndpointSerializer


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17 package org.apache.servicemix.common.wsdl1;
18
19 import java.io.PrintWriter JavaDoc;
20
21 import javax.jbi.messaging.MessageExchange.Role;
22 import javax.wsdl.Definition;
23 import javax.wsdl.WSDLException;
24 import javax.wsdl.extensions.ExtensibilityElement;
25 import javax.wsdl.extensions.ExtensionRegistry;
26 import javax.wsdl.extensions.ExtensionSerializer;
27 import javax.xml.namespace.QName JavaDoc;
28
29 import com.ibm.wsdl.util.xml.DOMUtils;
30
31 public class JbiEndpointSerializer implements ExtensionSerializer {
32
33     public void marshall(Class JavaDoc parentType,
34                          QName JavaDoc elementType,
35                          ExtensibilityElement extension,
36                          PrintWriter JavaDoc pw,
37                          Definition def,
38                          ExtensionRegistry extReg) throws WSDLException {
39
40         JbiEndpoint endpoint = (JbiEndpoint) extension;
41         if (endpoint != null) {
42             String JavaDoc tagName = DOMUtils.getQualifiedValue(JbiExtension.NS_URI_JBI, JbiExtension.ELEM_ENDPOINT, def);
43             pw.print(" <" + tagName);
44             DOMUtils.printAttribute(
45                             JbiExtension.ROLE,
46                             endpoint.getRole() == Role.CONSUMER ? JbiExtension.ROLE_CONSUMER : JbiExtension.ROLE_PROVIDER,
47                             pw);
48             if (endpoint.getDefaultMep() != null) {
49                 DOMUtils.printAttribute(
50                                 JbiExtension.DEFAULT_MEP,
51                                 endpoint.getDefaultMep().toString(),
52                                 pw);
53             }
54             if (endpoint.getDefaultOperation() != null) {
55                 DOMUtils.printQualifiedAttribute(
56                                 JbiExtension.DEFAULT_OPERATION,
57                                 endpoint.getDefaultOperation(),
58                                 def,
59                                 pw);
60             }
61             pw.print("/>");
62         }
63     }
64
65 }
66
Popular Tags