325N/A/*
325N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
325N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
325N/A *
325N/A * This code is free software; you can redistribute it and/or modify it
325N/A * under the terms of the GNU General Public License version 2 only, as
325N/A * published by the Free Software Foundation. Oracle designates this
325N/A * particular file as subject to the "Classpath" exception as provided
325N/A * by Oracle in the LICENSE file that accompanied this code.
325N/A *
325N/A * This code is distributed in the hope that it will be useful, but WITHOUT
325N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
325N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
325N/A * version 2 for more details (a copy is included in the LICENSE file that
325N/A * accompanied this code).
325N/A *
325N/A * You should have received a copy of the GNU General Public License version
325N/A * 2 along with this work; if not, write to the Free Software Foundation,
325N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
325N/A *
325N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
325N/A * or visit www.oracle.com if you need additional information or have any
325N/A * questions.
325N/A */
325N/A
325N/Apackage com.sun.xml.internal.ws.api.client;
325N/A
325N/Aimport com.sun.istack.internal.NotNull;
325N/Aimport com.sun.istack.internal.Nullable;
325N/Aimport com.sun.xml.internal.ws.api.BindingID;
325N/Aimport com.sun.xml.internal.ws.api.WSBinding;
325N/Aimport com.sun.xml.internal.ws.api.WSFeatureList;
325N/Aimport com.sun.xml.internal.ws.api.WSService;
325N/Aimport com.sun.xml.internal.ws.developer.WSBindingProvider;
325N/A
325N/Aimport javax.xml.ws.BindingProvider;
325N/Aimport javax.xml.ws.Dispatch;
325N/Aimport javax.xml.ws.WebServiceFeature;
325N/Aimport java.util.ArrayList;
325N/Aimport java.util.Collections;
325N/Aimport java.util.List;
325N/A
325N/A/**
325N/A * Interception point for inner working of {@link WSService}.
325N/A *
325N/A * <p>
325N/A * System-level code could hook an implementation of this to
325N/A * {@link WSService} to augument its behavior.
325N/A *
325N/A * @author Kohsuke Kawaguchi
325N/A * @since 2.1 EA3
325N/A * @see ServiceInterceptorFactory
325N/A */
325N/Apublic abstract class ServiceInterceptor {
325N/A /**
325N/A * Called before {@link WSBinding} is created, to allow interceptors
325N/A * to add {@link WebServiceFeature}s to the created {@link WSBinding}.
325N/A *
325N/A * @param port
325N/A * Information about the port for which dispatch/proxy will be created.
325N/A * @param serviceEndpointInterface
325N/A * Null if the created binding is for {@link Dispatch}. Otheriwse
325N/A * it represents the port interface of the proxy to be created.
325N/A * @param defaultFeatures
325N/A * The list of features that are currently scheduled to be set for
325N/A * the newly created {@link WSBinding}.
325N/A *
325N/A * @return
325N/A * A set of features to be added to the newly created {@link WSBinding}.
325N/A * Can be empty but never null.
325N/A * <tt>defaultFeatures</tt> will take precedence over what this method
325N/A * would return (because it includes user-specified ones which will
325N/A * take the at-most priority), but features you return from this method
325N/A * will take precedence over {@link BindingID}'s
325N/A * {@link BindingID#createBuiltinFeatureList() implicit features}.
325N/A */
325N/A public List<WebServiceFeature> preCreateBinding(@NotNull WSPortInfo port, @Nullable Class<?> serviceEndpointInterface, @NotNull WSFeatureList defaultFeatures) {
325N/A return Collections.emptyList();
325N/A }
325N/A
325N/A
325N/A /**
325N/A * A callback to notify the event of creation of proxy object for SEI endpoint. The
325N/A * callback could set some properties on the {@link BindingProvider}.
325N/A *
325N/A * @param bp created proxy instance
325N/A * @param serviceEndpointInterface SEI of the endpoint
325N/A */
325N/A public void postCreateProxy(@NotNull WSBindingProvider bp,@NotNull Class<?> serviceEndpointInterface) {
325N/A }
325N/A
325N/A
325N/A /**
325N/A * A callback to notify that a {@link Dispatch} object is created. The callback
325N/A * could set some properties on the {@link BindingProvider}.
325N/A *
325N/A * @param bp BindingProvider of dispatch object
325N/A */
325N/A public void postCreateDispatch(@NotNull WSBindingProvider bp) {
325N/A }
325N/A
325N/A /**
325N/A * Aggregates multiple interceptors into one facade.
325N/A */
325N/A public static ServiceInterceptor aggregate(final ServiceInterceptor... interceptors) {
325N/A if(interceptors.length==1)
325N/A return interceptors[0];
325N/A return new ServiceInterceptor() {
325N/A public List<WebServiceFeature> preCreateBinding(@NotNull WSPortInfo port, @Nullable Class<?> portInterface, @NotNull WSFeatureList defaultFeatures) {
325N/A List<WebServiceFeature> r = new ArrayList<WebServiceFeature>();
325N/A for (ServiceInterceptor si : interceptors)
325N/A r.addAll(si.preCreateBinding(port,portInterface,defaultFeatures));
325N/A return r;
325N/A }
325N/A
325N/A public void postCreateProxy(@NotNull WSBindingProvider bp, @NotNull Class<?> serviceEndpointInterface) {
325N/A for (ServiceInterceptor si : interceptors)
325N/A si.postCreateProxy(bp,serviceEndpointInterface);
325N/A }
325N/A
325N/A public void postCreateDispatch(@NotNull WSBindingProvider bp) {
325N/A for (ServiceInterceptor si : interceptors)
325N/A si.postCreateDispatch(bp);
325N/A }
325N/A };
325N/A }
325N/A}