KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > axis > builder > OperationDescBuilder


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.geronimo.axis.builder;
18
19 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21 import javax.wsdl.BindingOperation;
22 import javax.wsdl.Operation;
23 import javax.wsdl.Message;
24 import javax.wsdl.BindingInput;
25 import javax.wsdl.extensions.soap.SOAPOperation;
26 import javax.wsdl.extensions.soap.SOAPBody;
27 import javax.wsdl.extensions.ExtensibilityElement;
28 import javax.xml.namespace.QName JavaDoc;
29
30 import org.apache.geronimo.axis.client.OperationInfo;
31 import org.apache.geronimo.common.DeploymentException;
32 import org.apache.geronimo.webservices.builder.SchemaInfoBuilder;
33 import org.apache.axis.soap.SOAPConstants;
34 import org.apache.axis.description.OperationDesc;
35
36 public abstract class OperationDescBuilder {
37     protected final OperationDesc operationDesc;
38     protected final BindingOperation bindingOperation;
39     protected final Operation operation;
40     protected final String JavaDoc operationName;
41     protected final Message input;
42     protected final Message output;
43     protected final SOAPOperation soapOperation;
44     protected boolean built;
45
46     public OperationDescBuilder(BindingOperation bindingOperation) throws DeploymentException {
47         this.bindingOperation = bindingOperation;
48         this.operation = bindingOperation.getOperation();
49         this.soapOperation = (SOAPOperation) SchemaInfoBuilder.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
50
51         operationDesc = new OperationDesc();
52         output = operation.getOutput() == null ? null : operation.getOutput().getMessage();
53         operationName = operation.getName();
54         input = operation.getInput().getMessage();
55     }
56
57     public abstract OperationInfo buildOperationInfo(SOAPConstants soapVersion) throws DeploymentException;
58
59     public abstract OperationDesc buildOperationDesc() throws DeploymentException;
60
61     protected QName JavaDoc getOperationNameFromSOAPBody() {
62         BindingInput bindingInput = bindingOperation.getBindingInput();
63         List JavaDoc extensibilityElements = bindingInput.getExtensibilityElements();
64         for (Iterator JavaDoc iterator = extensibilityElements.iterator(); iterator.hasNext();) {
65             ExtensibilityElement extensibilityElement = (ExtensibilityElement) iterator.next();
66             if (extensibilityElement instanceof SOAPBody) {
67                 String JavaDoc namespaceURI = ((SOAPBody)extensibilityElement).getNamespaceURI();
68                 return new QName JavaDoc(namespaceURI, operationName);
69             }
70         }
71         return new QName JavaDoc("", operationName);
72     }
73 }
74
Popular Tags