src/share/jaxws_classes/com/sun/tools/internal/ws/processor/model/Service.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
equal deleted inserted replaced
-1:000000000000 0:373ffda63c9a
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 */
25
26 package com.sun.tools.internal.ws.processor.model;
27
28 import com.sun.tools.internal.ws.processor.model.java.JavaInterface;
29 import com.sun.tools.internal.ws.wsdl.framework.Entity;
30
31 import javax.xml.namespace.QName;
32 import java.util.*;
33
34 /**
35 *
36 * @author WS Development Team
37 */
38 public class Service extends ModelObject {
39
40 public Service(Entity entity) {
41 super(entity);
42 }
43
44 public Service(QName name, JavaInterface javaInterface, Entity entity) {
45 super(entity);
46 this.name = name;
47 this.javaInterface = javaInterface;
48 }
49
50 public QName getName() {
51 return name;
52 }
53
54 public void setName(QName n) {
55 name = n;
56 }
57
58 public void addPort(Port port) {
59 if (portsByName.containsKey(port.getName())) {
60 throw new ModelException("model.uniqueness");
61 }
62 ports.add(port);
63 portsByName.put(port.getName(), port);
64 }
65
66
67 public Port getPortByName(QName n) {
68 if (portsByName.size() != ports.size()) {
69 initializePortsByName();
70 }
71 return (Port) portsByName.get(n);
72 }
73
74 /* serialization */
75 public List<Port> getPorts() {
76 return ports;
77 }
78
79 /* serialization */
80 public void setPorts(List<Port> m) {
81 ports = m;
82 // initializePortsByName();
83 }
84
85 private void initializePortsByName() {
86 portsByName = new HashMap();
87 if (ports != null) {
88 for (Iterator iter = ports.iterator(); iter.hasNext();) {
89 Port port = (Port) iter.next();
90 if (port.getName() != null &&
91 portsByName.containsKey(port.getName())) {
92
93 throw new ModelException("model.uniqueness");
94 }
95 portsByName.put(port.getName(), port);
96 }
97 }
98 }
99
100 public JavaInterface getJavaIntf() {
101 return getJavaInterface();
102 }
103
104 public JavaInterface getJavaInterface() {
105 return javaInterface;
106 }
107
108 public void setJavaInterface(JavaInterface i) {
109 javaInterface = i;
110 }
111
112 public void accept(ModelVisitor visitor) throws Exception {
113 visitor.visit(this);
114 }
115
116 private QName name;
117 private List<Port> ports = new ArrayList();
118 private Map<QName, Port> portsByName = new HashMap<QName, Port>();
119 private JavaInterface javaInterface;
120 }

mercurial