KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > component > common > wsdl > JbiEndpointDeserializer


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

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