aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. Oracle designates this aoqi@0: * particular file as subject to the "Classpath" exception as provided aoqi@0: * by Oracle in the LICENSE file that accompanied this code. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: */ aoqi@0: aoqi@0: package com.sun.xml.internal.ws.api.client; aoqi@0: aoqi@0: import com.sun.istack.internal.NotNull; aoqi@0: import com.sun.istack.internal.Nullable; aoqi@0: import com.sun.xml.internal.ws.api.BindingID; aoqi@0: import com.sun.xml.internal.ws.api.WSBinding; aoqi@0: import com.sun.xml.internal.ws.api.WSFeatureList; aoqi@0: import com.sun.xml.internal.ws.api.WSService; aoqi@0: import com.sun.xml.internal.ws.developer.WSBindingProvider; aoqi@0: aoqi@0: import javax.xml.ws.BindingProvider; aoqi@0: import javax.xml.ws.Dispatch; aoqi@0: import javax.xml.ws.WebServiceFeature; aoqi@0: import java.util.ArrayList; aoqi@0: import java.util.Collections; aoqi@0: import java.util.List; aoqi@0: aoqi@0: /** aoqi@0: * Interception point for inner working of {@link WSService}. aoqi@0: * aoqi@0: *

aoqi@0: * System-level code could hook an implementation of this to aoqi@0: * {@link WSService} to augument its behavior. aoqi@0: * aoqi@0: * @author Kohsuke Kawaguchi aoqi@0: * @since 2.1 EA3 aoqi@0: * @see ServiceInterceptorFactory aoqi@0: */ aoqi@0: public abstract class ServiceInterceptor { aoqi@0: /** aoqi@0: * Called before {@link WSBinding} is created, to allow interceptors aoqi@0: * to add {@link WebServiceFeature}s to the created {@link WSBinding}. aoqi@0: * aoqi@0: * @param port aoqi@0: * Information about the port for which dispatch/proxy will be created. aoqi@0: * @param serviceEndpointInterface aoqi@0: * Null if the created binding is for {@link Dispatch}. Otheriwse aoqi@0: * it represents the port interface of the proxy to be created. aoqi@0: * @param defaultFeatures aoqi@0: * The list of features that are currently scheduled to be set for aoqi@0: * the newly created {@link WSBinding}. aoqi@0: * aoqi@0: * @return aoqi@0: * A set of features to be added to the newly created {@link WSBinding}. aoqi@0: * Can be empty but never null. aoqi@0: * defaultFeatures will take precedence over what this method aoqi@0: * would return (because it includes user-specified ones which will aoqi@0: * take the at-most priority), but features you return from this method aoqi@0: * will take precedence over {@link BindingID}'s aoqi@0: * {@link BindingID#createBuiltinFeatureList() implicit features}. aoqi@0: */ aoqi@0: public List preCreateBinding(@NotNull WSPortInfo port, @Nullable Class serviceEndpointInterface, @NotNull WSFeatureList defaultFeatures) { aoqi@0: return Collections.emptyList(); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * A callback to notify the event of creation of proxy object for SEI endpoint. The aoqi@0: * callback could set some properties on the {@link BindingProvider}. aoqi@0: * aoqi@0: * @param bp created proxy instance aoqi@0: * @param serviceEndpointInterface SEI of the endpoint aoqi@0: */ aoqi@0: public void postCreateProxy(@NotNull WSBindingProvider bp,@NotNull Class serviceEndpointInterface) { aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * A callback to notify that a {@link Dispatch} object is created. The callback aoqi@0: * could set some properties on the {@link BindingProvider}. aoqi@0: * aoqi@0: * @param bp BindingProvider of dispatch object aoqi@0: */ aoqi@0: public void postCreateDispatch(@NotNull WSBindingProvider bp) { aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Aggregates multiple interceptors into one facade. aoqi@0: */ aoqi@0: public static ServiceInterceptor aggregate(final ServiceInterceptor... interceptors) { aoqi@0: if(interceptors.length==1) aoqi@0: return interceptors[0]; aoqi@0: return new ServiceInterceptor() { aoqi@0: public List preCreateBinding(@NotNull WSPortInfo port, @Nullable Class portInterface, @NotNull WSFeatureList defaultFeatures) { aoqi@0: List r = new ArrayList(); aoqi@0: for (ServiceInterceptor si : interceptors) aoqi@0: r.addAll(si.preCreateBinding(port,portInterface,defaultFeatures)); aoqi@0: return r; aoqi@0: } aoqi@0: aoqi@0: public void postCreateProxy(@NotNull WSBindingProvider bp, @NotNull Class serviceEndpointInterface) { aoqi@0: for (ServiceInterceptor si : interceptors) aoqi@0: si.postCreateProxy(bp,serviceEndpointInterface); aoqi@0: } aoqi@0: aoqi@0: public void postCreateDispatch(@NotNull WSBindingProvider bp) { aoqi@0: for (ServiceInterceptor si : interceptors) aoqi@0: si.postCreateDispatch(bp); aoqi@0: } aoqi@0: }; aoqi@0: } aoqi@0: }