src/share/jaxws_classes/com/sun/xml/internal/ws/policy/PolicyMapKey.java

Thu, 12 Oct 2017 19:44:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 19:44:07 +0800
changeset 760
e530533619ec
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1997, 2010, 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.xml.internal.ws.policy;
    28 import com.sun.xml.internal.ws.policy.privateutil.LocalizationMessages;
    29 import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
    31 import javax.xml.namespace.QName;
    33 /**
    34  * This class provides implementation of PolicyMapKey interface to be used in connection with {@link PolicyMap}.
    35  * Instances of the class are created by a call to one of {@link PolicyMap} <code>createWsdl<emph>XXX</emph>PolicyMapKey(...)</code>
    36  * methods.
    37  * <p/>
    38  * The class wraps scope information and adds a package setter method to allow injection of actual equality comparator/tester. This injection
    39  * is made within a <code>get...</code> call on {@link PolicyMap}, before the actual scope map search is performed.
    40  *
    41  *
    42  * @author Marek Potociar (marek.potociar at sun.com)
    43  * @author Fabian Ritzmann
    44  */
    45 final public class PolicyMapKey  {
    46     private static final PolicyLogger LOGGER = PolicyLogger.getLogger(PolicyMapKey.class);
    48     private final QName service;
    49     private final QName port;
    50     private final QName operation;
    51     private final QName faultMessage;
    53     private PolicyMapKeyHandler handler;
    55     PolicyMapKey(final QName service, final QName port, final QName operation, final PolicyMapKeyHandler handler) {
    56         this(service, port, operation, null, handler);
    57     }
    59     PolicyMapKey(final QName service, final QName port, final QName operation, final QName faultMessage, final PolicyMapKeyHandler handler) {
    60         if (handler == null) {
    61             throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0046_POLICY_MAP_KEY_HANDLER_NOT_SET()));
    62         }
    64         this.service = service;
    65         this.port = port;
    66         this.operation = operation;
    67         this.faultMessage = faultMessage;
    68         this.handler = handler;
    69     }
    71     PolicyMapKey(final PolicyMapKey that) {
    72         this.service = that.service;
    73         this.port = that.port;
    74         this.operation = that.operation;
    75         this.faultMessage = that.faultMessage;
    76         this.handler = that.handler;
    77     }
    79     public QName getOperation() {
    80         return operation;
    81     }
    83     public QName getPort() {
    84         return port;
    85     }
    87     public QName getService() {
    88         return service;
    89     }
    91     void setHandler(PolicyMapKeyHandler handler) {
    92         if (handler == null) {
    93             throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0046_POLICY_MAP_KEY_HANDLER_NOT_SET()));
    94         }
    96         this.handler = handler;
    97     }
    99     public QName getFaultMessage() {
   100         return faultMessage;
   101     }
   103     @Override
   104     public boolean equals(final Object that) {
   105         if (this == that) {
   106             return true; // we are lucky here => no special handling is required
   107         }
   109         if (that == null) {
   110             return false;
   111         }
   113         if (that instanceof PolicyMapKey) {
   114             return handler.areEqual(this, (PolicyMapKey) that);
   115         } else {
   116             return false;
   117         }
   118     }
   120     @Override
   121     public int hashCode() {
   122         return handler.generateHashCode(this);
   123     }
   125     @Override
   126     public String toString() {
   127         final StringBuffer result = new StringBuffer("PolicyMapKey(");
   128         result.append(this.service).append(", ").append(port).append(", ").append(operation).append(", ").append(faultMessage);
   129         return result.append(")").toString();
   130     }
   131 }

mercurial