|
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 */ |
|
25 |
|
26 package com.sun.xml.internal.ws.api.client; |
|
27 |
|
28 import com.sun.istack.internal.NotNull; |
|
29 import com.sun.istack.internal.Nullable; |
|
30 import com.sun.xml.internal.ws.api.BindingID; |
|
31 import com.sun.xml.internal.ws.api.WSBinding; |
|
32 import com.sun.xml.internal.ws.api.WSFeatureList; |
|
33 import com.sun.xml.internal.ws.api.WSService; |
|
34 import com.sun.xml.internal.ws.developer.WSBindingProvider; |
|
35 |
|
36 import javax.xml.ws.BindingProvider; |
|
37 import javax.xml.ws.Dispatch; |
|
38 import javax.xml.ws.WebServiceFeature; |
|
39 import java.util.ArrayList; |
|
40 import java.util.Collections; |
|
41 import java.util.List; |
|
42 |
|
43 /** |
|
44 * Interception point for inner working of {@link WSService}. |
|
45 * |
|
46 * <p> |
|
47 * System-level code could hook an implementation of this to |
|
48 * {@link WSService} to augument its behavior. |
|
49 * |
|
50 * @author Kohsuke Kawaguchi |
|
51 * @since 2.1 EA3 |
|
52 * @see ServiceInterceptorFactory |
|
53 */ |
|
54 public abstract class ServiceInterceptor { |
|
55 /** |
|
56 * Called before {@link WSBinding} is created, to allow interceptors |
|
57 * to add {@link WebServiceFeature}s to the created {@link WSBinding}. |
|
58 * |
|
59 * @param port |
|
60 * Information about the port for which dispatch/proxy will be created. |
|
61 * @param serviceEndpointInterface |
|
62 * Null if the created binding is for {@link Dispatch}. Otheriwse |
|
63 * it represents the port interface of the proxy to be created. |
|
64 * @param defaultFeatures |
|
65 * The list of features that are currently scheduled to be set for |
|
66 * the newly created {@link WSBinding}. |
|
67 * |
|
68 * @return |
|
69 * A set of features to be added to the newly created {@link WSBinding}. |
|
70 * Can be empty but never null. |
|
71 * <tt>defaultFeatures</tt> will take precedence over what this method |
|
72 * would return (because it includes user-specified ones which will |
|
73 * take the at-most priority), but features you return from this method |
|
74 * will take precedence over {@link BindingID}'s |
|
75 * {@link BindingID#createBuiltinFeatureList() implicit features}. |
|
76 */ |
|
77 public List<WebServiceFeature> preCreateBinding(@NotNull WSPortInfo port, @Nullable Class<?> serviceEndpointInterface, @NotNull WSFeatureList defaultFeatures) { |
|
78 return Collections.emptyList(); |
|
79 } |
|
80 |
|
81 /** |
|
82 * A callback to notify the event of creation of proxy object for SEI endpoint. The |
|
83 * callback could set some properties on the {@link BindingProvider}. |
|
84 * |
|
85 * @param bp created proxy instance |
|
86 * @param serviceEndpointInterface SEI of the endpoint |
|
87 */ |
|
88 public void postCreateProxy(@NotNull WSBindingProvider bp,@NotNull Class<?> serviceEndpointInterface) { |
|
89 } |
|
90 |
|
91 /** |
|
92 * A callback to notify that a {@link Dispatch} object is created. The callback |
|
93 * could set some properties on the {@link BindingProvider}. |
|
94 * |
|
95 * @param bp BindingProvider of dispatch object |
|
96 */ |
|
97 public void postCreateDispatch(@NotNull WSBindingProvider bp) { |
|
98 } |
|
99 |
|
100 /** |
|
101 * Aggregates multiple interceptors into one facade. |
|
102 */ |
|
103 public static ServiceInterceptor aggregate(final ServiceInterceptor... interceptors) { |
|
104 if(interceptors.length==1) |
|
105 return interceptors[0]; |
|
106 return new ServiceInterceptor() { |
|
107 public List<WebServiceFeature> preCreateBinding(@NotNull WSPortInfo port, @Nullable Class<?> portInterface, @NotNull WSFeatureList defaultFeatures) { |
|
108 List<WebServiceFeature> r = new ArrayList<WebServiceFeature>(); |
|
109 for (ServiceInterceptor si : interceptors) |
|
110 r.addAll(si.preCreateBinding(port,portInterface,defaultFeatures)); |
|
111 return r; |
|
112 } |
|
113 |
|
114 public void postCreateProxy(@NotNull WSBindingProvider bp, @NotNull Class<?> serviceEndpointInterface) { |
|
115 for (ServiceInterceptor si : interceptors) |
|
116 si.postCreateProxy(bp,serviceEndpointInterface); |
|
117 } |
|
118 |
|
119 public void postCreateDispatch(@NotNull WSBindingProvider bp) { |
|
120 for (ServiceInterceptor si : interceptors) |
|
121 si.postCreateDispatch(bp); |
|
122 } |
|
123 }; |
|
124 } |
|
125 } |