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.policy; aoqi@0: aoqi@0: import com.sun.xml.internal.ws.policy.PolicyMap; aoqi@0: import com.sun.xml.internal.ws.policy.PolicyMapMutator; aoqi@0: import com.sun.xml.internal.ws.api.server.Container; aoqi@0: import com.sun.istack.internal.Nullable; aoqi@0: import java.util.Arrays; aoqi@0: import java.util.Collection; aoqi@0: import javax.xml.ws.WebServiceException; aoqi@0: aoqi@0: /** aoqi@0: * PolicyResolver will be used to resolve the PolicyMap created by configuration understood by JAX-WS. aoqi@0: * aoqi@0: * Extensions of this can return effective PolicyMap after merge policies from other configurations. aoqi@0: * @author Rama Pulavarthi aoqi@0: */ aoqi@0: public interface PolicyResolver { aoqi@0: /** aoqi@0: * Creates a PolicyResolver aoqi@0: * aoqi@0: * @param context aoqi@0: * ServerContext that captures information useful for resolving Policy on server-side aoqi@0: * aoqi@0: * @return aoqi@0: * A PolicyMap with single policy alternative that gets created after consulting various configuration models. aoqi@0: * aoqi@0: * @throws WebServiceException aoqi@0: * If resolution failed aoqi@0: */ aoqi@0: PolicyMap resolve(ServerContext context) throws WebServiceException; aoqi@0: aoqi@0: /** aoqi@0: * Creates a PolicyResolver aoqi@0: * aoqi@0: * @param context aoqi@0: * ServerContext that captures information useful for resolving Policy on client-side aoqi@0: * aoqi@0: * @return aoqi@0: * A PolicyMap with single policy alternative that gets created after consulting various configuration models. aoqi@0: * aoqi@0: * @throws WebServiceException aoqi@0: * If resolution failed aoqi@0: */ aoqi@0: PolicyMap resolve(ClientContext context) throws WebServiceException; aoqi@0: aoqi@0: public class ServerContext { aoqi@0: private final PolicyMap policyMap; aoqi@0: private final Class endpointClass; aoqi@0: private final Container container; aoqi@0: private final boolean hasWsdl; aoqi@0: private final Collection mutators; aoqi@0: aoqi@0: /** aoqi@0: * The abstraction of PolicyMap is not finalized, and will change in few months. It is highly discouraged to use aoqi@0: * PolicyMap until it is finalized. aoqi@0: * aoqi@0: * In presence of WSDL, JAX-WS by default creates PolicyMap from Policy Attachemnts in WSDL. aoqi@0: * In absense of WSDL, JAX-WS creates PolicyMap from WebServiceFeatures configured on the endpoint implementation aoqi@0: * aoqi@0: * @param policyMap aoqi@0: * PolicyMap created from PolicyAttachments in WSDL or Feature annotations on endpoint implementation class. aoqi@0: * @param container aoqi@0: * @param endpointClass aoqi@0: * @param mutators aoqi@0: * List of PolicyMapMutators that are run eventually when a PolicyMap is created aoqi@0: */ aoqi@0: public ServerContext(@Nullable PolicyMap policyMap, Container container, aoqi@0: Class endpointClass, final PolicyMapMutator... mutators) { aoqi@0: this.policyMap = policyMap; aoqi@0: this.endpointClass = endpointClass; aoqi@0: this.container = container; aoqi@0: this.hasWsdl = true; aoqi@0: this.mutators = Arrays.asList(mutators); aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * The abstraction of PolicyMap is not finalized, and will change in few months. It is highly discouraged to use aoqi@0: * PolicyMap until it is finalized. aoqi@0: * aoqi@0: * In presence of WSDL, JAX-WS by default creates PolicyMap from Policy Attachemnts in WSDL. aoqi@0: * In absense of WSDL, JAX-WS creates PolicyMap from WebServiceFeatures configured on the endpoint implementation aoqi@0: * aoqi@0: * @param policyMap aoqi@0: * PolicyMap created from PolicyAttachments in WSDL or Feature annotations on endpoint implementation class. aoqi@0: * @param container aoqi@0: * @param endpointClass aoqi@0: * @param hasWsdl Set to true, if this service is bundled with WSDL, false otherwise aoqi@0: * @param mutators aoqi@0: * List of PolicyMapMutators that are run eventually when a PolicyMap is created aoqi@0: */ aoqi@0: public ServerContext(@Nullable PolicyMap policyMap, Container container, aoqi@0: Class endpointClass, boolean hasWsdl, final PolicyMapMutator... mutators) { aoqi@0: this.policyMap = policyMap; aoqi@0: this.endpointClass = endpointClass; aoqi@0: this.container = container; aoqi@0: this.hasWsdl = hasWsdl; aoqi@0: this.mutators = Arrays.asList(mutators); aoqi@0: } aoqi@0: aoqi@0: public @Nullable PolicyMap getPolicyMap() { aoqi@0: return policyMap; aoqi@0: } aoqi@0: aoqi@0: public @Nullable Class getEndpointClass() { aoqi@0: return endpointClass; aoqi@0: } aoqi@0: aoqi@0: public Container getContainer() { aoqi@0: return container; aoqi@0: } aoqi@0: aoqi@0: /** aoqi@0: * Return true, if this service is bundled with WSDL, false otherwise aoqi@0: * @return aoqi@0: */ aoqi@0: public boolean hasWsdl() { aoqi@0: return hasWsdl; aoqi@0: } aoqi@0: aoqi@0: public Collection getMutators() { aoqi@0: return mutators; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: public class ClientContext { aoqi@0: private PolicyMap policyMap; aoqi@0: private Container container; aoqi@0: aoqi@0: /** aoqi@0: * The abstraction of PolicyMap is not finalized, and will change in few months. It is highly discouraged to use aoqi@0: * PolicyMap until it is finalized. aoqi@0: * aoqi@0: * In presence of WSDL, JAX-WS by default creates PolicyMap from Policy Attachemnts in WSDL. aoqi@0: * aoqi@0: * @param policyMap PolicyMap created from PolicyAttachemnts in WSDL aoqi@0: * @param container aoqi@0: */ aoqi@0: public ClientContext(@Nullable PolicyMap policyMap, Container container) { aoqi@0: this.policyMap = policyMap; aoqi@0: this.container = container; aoqi@0: } aoqi@0: aoqi@0: public @Nullable PolicyMap getPolicyMap() { aoqi@0: return policyMap; aoqi@0: } aoqi@0: aoqi@0: public Container getContainer() { aoqi@0: return container; aoqi@0: } aoqi@0: } aoqi@0: }