1 /* |
1 /* |
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
27 |
27 |
28 import com.sun.istack.internal.NotNull; |
28 import com.sun.istack.internal.NotNull; |
29 import com.sun.istack.internal.Nullable; |
29 import com.sun.istack.internal.Nullable; |
30 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
30 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort; |
31 import com.sun.xml.internal.ws.api.model.wsdl.WSDLService; |
31 import com.sun.xml.internal.ws.api.model.wsdl.WSDLService; |
|
32 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLModel; |
|
33 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLPort; |
|
34 import com.sun.xml.internal.ws.api.model.wsdl.editable.EditableWSDLService; |
32 |
35 |
33 import javax.xml.namespace.QName; |
36 import javax.xml.namespace.QName; |
34 import javax.xml.stream.XMLStreamReader; |
37 import javax.xml.stream.XMLStreamReader; |
|
38 |
35 import java.util.LinkedHashMap; |
39 import java.util.LinkedHashMap; |
36 import java.util.Map; |
40 import java.util.Map; |
37 |
41 |
38 /** |
42 /** |
39 * Implementation of {@link WSDLService} |
43 * Implementation of {@link WSDLService} |
40 * |
44 * |
41 * @author Vivek Pandey |
45 * @author Vivek Pandey |
42 */ |
46 */ |
43 public final class WSDLServiceImpl extends AbstractExtensibleImpl implements WSDLService { |
47 public final class WSDLServiceImpl extends AbstractExtensibleImpl implements EditableWSDLService { |
44 private final QName name; |
48 private final QName name; |
45 private final Map<QName, WSDLPortImpl> ports; |
49 private final Map<QName, EditableWSDLPort> ports; |
46 private final WSDLModelImpl parent; |
50 private final EditableWSDLModel parent; |
47 |
51 |
48 public WSDLServiceImpl(XMLStreamReader xsr,WSDLModelImpl parent, QName name) { |
52 public WSDLServiceImpl(XMLStreamReader xsr, EditableWSDLModel parent, QName name) { |
49 super(xsr); |
53 super(xsr); |
50 this.parent = parent; |
54 this.parent = parent; |
51 this.name = name; |
55 this.name = name; |
52 ports = new LinkedHashMap<QName,WSDLPortImpl>(); |
56 ports = new LinkedHashMap<QName, EditableWSDLPort>(); |
53 } |
57 } |
54 |
58 |
55 public @NotNull |
59 public @NotNull |
56 WSDLModelImpl getParent() { |
60 EditableWSDLModel getParent() { |
57 return parent; |
61 return parent; |
58 } |
62 } |
59 |
63 |
60 public QName getName() { |
64 public QName getName() { |
61 return name; |
65 return name; |
62 } |
66 } |
63 |
67 |
64 public WSDLPortImpl get(QName portName) { |
68 public EditableWSDLPort get(QName portName) { |
65 return ports.get(portName); |
69 return ports.get(portName); |
66 } |
70 } |
67 |
71 |
68 public WSDLPort getFirstPort() { |
72 public EditableWSDLPort getFirstPort() { |
69 if(ports.isEmpty()) |
73 if(ports.isEmpty()) |
70 return null; |
74 return null; |
71 else |
75 else |
72 return ports.values().iterator().next(); |
76 return ports.values().iterator().next(); |
73 } |
77 } |
74 |
78 |
75 public Iterable<WSDLPortImpl> getPorts(){ |
79 public Iterable<EditableWSDLPort> getPorts(){ |
76 return ports.values(); |
80 return ports.values(); |
77 } |
81 } |
78 |
82 |
79 /** |
83 /** |
80 * gets the first port in this service which matches the portType |
84 * gets the first port in this service which matches the portType |
81 */ |
85 */ |
82 public @Nullable |
86 public @Nullable |
83 WSDLPortImpl getMatchingPort(QName portTypeName){ |
87 EditableWSDLPort getMatchingPort(QName portTypeName){ |
84 for(WSDLPortImpl port : getPorts()){ |
88 for(EditableWSDLPort port : getPorts()){ |
85 QName ptName = port.getBinding().getPortTypeName(); |
89 QName ptName = port.getBinding().getPortTypeName(); |
86 assert (ptName != null); |
90 assert (ptName != null); |
87 if(ptName.equals(portTypeName)) |
91 if(ptName.equals(portTypeName)) |
88 return port; |
92 return port; |
89 } |
93 } |
95 * |
99 * |
96 * @param portName Must be non-null |
100 * @param portName Must be non-null |
97 * @param port Must be non-null |
101 * @param port Must be non-null |
98 * @throws NullPointerException if either opName or ptOp is null |
102 * @throws NullPointerException if either opName or ptOp is null |
99 */ |
103 */ |
100 public void put(QName portName, WSDLPortImpl port) { |
104 public void put(QName portName, EditableWSDLPort port) { |
101 if (portName == null || port == null) |
105 if (portName == null || port == null) |
102 throw new NullPointerException(); |
106 throw new NullPointerException(); |
103 ports.put(portName, port); |
107 ports.put(portName, port); |
104 } |
108 } |
105 |
109 |
106 void freeze(WSDLModelImpl root) { |
110 public void freeze(EditableWSDLModel root) { |
107 for (WSDLPortImpl port : ports.values()) { |
111 for (EditableWSDLPort port : ports.values()) { |
108 port.freeze(root); |
112 port.freeze(root); |
109 } |
113 } |
110 } |
114 } |
111 } |
115 } |