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

changeset 0
373ffda63c9a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/ws/policy/PolicyMapKey.java	Wed Apr 27 01:27:09 2016 +0800
     1.3 @@ -0,0 +1,131 @@
     1.4 +/*
     1.5 + * Copyright (c) 1997, 2010, 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.policy;
    1.30 +
    1.31 +import com.sun.xml.internal.ws.policy.privateutil.LocalizationMessages;
    1.32 +import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
    1.33 +
    1.34 +import javax.xml.namespace.QName;
    1.35 +
    1.36 +/**
    1.37 + * This class provides implementation of PolicyMapKey interface to be used in connection with {@link PolicyMap}.
    1.38 + * Instances of the class are created by a call to one of {@link PolicyMap} <code>createWsdl<emph>XXX</emph>PolicyMapKey(...)</code>
    1.39 + * methods.
    1.40 + * <p/>
    1.41 + * The class wraps scope information and adds a package setter method to allow injection of actual equality comparator/tester. This injection
    1.42 + * is made within a <code>get...</code> call on {@link PolicyMap}, before the actual scope map search is performed.
    1.43 + *
    1.44 + *
    1.45 + * @author Marek Potociar (marek.potociar at sun.com)
    1.46 + * @author Fabian Ritzmann
    1.47 + */
    1.48 +final public class PolicyMapKey  {
    1.49 +    private static final PolicyLogger LOGGER = PolicyLogger.getLogger(PolicyMapKey.class);
    1.50 +
    1.51 +    private final QName service;
    1.52 +    private final QName port;
    1.53 +    private final QName operation;
    1.54 +    private final QName faultMessage;
    1.55 +
    1.56 +    private PolicyMapKeyHandler handler;
    1.57 +
    1.58 +    PolicyMapKey(final QName service, final QName port, final QName operation, final PolicyMapKeyHandler handler) {
    1.59 +        this(service, port, operation, null, handler);
    1.60 +    }
    1.61 +
    1.62 +    PolicyMapKey(final QName service, final QName port, final QName operation, final QName faultMessage, final PolicyMapKeyHandler handler) {
    1.63 +        if (handler == null) {
    1.64 +            throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0046_POLICY_MAP_KEY_HANDLER_NOT_SET()));
    1.65 +        }
    1.66 +
    1.67 +        this.service = service;
    1.68 +        this.port = port;
    1.69 +        this.operation = operation;
    1.70 +        this.faultMessage = faultMessage;
    1.71 +        this.handler = handler;
    1.72 +    }
    1.73 +
    1.74 +    PolicyMapKey(final PolicyMapKey that) {
    1.75 +        this.service = that.service;
    1.76 +        this.port = that.port;
    1.77 +        this.operation = that.operation;
    1.78 +        this.faultMessage = that.faultMessage;
    1.79 +        this.handler = that.handler;
    1.80 +    }
    1.81 +
    1.82 +    public QName getOperation() {
    1.83 +        return operation;
    1.84 +    }
    1.85 +
    1.86 +    public QName getPort() {
    1.87 +        return port;
    1.88 +    }
    1.89 +
    1.90 +    public QName getService() {
    1.91 +        return service;
    1.92 +    }
    1.93 +
    1.94 +    void setHandler(PolicyMapKeyHandler handler) {
    1.95 +        if (handler == null) {
    1.96 +            throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0046_POLICY_MAP_KEY_HANDLER_NOT_SET()));
    1.97 +        }
    1.98 +
    1.99 +        this.handler = handler;
   1.100 +    }
   1.101 +
   1.102 +    public QName getFaultMessage() {
   1.103 +        return faultMessage;
   1.104 +    }
   1.105 +
   1.106 +    @Override
   1.107 +    public boolean equals(final Object that) {
   1.108 +        if (this == that) {
   1.109 +            return true; // we are lucky here => no special handling is required
   1.110 +        }
   1.111 +
   1.112 +        if (that == null) {
   1.113 +            return false;
   1.114 +        }
   1.115 +
   1.116 +        if (that instanceof PolicyMapKey) {
   1.117 +            return handler.areEqual(this, (PolicyMapKey) that);
   1.118 +        } else {
   1.119 +            return false;
   1.120 +        }
   1.121 +    }
   1.122 +
   1.123 +    @Override
   1.124 +    public int hashCode() {
   1.125 +        return handler.generateHashCode(this);
   1.126 +    }
   1.127 +
   1.128 +    @Override
   1.129 +    public String toString() {
   1.130 +        final StringBuffer result = new StringBuffer("PolicyMapKey(");
   1.131 +        result.append(this.service).append(", ").append(port).append(", ").append(operation).append(", ").append(faultMessage);
   1.132 +        return result.append(")").toString();
   1.133 +    }
   1.134 +}

mercurial