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