KickJava   Java API By Example, From Geeks To Geeks.

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


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.net.URI 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.ExtensionDeserializer;
26 import javax.wsdl.extensions.ExtensionRegistry;
27 import javax.xml.namespace.QName JavaDoc;
28
29 import org.w3c.dom.Element JavaDoc;
30
31 import com.ibm.wsdl.util.xml.DOMUtils;
32
33 public class JbiEndpointDeserializer implements ExtensionDeserializer {
34
35     public ExtensibilityElement unmarshall(
36             Class JavaDoc parentType,
37             QName JavaDoc elementType,
38             Element el,
39             Definition def,
40             ExtensionRegistry extReg)
41             throws WSDLException {
42         
43         JbiEndpoint jbiEndpoint = (JbiEndpoint) extReg.createExtension(parentType, elementType);
44
45         String JavaDoc role = DOMUtils.getAttribute(el, JbiExtension.ROLE);
46         if (role == null) {
47             throw new WSDLException(WSDLException.OTHER_ERROR, "Role must be specified");
48         } else if (JbiExtension.ROLE_CONSUMER.equals(role)) {
49             jbiEndpoint.setRole(Role.CONSUMER);
50         } else if (JbiExtension.ROLE_PROVIDER.equals(role)) {
51             jbiEndpoint.setRole(Role.PROVIDER);
52         } else {
53             throw new WSDLException(WSDLException.OTHER_ERROR, "Unrecognized role: " + role);
54         }
55
56         String JavaDoc defaultMep = DOMUtils.getAttribute(el, JbiExtension.DEFAULT_MEP);
57         if (defaultMep == null) {
58             defaultMep = JbiExtension.DEFAULT_MEP_IN_OUT;
59         }
60         if (JbiExtension.DEFAULT_MEP_IN_ONLY.equals(defaultMep) ||
61             JbiExtension.DEFAULT_MEP_ROBUST_IN_ONLY.equals(defaultMep) ||
62             JbiExtension.DEFAULT_MEP_IN_OUT.equals(defaultMep)) {
63             jbiEndpoint.setDefaultMep(URI.create(JbiExtension.WSDL2_NS + defaultMep));
64         }
65         
66         QName JavaDoc defaultOperation = DOMUtils.getQualifiedAttributeValue(el, JbiExtension.DEFAULT_OPERATION, null, false, def);
67         if (defaultOperation != null) {
68             jbiEndpoint.setDefaultOperation(defaultOperation);
69         }
70         
71         return jbiEndpoint;
72     }
73
74 }
75
Popular Tags