src/share/jaxws_classes/com/sun/xml/internal/ws/handler/PortInfoImpl.java

changeset 0
373ffda63c9a
child 637
9c07ef4934dd
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/handler/PortInfoImpl.java	Wed Apr 27 01:27:09 2016 +0800
     1.3 @@ -0,0 +1,123 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.xml.internal.ws.handler;
    1.30 +
    1.31 +import com.sun.xml.internal.ws.api.BindingID;
    1.32 +import com.sun.xml.internal.ws.client.WSServiceDelegate;
    1.33 +
    1.34 +import javax.xml.namespace.QName;
    1.35 +import javax.xml.ws.handler.PortInfo;
    1.36 +
    1.37 +/**
    1.38 + * <p>Implementation of the PortInfo interface. This is just a simple
    1.39 + * class used to hold the info necessary to uniquely identify a port,
    1.40 + * including the port name, service name, and binding ID. This class
    1.41 + * is only used on the client side.
    1.42 + *
    1.43 + * <p>An instance is created by
    1.44 + * {@link WSServiceDelegate} when used to
    1.45 + * place a handler chain into the HandlerResolver map. Another is
    1.46 + * created later by
    1.47 + * {@link com.sun.xml.internal.ws.client.WSServiceDelegate} to retrieve the
    1.48 + * necessary handler chain to set on a binding instance.
    1.49 + *
    1.50 + * @see WSServiceDelegate
    1.51 + * @see com.sun.xml.internal.ws.client.HandlerResolverImpl
    1.52 + *
    1.53 + * @author WS Development Team
    1.54 + */
    1.55 +public class PortInfoImpl implements PortInfo {
    1.56 +
    1.57 +    private BindingID bindingId;
    1.58 +    private QName portName;
    1.59 +    private QName serviceName;
    1.60 +
    1.61 +    /**
    1.62 +     * The class is constructed with the information needed to identify
    1.63 +     * a port. This information cannot be changed later.
    1.64 +     *
    1.65 +     * @param bindingId The binding ID string.
    1.66 +     * @param portName The QName of the port.
    1.67 +     * @param serviceName The QName of the service.
    1.68 +     */
    1.69 +    public PortInfoImpl(BindingID bindingId, QName portName, QName serviceName) {
    1.70 +        if (bindingId == null) {
    1.71 +            throw new RuntimeException("bindingId cannot be null");
    1.72 +        }
    1.73 +        if (portName == null) {
    1.74 +            throw new RuntimeException("portName cannot be null");
    1.75 +        }
    1.76 +        if (serviceName == null) {
    1.77 +            throw new RuntimeException("serviceName cannot be null");
    1.78 +        }
    1.79 +        this.bindingId = bindingId;
    1.80 +        this.portName = portName;
    1.81 +        this.serviceName = serviceName;
    1.82 +    }
    1.83 +
    1.84 +    public String getBindingID() {
    1.85 +        return bindingId.toString();
    1.86 +    }
    1.87 +
    1.88 +    public QName getPortName() {
    1.89 +        return portName;
    1.90 +    }
    1.91 +
    1.92 +    public QName getServiceName() {
    1.93 +        return serviceName;
    1.94 +    }
    1.95 +
    1.96 +    /**
    1.97 +     * Object.equals is overridden here so that PortInfo objects
    1.98 +     * can be compared when using them as keys in the map in
    1.99 +     * HandlerResolverImpl. This method relies on the equals()
   1.100 +     * methods of java.lang.String and javax.xml.namespace.QName.
   1.101 +     *
   1.102 +     * @param obj The PortInfo object to test for equality.
   1.103 +     * @return True if they match, and false if they do not or
   1.104 +     * if the object passed in is not a PortInfo.
   1.105 +     */
   1.106 +    public boolean equals(Object obj) {
   1.107 +        if (obj instanceof PortInfo) {
   1.108 +            PortInfo info = (PortInfo) obj;
   1.109 +            if (bindingId.toString().equals(info.getBindingID()) &&
   1.110 +                portName.equals(info.getPortName()) &&
   1.111 +                serviceName.equals(info.getServiceName())) {
   1.112 +                return true;
   1.113 +            }
   1.114 +        }
   1.115 +        return false;
   1.116 +    }
   1.117 +
   1.118 +    /**
   1.119 +     * Needed so PortInfoImpl can be used as a key in a map. This
   1.120 +     * method just delegates to the hashCode method of java.lang.String.
   1.121 +     */
   1.122 +    public int hashCode() {
   1.123 +        return bindingId.hashCode();
   1.124 +    }
   1.125 +
   1.126 +}

mercurial