author | mkos |
Sun, 30 Dec 2012 00:00:00 +0100 | |
changeset 22678 | ac1ea46be942 |
parent 12009 | 4abb694f273a |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
22678
ac1ea46be942
8029237: Update copyright year to match last edit in jaxws repository for 2012
mkos
parents:
12009
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. |
12009 | 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.policy; |
|
27 |
||
28 |
import com.sun.xml.internal.ws.policy.privateutil.LocalizationMessages; |
|
29 |
import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger; |
|
30 |
||
31 |
import javax.xml.namespace.QName; |
|
32 |
||
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); |
|
47 |
||
48 |
private final QName service; |
|
49 |
private final QName port; |
|
50 |
private final QName operation; |
|
51 |
private final QName faultMessage; |
|
52 |
||
53 |
private PolicyMapKeyHandler handler; |
|
54 |
||
55 |
PolicyMapKey(final QName service, final QName port, final QName operation, final PolicyMapKeyHandler handler) { |
|
56 |
this(service, port, operation, null, handler); |
|
57 |
} |
|
58 |
||
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 |
} |
|
63 |
||
64 |
this.service = service; |
|
65 |
this.port = port; |
|
66 |
this.operation = operation; |
|
67 |
this.faultMessage = faultMessage; |
|
68 |
this.handler = handler; |
|
69 |
} |
|
70 |
||
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 |
} |
|
78 |
||
79 |
public QName getOperation() { |
|
80 |
return operation; |
|
81 |
} |
|
82 |
||
83 |
public QName getPort() { |
|
84 |
return port; |
|
85 |
} |
|
86 |
||
87 |
public QName getService() { |
|
88 |
return service; |
|
89 |
} |
|
90 |
||
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 |
} |
|
95 |
||
96 |
this.handler = handler; |
|
97 |
} |
|
98 |
||
99 |
public QName getFaultMessage() { |
|
100 |
return faultMessage; |
|
101 |
} |
|
102 |
||
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 |
} |
|
108 |
||
109 |
if (that == null) { |
|
110 |
return false; |
|
111 |
} |
|
112 |
||
113 |
if (that instanceof PolicyMapKey) { |
|
114 |
return handler.areEqual(this, (PolicyMapKey) that); |
|
115 |
} else { |
|
116 |
return false; |
|
117 |
} |
|
118 |
} |
|
119 |
||
120 |
@Override |
|
121 |
public int hashCode() { |
|
122 |
return handler.generateHashCode(this); |
|
123 |
} |
|
124 |
||
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 |
} |