src/share/jaxws_classes/com/sun/xml/internal/ws/api/server/WebServiceContextDelegate.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 368
0989ad8c0860
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package com.sun.xml.internal.ws.api.server;
aoqi@0 27
aoqi@0 28 import com.sun.istack.internal.NotNull;
aoqi@0 29 import com.sun.istack.internal.Nullable;
aoqi@0 30 import com.sun.xml.internal.ws.api.message.Packet;
aoqi@0 31 import com.sun.xml.internal.ws.api.pipe.Pipe;
aoqi@0 32
aoqi@0 33 import javax.xml.ws.WebServiceContext;
aoqi@0 34 import javax.xml.ws.WebServiceException;
aoqi@0 35 import java.security.Principal;
aoqi@0 36
aoqi@0 37 /**
aoqi@0 38 * This object is set to {@link Packet#webServiceContextDelegate}
aoqi@0 39 * to serve {@link WebServiceContext} methods for a {@link Packet}.
aoqi@0 40 *
aoqi@0 41 * <p>
aoqi@0 42 * When the user application calls a method on {@link WebServiceContext},
aoqi@0 43 * the JAX-WS RI goes to the {@link Packet} that represents the request,
aoqi@0 44 * then check {@link Packet#webServiceContextDelegate}, and forwards
aoqi@0 45 * the method calls to {@link WebServiceContextDelegate}.
aoqi@0 46 *
aoqi@0 47 * <p>
aoqi@0 48 * All the methods defined on this interface takes {@link Packet}
aoqi@0 49 * (whose {@link Packet#webServiceContextDelegate} points to
aoqi@0 50 * this object), so that a single stateless {@link WebServiceContextDelegate}
aoqi@0 51 * can be used to serve multiple concurrent {@link Packet}s,
aoqi@0 52 * if the implementation wishes to do so.
aoqi@0 53 *
aoqi@0 54 * <p>
aoqi@0 55 * (It is also allowed to create one instance of
aoqi@0 56 * {@link WebServiceContextDelegate} for each packet,
aoqi@0 57 * and thus effectively ignore the packet parameter.)
aoqi@0 58 *
aoqi@0 59 * <p>
aoqi@0 60 * Attaching this on a {@link Packet} allows {@link Pipe}s to
aoqi@0 61 * intercept and replace them, if they wish.
aoqi@0 62 *
aoqi@0 63 *
aoqi@0 64 * @author Kohsuke Kawaguchi
aoqi@0 65 */
aoqi@0 66 public interface WebServiceContextDelegate {
aoqi@0 67 /**
aoqi@0 68 * Implements {@link WebServiceContext#getUserPrincipal()}
aoqi@0 69 * for the given packet.
aoqi@0 70 *
aoqi@0 71 * @param request
aoqi@0 72 * Always non-null. See class javadoc.
aoqi@0 73 * @see WebServiceContext#getUserPrincipal()
aoqi@0 74 */
aoqi@0 75 Principal getUserPrincipal(@NotNull Packet request);
aoqi@0 76
aoqi@0 77 /**
aoqi@0 78 * Implements {@link WebServiceContext#isUserInRole(String)}
aoqi@0 79 * for the given packet.
aoqi@0 80 *
aoqi@0 81 * @param request
aoqi@0 82 * Always non-null. See class javadoc.
aoqi@0 83 * @see WebServiceContext#isUserInRole(String)
aoqi@0 84 */
aoqi@0 85 boolean isUserInRole(@NotNull Packet request,String role);
aoqi@0 86
aoqi@0 87 /**
aoqi@0 88 * Gets the address of the endpoint.
aoqi@0 89 *
aoqi@0 90 * <p>
aoqi@0 91 * The "address" of endpoints is always affected by a particular
aoqi@0 92 * client being served, hence it's up to transport to provide this
aoqi@0 93 * information.
aoqi@0 94 *
aoqi@0 95 * @param request
aoqi@0 96 * Always non-null. See class javadoc.
aoqi@0 97 * @param endpoint
aoqi@0 98 * The endpoint whose address will be returned.
aoqi@0 99 *
aoqi@0 100 * @throws WebServiceException
aoqi@0 101 * if this method could not compute the address for some reason.
aoqi@0 102 * @return
aoqi@0 103 * Absolute URL of the endpoint. This shold be an address that the client
aoqi@0 104 * can use to talk back to this same service later.
aoqi@0 105 *
aoqi@0 106 * @see WebServiceContext#getEndpointReference
aoqi@0 107 */
aoqi@0 108 @NotNull String getEPRAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint);
aoqi@0 109
aoqi@0 110 /**
aoqi@0 111 * Gets the address of the primary WSDL.
aoqi@0 112 *
aoqi@0 113 * <p>
aoqi@0 114 * If a transport supports publishing of WSDL by itself (instead/in addition to MEX),
aoqi@0 115 * then it should implement this method so that the rest of the JAX-WS RI can
aoqi@0 116 * use that information.
aoqi@0 117 *
aoqi@0 118 * For example, HTTP transports often use the convention {@code getEPRAddress()+"?wsdl"}
aoqi@0 119 * for publishing WSDL on HTTP.
aoqi@0 120 *
aoqi@0 121 * <p>
aoqi@0 122 * Some transports may not have such WSDL publishing mechanism on its own.
aoqi@0 123 * Those transports may choose to return null, indicating that WSDL
aoqi@0 124 * is not published. If such transports are always used in conjunction with
aoqi@0 125 * other transports that support WSDL publishing (such as SOAP/TCP used
aoqi@0 126 * with Servlet transport), then such transport may
aoqi@0 127 * choose to find the corresponding servlet endpoint by {@link Module#getBoundEndpoints()}
aoqi@0 128 * and try to obtain the address from there.
aoqi@0 129 *
aoqi@0 130 * <p>
aoqi@0 131 * This information is used to put a metadata reference inside an EPR,
aoqi@0 132 * among other things. Clients that do not support MEX rely on this
aoqi@0 133 * WSDL URL to retrieve metadata, it is desirable for transports to support
aoqi@0 134 * this, but not mandatory.
aoqi@0 135 *
aoqi@0 136 * <p>
aoqi@0 137 * This method will be never invoked if the {@link WSEndpoint}
aoqi@0 138 * does not have a corresponding WSDL to begin with
aoqi@0 139 * (IOW {@link WSEndpoint#getServiceDefinition() returning null}.
aoqi@0 140 *
aoqi@0 141 * @param request
aoqi@0 142 * Always non-null. See class javadoc.
aoqi@0 143 * @param endpoint
aoqi@0 144 * The endpoint whose address will be returned.
aoqi@0 145 *
aoqi@0 146 * @return
aoqi@0 147 * null if the implementation does not support the notion of
aoqi@0 148 * WSDL publishing.
aoqi@0 149 */
aoqi@0 150 @Nullable String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint);
aoqi@0 151 }

mercurial