1 /* 2 * Copyright (c) 2009, 2017, 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 javax.xml.ws.spi.http; 27 28 import javax.xml.ws.Endpoint; 29 import java.util.Set; 30 31 /** 32 * HttpContext represents a mapping between the root URI path of a web 33 * service to a {@link HttpHandler} which is invoked to handle requests 34 * destined for that path on the associated container. 35 * <p> 36 * Container provides the implementation for this and it matches 37 * web service requests to corresponding HttpContext objects. 38 * 39 * @author Jitendra Kotamraju 40 * @since 1.7, JAX-WS 2.2 41 */ 42 public abstract class HttpContext { 43 44 /** 45 * The handler to set for this context. 46 */ 47 protected HttpHandler handler; 48 49 /** 50 * JAX-WS runtime sets its handler during 51 * {@link Endpoint#publish(HttpContext)} to handle 52 * HTTP requests for this context. Container or its extensions 53 * use this handler to process the requests. 54 * 55 * @param handler the handler to set for this context 56 */ 57 public void setHandler(HttpHandler handler) { 58 this.handler = handler; 59 } 60 61 /** 62 * Returns the path for this context. This path uniquely identifies 63 * an endpoint inside an application and the path is relative to 64 * application's context path. Container should give this 65 * path based on how it matches request URIs to this HttpContext object. 66 * 67 * <p> 68 * For servlet container, this is typically a url-pattern for an endpoint. 69 * 70 * <p> 71 * Endpoint's address for this context can be computed as follows: 72 * <pre> 73 * HttpExchange exch = ...; 74 * String endpointAddress = 75 * exch.getScheme() + "://" 76 * + exch.getLocalAddress().getHostName() 77 * + ":" + exch.getLocalAddress().getPort() 78 * + exch.getContextPath() + getPath(); 79 * </pre> 80 * 81 * @return this context's path 82 */ 83 public abstract String getPath(); 84 85 /** 86 * Returns an attribute value for container's configuration 87 * and other data that can be used by jax-ws runtime. 88 * 89 * @param name attribute name 90 * @return attribute value 91 */ 92 public abstract Object getAttribute(String name); 93 94 /** 95 * Returns all attribute names for container's configuration 96 * and other data that can be used by jax-ws runtime. 97 * 98 * @return set of all attribute names 99 */ 100 public abstract Set<String> getAttributeNames(); 101 102 }