KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > http > HttpWsdl1Deployer


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.http;
18
19 import javax.wsdl.extensions.ExtensibilityElement;
20 import javax.wsdl.extensions.http.HTTPAddress;
21 import javax.wsdl.extensions.http.HTTPBinding;
22 import javax.wsdl.extensions.soap.SOAPAddress;
23 import javax.wsdl.extensions.soap.SOAPBinding;
24
25 import org.apache.servicemix.common.BaseComponent;
26 import org.apache.servicemix.common.Endpoint;
27 import org.apache.servicemix.common.wsdl1.AbstractWsdl1Deployer;
28 import org.apache.servicemix.common.wsdl1.JbiEndpoint;
29
30 /**
31  * @author gnodet
32  *
33  */

34 public class HttpWsdl1Deployer extends AbstractWsdl1Deployer {
35
36     public HttpWsdl1Deployer(BaseComponent component) {
37         super(component);
38     }
39
40     /* (non-Javadoc)
41      * @see org.servicemix.common.wsdl1.AbstractWsdl1Deployer#createEndpoint(javax.wsdl.extensions.ExtensibilityElement, javax.wsdl.extensions.ExtensibilityElement)
42      */

43     protected Endpoint createEndpoint(ExtensibilityElement portElement,
44                                       ExtensibilityElement bindingElement,
45                                       JbiEndpoint jbiEndpoint) {
46         if (jbiEndpoint == null) {
47             return null;
48         }
49         if (portElement instanceof HTTPAddress && bindingElement instanceof HTTPBinding) {
50             if (!"POST".equals(((HTTPBinding) bindingElement).getVerb())) {
51                 throw new UnsupportedOperationException JavaDoc(((HTTPBinding) bindingElement).getVerb() + " not supported");
52             }
53             HttpEndpoint endpoint = new HttpEndpoint();
54             endpoint.setSoap(false);
55             endpoint.setRole(jbiEndpoint.getRole());
56             endpoint.setDefaultMep(jbiEndpoint.getDefaultMep());
57             endpoint.setDefaultOperation(jbiEndpoint.getDefaultOperation());
58             endpoint.setLocationURI(((HTTPAddress) portElement).getLocationURI());
59             endpoint.setBinding(bindingElement);
60             return endpoint;
61         } else if (portElement instanceof SOAPAddress && bindingElement instanceof SOAPBinding) {
62             HttpEndpoint endpoint = new HttpEndpoint();
63             endpoint.setSoap(true);
64             endpoint.setRole(jbiEndpoint.getRole());
65             endpoint.setDefaultMep(jbiEndpoint.getDefaultMep());
66             endpoint.setDefaultOperation(jbiEndpoint.getDefaultOperation());
67             endpoint.setLocationURI(((SOAPAddress) portElement).getLocationURI());
68             endpoint.setBinding(bindingElement);
69             return endpoint;
70         } else {
71             return null;
72         }
73     }
74
75     /* (non-Javadoc)
76      * @see org.servicemix.common.wsdl1.AbstractWsdl1Deployer#filterPortElement(javax.wsdl.extensions.ExtensibilityElement)
77      */

78     protected boolean filterPortElement(ExtensibilityElement element) {
79         if (element instanceof HTTPAddress) {
80             return true;
81         }
82         if (element instanceof SOAPAddress) {
83             String JavaDoc uri = ((SOAPAddress) element).getLocationURI();
84             if (uri.startsWith("http://") || uri.startsWith("https://")) {
85                 return true;
86             }
87         }
88         return false;
89     }
90
91     /* (non-Javadoc)
92      * @see org.servicemix.common.wsdl1.AbstractWsdl1Deployer#filterBindingElement(javax.wsdl.extensions.ExtensibilityElement)
93      */

94     protected boolean filterBindingElement(ExtensibilityElement element) {
95         return element instanceof HTTPBinding || element instanceof SOAPBinding;
96     }
97
98 }
99
Popular Tags