|
1 /* |
|
2 * Copyright (c) 1997, 2010, 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 com.sun.xml.internal.ws.transport.http.server; |
|
27 |
|
28 import com.sun.istack.internal.NotNull; |
|
29 import com.sun.xml.internal.ws.api.server.BoundEndpoint; |
|
30 import com.sun.xml.internal.ws.api.server.Module; |
|
31 import com.sun.xml.internal.ws.api.server.WSEndpoint; |
|
32 import com.sun.xml.internal.ws.api.server.WebModule; |
|
33 import com.sun.xml.internal.ws.transport.http.HttpAdapter; |
|
34 |
|
35 import javax.xml.ws.WebServiceException; |
|
36 import java.net.URI; |
|
37 import java.net.URISyntaxException; |
|
38 import java.util.logging.Logger; |
|
39 |
|
40 /** |
|
41 * {@link HttpAdapter} for Endpoint API. |
|
42 * |
|
43 * <p> |
|
44 * This is a thin wrapper around {@link HttpAdapter} |
|
45 * with some description specified in the deployment (in particular those |
|
46 * information are related to how a request is routed to a {@link ServerAdapter}. |
|
47 * |
|
48 * <p> |
|
49 * This class implements {@link BoundEndpoint} and represent the |
|
50 * server-{@link WSEndpoint} association for Endpoint API's transport |
|
51 * |
|
52 * @author Jitendra Kotamraju |
|
53 */ |
|
54 public final class ServerAdapter extends HttpAdapter implements BoundEndpoint { |
|
55 final String name; |
|
56 |
|
57 protected ServerAdapter(String name, String urlPattern, WSEndpoint endpoint, ServerAdapterList owner) { |
|
58 super(endpoint, owner, urlPattern); |
|
59 this.name = name; |
|
60 // registers itself with the container |
|
61 Module module = endpoint.getContainer().getSPI(Module.class); |
|
62 if(module==null) |
|
63 LOGGER.warning("Container "+endpoint.getContainer()+" doesn't support "+Module.class); |
|
64 else { |
|
65 module.getBoundEndpoints().add(this); |
|
66 } |
|
67 } |
|
68 |
|
69 /** |
|
70 * Gets the name of the endpoint as given in the <tt>sun-jaxws.xml</tt> |
|
71 * deployment descriptor. |
|
72 */ |
|
73 public String getName() { |
|
74 return name; |
|
75 } |
|
76 |
|
77 |
|
78 @NotNull |
|
79 public URI getAddress() { |
|
80 WebModule webModule = endpoint.getContainer().getSPI(WebModule.class); |
|
81 if(webModule==null) |
|
82 // this is really a bug in the container implementation |
|
83 throw new WebServiceException("Container "+endpoint.getContainer()+" doesn't support "+WebModule.class); |
|
84 |
|
85 return getAddress(webModule.getContextPath()); |
|
86 } |
|
87 |
|
88 public @NotNull URI getAddress(String baseAddress) { |
|
89 String adrs = baseAddress+getValidPath(); |
|
90 try { |
|
91 return new URI(adrs); |
|
92 } catch (URISyntaxException e) { |
|
93 // this is really a bug in the container implementation |
|
94 throw new WebServiceException("Unable to compute address for "+endpoint,e); |
|
95 } |
|
96 } |
|
97 |
|
98 public void dispose() { |
|
99 endpoint.dispose(); |
|
100 } |
|
101 |
|
102 public String getUrlPattern() { |
|
103 return urlPattern; |
|
104 } |
|
105 |
|
106 public String toString() { |
|
107 return super.toString()+"[name="+name+']'; |
|
108 } |
|
109 |
|
110 private static final Logger LOGGER = Logger.getLogger(ServerAdapter.class.getName()); |
|
111 } |