Thu, 31 Aug 2017 15:18:52 +0800
merge
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
26 package com.sun.tools.internal.ws.processor.model;
28 import com.sun.tools.internal.ws.processor.model.java.JavaInterface;
29 import com.sun.tools.internal.ws.wsdl.document.PortType;
30 import com.sun.tools.internal.ws.wsdl.document.soap.SOAPStyle;
31 import com.sun.tools.internal.ws.wsdl.framework.Entity;
33 import javax.xml.namespace.QName;
34 import java.util.ArrayList;
35 import java.util.HashMap;
36 import java.util.List;
37 import java.util.Map;
39 /**
40 * @author WS Development Team
41 */
42 public class Port extends ModelObject {
44 public Port(Entity entity) {
45 super(entity);
46 }
48 public Port(QName name, Entity entity) {
49 super(entity);
50 _name = name;
51 }
53 public QName getName() {
54 return _name;
55 }
57 public void setName(QName n) {
58 _name = n;
59 }
61 public void addOperation(Operation operation) {
62 _operations.add(operation);
63 operationsByName.put(operation.getUniqueName(), operation);
64 }
66 public Operation getOperationByUniqueName(String name) {
67 if (operationsByName.size() != _operations.size()) {
68 initializeOperationsByName();
69 }
70 return operationsByName.get(name);
71 }
73 private void initializeOperationsByName() {
74 operationsByName = new HashMap<String, Operation>();
75 if (_operations != null) {
76 for (Operation operation : _operations) {
77 if (operation.getUniqueName() != null &&
78 operationsByName.containsKey(operation.getUniqueName())) {
80 throw new ModelException("model.uniqueness");
81 }
82 operationsByName.put(operation.getUniqueName(), operation);
83 }
84 }
85 }
87 /* serialization */
88 public List<Operation> getOperations() {
89 return _operations;
90 }
92 /* serialization */
93 public void setOperations(List<Operation> l) {
94 _operations = l;
95 }
97 public JavaInterface getJavaInterface() {
98 return _javaInterface;
99 }
101 public void setJavaInterface(JavaInterface i) {
102 _javaInterface = i;
103 }
105 public String getAddress() {
106 return _address;
107 }
109 public void setAddress(String s) {
110 _address = s;
111 }
113 public String getServiceImplName() {
114 return _serviceImplName;
115 }
117 public void setServiceImplName(String name) {
118 _serviceImplName = name;
119 }
121 public void accept(ModelVisitor visitor) throws Exception {
122 visitor.visit(this);
123 }
125 public boolean isProvider() {
126 JavaInterface intf = getJavaInterface();
127 if (intf != null) {
128 String sei = intf.getName();
129 if (sei.equals(javax.xml.ws.Provider.class.getName())) {
130 return true;
131 }
132 }
133 return false;
134 }
136 /**
137 * XYZ_Service.getABC() method name
138 *
139 * @return Returns the portGetterName.
140 */
141 public String getPortGetter() {
142 return portGetter;
143 }
145 /**
146 * @param portGetterName The portGetterName to set.
147 */
148 public void setPortGetter(String portGetterName) {
149 this.portGetter = portGetterName;
150 }
152 public SOAPStyle getStyle() {
153 return _style;
154 }
156 public void setStyle(SOAPStyle s) {
157 _style = s;
158 }
160 public boolean isWrapped() {
161 return _isWrapped;
162 }
164 public void setWrapped(boolean isWrapped) {
165 _isWrapped = isWrapped;
166 }
168 private SOAPStyle _style = null;
169 private boolean _isWrapped = true;
171 private String portGetter;
172 private QName _name;
173 private List<Operation> _operations = new ArrayList<Operation>();
174 private JavaInterface _javaInterface;
175 private String _address;
176 private String _serviceImplName;
177 private Map<String, Operation> operationsByName = new HashMap<String, Operation>();
178 public Map<QName, PortType> portTypes = new HashMap<QName, PortType>();
179 }