|
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.api.policy; |
|
27 |
|
28 import com.sun.xml.internal.ws.policy.PolicyMap; |
|
29 import com.sun.xml.internal.ws.policy.PolicyMapMutator; |
|
30 import com.sun.xml.internal.ws.api.server.Container; |
|
31 import com.sun.istack.internal.Nullable; |
|
32 import java.util.Arrays; |
|
33 import java.util.Collection; |
|
34 import javax.xml.ws.WebServiceException; |
|
35 |
|
36 /** |
|
37 * PolicyResolver will be used to resolve the PolicyMap created by configuration understood by JAX-WS. |
|
38 * |
|
39 * Extensions of this can return effective PolicyMap after merge policies from other configurations. |
|
40 * @author Rama Pulavarthi |
|
41 */ |
|
42 public interface PolicyResolver { |
|
43 /** |
|
44 * Creates a PolicyResolver |
|
45 * |
|
46 * @param context |
|
47 * ServerContext that captures information useful for resolving Policy on server-side |
|
48 * |
|
49 * @return |
|
50 * A PolicyMap with single policy alternative that gets created after consulting various configuration models. |
|
51 * |
|
52 * @throws WebServiceException |
|
53 * If resolution failed |
|
54 */ |
|
55 PolicyMap resolve(ServerContext context) throws WebServiceException; |
|
56 |
|
57 /** |
|
58 * Creates a PolicyResolver |
|
59 * |
|
60 * @param context |
|
61 * ServerContext that captures information useful for resolving Policy on client-side |
|
62 * |
|
63 * @return |
|
64 * A PolicyMap with single policy alternative that gets created after consulting various configuration models. |
|
65 * |
|
66 * @throws WebServiceException |
|
67 * If resolution failed |
|
68 */ |
|
69 PolicyMap resolve(ClientContext context) throws WebServiceException; |
|
70 |
|
71 public class ServerContext { |
|
72 private final PolicyMap policyMap; |
|
73 private final Class endpointClass; |
|
74 private final Container container; |
|
75 private final boolean hasWsdl; |
|
76 private final Collection<PolicyMapMutator> mutators; |
|
77 |
|
78 /** |
|
79 * The abstraction of PolicyMap is not finalized, and will change in few months. It is highly discouraged to use |
|
80 * PolicyMap until it is finalized. |
|
81 * |
|
82 * In presence of WSDL, JAX-WS by default creates PolicyMap from Policy Attachemnts in WSDL. |
|
83 * In absense of WSDL, JAX-WS creates PolicyMap from WebServiceFeatures configured on the endpoint implementation |
|
84 * |
|
85 * @param policyMap |
|
86 * PolicyMap created from PolicyAttachments in WSDL or Feature annotations on endpoint implementation class. |
|
87 * @param container |
|
88 * @param endpointClass |
|
89 * @param mutators |
|
90 * List of PolicyMapMutators that are run eventually when a PolicyMap is created |
|
91 */ |
|
92 public ServerContext(@Nullable PolicyMap policyMap, Container container, |
|
93 Class endpointClass, final PolicyMapMutator... mutators) { |
|
94 this.policyMap = policyMap; |
|
95 this.endpointClass = endpointClass; |
|
96 this.container = container; |
|
97 this.hasWsdl = true; |
|
98 this.mutators = Arrays.asList(mutators); |
|
99 } |
|
100 |
|
101 /** |
|
102 * The abstraction of PolicyMap is not finalized, and will change in few months. It is highly discouraged to use |
|
103 * PolicyMap until it is finalized. |
|
104 * |
|
105 * In presence of WSDL, JAX-WS by default creates PolicyMap from Policy Attachemnts in WSDL. |
|
106 * In absense of WSDL, JAX-WS creates PolicyMap from WebServiceFeatures configured on the endpoint implementation |
|
107 * |
|
108 * @param policyMap |
|
109 * PolicyMap created from PolicyAttachments in WSDL or Feature annotations on endpoint implementation class. |
|
110 * @param container |
|
111 * @param endpointClass |
|
112 * @param hasWsdl Set to true, if this service is bundled with WSDL, false otherwise |
|
113 * @param mutators |
|
114 * List of PolicyMapMutators that are run eventually when a PolicyMap is created |
|
115 */ |
|
116 public ServerContext(@Nullable PolicyMap policyMap, Container container, |
|
117 Class endpointClass, boolean hasWsdl, final PolicyMapMutator... mutators) { |
|
118 this.policyMap = policyMap; |
|
119 this.endpointClass = endpointClass; |
|
120 this.container = container; |
|
121 this.hasWsdl = hasWsdl; |
|
122 this.mutators = Arrays.asList(mutators); |
|
123 } |
|
124 |
|
125 public @Nullable PolicyMap getPolicyMap() { |
|
126 return policyMap; |
|
127 } |
|
128 |
|
129 public @Nullable Class getEndpointClass() { |
|
130 return endpointClass; |
|
131 } |
|
132 |
|
133 public Container getContainer() { |
|
134 return container; |
|
135 } |
|
136 |
|
137 /** |
|
138 * Return true, if this service is bundled with WSDL, false otherwise |
|
139 * @return |
|
140 */ |
|
141 public boolean hasWsdl() { |
|
142 return hasWsdl; |
|
143 } |
|
144 |
|
145 public Collection<PolicyMapMutator> getMutators() { |
|
146 return mutators; |
|
147 } |
|
148 } |
|
149 |
|
150 public class ClientContext { |
|
151 private PolicyMap policyMap; |
|
152 private Container container; |
|
153 |
|
154 /** |
|
155 * The abstraction of PolicyMap is not finalized, and will change in few months. It is highly discouraged to use |
|
156 * PolicyMap until it is finalized. |
|
157 * |
|
158 * In presence of WSDL, JAX-WS by default creates PolicyMap from Policy Attachemnts in WSDL. |
|
159 * |
|
160 * @param policyMap PolicyMap created from PolicyAttachemnts in WSDL |
|
161 * @param container |
|
162 */ |
|
163 public ClientContext(@Nullable PolicyMap policyMap, Container container) { |
|
164 this.policyMap = policyMap; |
|
165 this.container = container; |
|
166 } |
|
167 |
|
168 public @Nullable PolicyMap getPolicyMap() { |
|
169 return policyMap; |
|
170 } |
|
171 |
|
172 public Container getContainer() { |
|
173 return container; |
|
174 } |
|
175 } |
|
176 } |