src/share/jaxws_classes/com/sun/xml/internal/ws/handler/PortInfoImpl.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.xml.internal.ws.handler;
27
28 import com.sun.xml.internal.ws.api.BindingID;
29 import com.sun.xml.internal.ws.client.WSServiceDelegate;
30
31 import javax.xml.namespace.QName;
32 import javax.xml.ws.handler.PortInfo;
33
34 /**
35 * <p>Implementation of the PortInfo interface. This is just a simple
36 * class used to hold the info necessary to uniquely identify a port,
37 * including the port name, service name, and binding ID. This class
38 * is only used on the client side.
39 *
40 * <p>An instance is created by
41 * {@link WSServiceDelegate} when used to
42 * place a handler chain into the HandlerResolver map. Another is
43 * created later by
44 * {@link com.sun.xml.internal.ws.client.WSServiceDelegate} to retrieve the
45 * necessary handler chain to set on a binding instance.
46 *
47 * @see WSServiceDelegate
48 * @see com.sun.xml.internal.ws.client.HandlerResolverImpl
49 *
50 * @author WS Development Team
51 */
52 public class PortInfoImpl implements PortInfo {
53
54 private BindingID bindingId;
55 private QName portName;
56 private QName serviceName;
57
58 /**
59 * The class is constructed with the information needed to identify
60 * a port. This information cannot be changed later.
61 *
62 * @param bindingId The binding ID string.
63 * @param portName The QName of the port.
64 * @param serviceName The QName of the service.
65 */
66 public PortInfoImpl(BindingID bindingId, QName portName, QName serviceName) {
67 if (bindingId == null) {
68 throw new RuntimeException("bindingId cannot be null");
69 }
70 if (portName == null) {
71 throw new RuntimeException("portName cannot be null");
72 }
73 if (serviceName == null) {
74 throw new RuntimeException("serviceName cannot be null");
75 }
76 this.bindingId = bindingId;
77 this.portName = portName;
78 this.serviceName = serviceName;
79 }
80
81 public String getBindingID() {
82 return bindingId.toString();
83 }
84
85 public QName getPortName() {
86 return portName;
87 }
88
89 public QName getServiceName() {
90 return serviceName;
91 }
92
93 /**
94 * Object.equals is overridden here so that PortInfo objects
95 * can be compared when using them as keys in the map in
96 * HandlerResolverImpl. This method relies on the equals()
97 * methods of java.lang.String and javax.xml.namespace.QName.
98 *
99 * @param obj The PortInfo object to test for equality.
100 * @return True if they match, and false if they do not or
101 * if the object passed in is not a PortInfo.
102 */
103 public boolean equals(Object obj) {
104 if (obj instanceof PortInfo) {
105 PortInfo info = (PortInfo) obj;
106 if (bindingId.toString().equals(info.getBindingID()) &&
107 portName.equals(info.getPortName()) &&
108 serviceName.equals(info.getServiceName())) {
109 return true;
110 }
111 }
112 return false;
113 }
114
115 /**
116 * Needed so PortInfoImpl can be used as a key in a map. This
117 * method just delegates to the hashCode method of java.lang.String.
118 */
119 public int hashCode() {
120 return bindingId.hashCode();
121 }
122
123 }

mercurial