public class ServletConnectionImpl extends WSHTTPConnection implements WebServiceContextDelegate
WSHTTPConnection implemented for HttpServlet.INTERNAL_ERR, MALFORMED_XML, OK, ONEWAY, UNSUPPORTED_MEDIA| Constructor and Description |
|---|
ServletConnectionImpl(ServletAdapter adapter,
javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
| Modifier and Type | Method and Description |
|---|---|
String |
getBaseAddress()
Gets the absolute URL up to the context path.
|
(package private) static String |
getBaseAddress(javax.servlet.http.HttpServletRequest request) |
javax.servlet.ServletContext |
getContext()
Environment specific context , if available
|
String |
getContextPath()
Portion of the request URI that groups related service addresses.
|
String |
getCookie(String name)
Subclasses are expected to override
|
String |
getEPRAddress(Packet p,
WSEndpoint endpoint)
Gets the address of the endpoint.
|
HaInfo |
getHaInfo() |
InputStream |
getInput()
Transport's underlying input stream.
|
OutputStream |
getOutput()
Transport's underlying output stream
|
String |
getPathInfo()
Extra portion of the request URI after the end of the expected address of the service
but before the query string
|
protected org.jvnet.ws.message.BasePropertySet.PropertyMap |
getPropertyMap()
Map representing the Fields and Methods annotated with
Property. |
String |
getProtocol()
Subclasses are expected to override
|
String |
getQueryString()
HTTP Query string, such as "foo=bar", or null if none exists.
|
javax.servlet.http.HttpServletRequest |
getRequest() |
Object |
getRequestAttribute(String key)
Gets request metadata attribute
|
String |
getRequestHeader(String headerName)
Gets an HTTP request header.
|
Set<String> |
getRequestHeaderNames()
HTTP request header names.
|
Map<String,List<String>> |
getRequestHeaders()
HTTP request headers.
|
List<String> |
getRequestHeaderValues(String headerName)
Gets an HTTP request header.
|
String |
getRequestMethod()
HTTP request method, such as "GET" or "POST".
|
String |
getRequestScheme()
Requested scheme, e.g.
|
String |
getRequestURI()
Requested path.
|
String |
getRequestURL() |
javax.servlet.http.HttpServletResponse |
getResponse() |
Map<String,List<String>> |
getResponseHeaders() |
String |
getServerName()
Server name
|
int |
getServerPort()
Server port
|
int |
getStatus()
Gets the last value set by
WSHTTPConnection.setStatus(int). |
Principal |
getUserPrincipal()
User principal associated with the request
|
Principal |
getUserPrincipal(Packet p)
Implements
WebServiceContext.getUserPrincipal()
for the given packet. |
WebServiceContextDelegate |
getWebServiceContextDelegate()
Returns the
WebServiceContextDelegate for this connection. |
String |
getWSDLAddress(Packet request,
WSEndpoint endpoint)
Gets the address of the primary WSDL.
|
boolean |
isSecure()
Whether connection is HTTPS or not
|
boolean |
isUserInRole(Packet p,
String role)
Implements
WebServiceContext.isUserInRole(String)
for the given packet. |
boolean |
isUserInRole(String role)
Whether user associated with the request holds the given role
|
void |
setContentLengthResponseHeader(int value)
Subclasses are expected to override
|
void |
setContentTypeResponseHeader(String value)
Sets the "Content-Type" header.
|
void |
setCookie(String name,
String value)
Subclasses are expected to override
|
void |
setHaInfo(HaInfo replicaInfo) |
void |
setResponseHeader(String key,
List<String> value) |
void |
setResponseHeader(String key,
String value) |
void |
setResponseHeaders(Map<String,List<String>> headers)
sets response headers.
|
void |
setStatus(int status)
Sets the HTTP response code like
WSHTTPConnection.OK. |
close, isClosedpublic ServletConnectionImpl(@NotNull
ServletAdapter adapter,
javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
@NotNull public Map<String,List<String>> getRequestHeaders()
WSHTTPConnectiongetRequestHeaders in class WSHTTPConnectionpublic Set<String> getRequestHeaderNames()
WSHTTPConnectiongetRequestHeaderNames in class WSHTTPConnectionpublic List<String> getRequestHeaderValues(@NotNull String headerName)
WSHTTPConnectiongetRequestHeaderValues in class WSHTTPConnectionpublic void setResponseHeaders(Map<String,List<String>> headers)
setResponseHeaders in class WSHTTPConnectionheaders - See URLConnection.getHeaderFields() for the format.
This parameter may not be null, but since the user application
code may invoke this method, a graceful error checking with
an helpful error message should be provided if it's actually null.WSHTTPConnection.setContentTypeResponseHeader(String)public void setResponseHeader(String key, String value)
setResponseHeader in class WSHTTPConnectionpublic void setResponseHeader(String key, List<String> value)
setResponseHeader in class WSHTTPConnectionpublic Map<String,List<String>> getResponseHeaders()
getResponseHeaders in class WSHTTPConnectionpublic void setStatus(int status)
WSHTTPConnectionWSHTTPConnection.OK.
While JAX-WS processes a WSHTTPConnection, it
will at least call this method once to set a valid HTTP response code.
Note that this method may be invoked multiple times (from user code),
so do not consider the value to be final until WSHTTPConnection.getOutput()
is invoked.
setStatus in class WSHTTPConnectionpublic int getStatus()
WSHTTPConnectionWSHTTPConnection.setStatus(int).getStatus in class WSHTTPConnectionWSHTTPConnection.setStatus(int) has not been invoked yet,
return 0.public void setContentTypeResponseHeader(@NotNull
String value)
WSHTTPConnectionIf the Content-Type header has already been set, this method will overwrite the previously set value. If not, this method adds it.
Note that this method and #setResponseHeaders(Map<String,List<String>>)
may be invoked in any arbitrary order.
setContentTypeResponseHeader in class WSHTTPConnectionvalue - strings like "application/xml; charset=UTF-8" or
"image/jpeg".@NotNull public InputStream getInput() throws IOException
WSHTTPConnection
This method will be invoked at most once by the JAX-WS RI to
read the request body. If there's no request body, this method
should return an empty InputStream.
getInput in class WSHTTPConnectionIOException@NotNull public OutputStream getOutput() throws IOException
WSHTTPConnectionThis method will be invoked exactly once by the JAX-WS RI to start writing the response body (unless the processing aborts abnormally.) Even if there's no response body to write, this method will still be invoked only to be closed immediately.
Once this method is called, the status code and response
headers will never change (IOW WSHTTPConnection.setStatus(int),
WSHTTPConnection.setResponseHeaders(java.util.Map<java.lang.String, java.util.List<java.lang.String>>), and WSHTTPConnection.setContentTypeResponseHeader(String)
will never be invoked.
getOutput in class WSHTTPConnectionIOException@NotNull public WebServiceContextDelegate getWebServiceContextDelegate()
WSHTTPConnectionWebServiceContextDelegate for this connection.getWebServiceContextDelegate in class WSHTTPConnectionpublic Principal getUserPrincipal(Packet p)
WebServiceContextDelegateWebServiceContext.getUserPrincipal()
for the given packet.getUserPrincipal in interface WebServiceContextDelegatep - Always non-null. See class javadoc.WebServiceContext.getUserPrincipal()public boolean isUserInRole(Packet p, String role)
WebServiceContextDelegateWebServiceContext.isUserInRole(String)
for the given packet.isUserInRole in interface WebServiceContextDelegatep - Always non-null. See class javadoc.WebServiceContext.isUserInRole(String)@NotNull public String getEPRAddress(Packet p, WSEndpoint endpoint)
WebServiceContextDelegateThe "address" of endpoints is always affected by a particular client being served, hence it's up to transport to provide this information.
getEPRAddress in interface WebServiceContextDelegatep - Always non-null. See class javadoc.endpoint - The endpoint whose address will be returned.WebServiceContext.getEndpointReference(org.w3c.dom.Element...)public String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint)
WebServiceContextDelegate
If a transport supports publishing of WSDL by itself (instead/in addition to MEX),
then it should implement this method so that the rest of the JAX-WS RI can
use that information.
For example, HTTP transports often use the convention getEPRAddress()+"?wsdl"
for publishing WSDL on HTTP.
Some transports may not have such WSDL publishing mechanism on its own.
Those transports may choose to return null, indicating that WSDL
is not published. If such transports are always used in conjunction with
other transports that support WSDL publishing (such as SOAP/TCP used
with Servlet transport), then such transport may
choose to find the corresponding servlet endpoint by Module.getBoundEndpoints()
and try to obtain the address from there.
This information is used to put a metadata reference inside an EPR, among other things. Clients that do not support MEX rely on this WSDL URL to retrieve metadata, it is desirable for transports to support this, but not mandatory.
This method will be never invoked if the WSEndpoint
does not have a corresponding WSDL to begin with
(IOW returning null.
getWSDLAddress in interface WebServiceContextDelegaterequest - Always non-null. See class javadoc.endpoint - The endpoint whose address will be returned.@NotNull public String getRequestMethod()
WSHTTPConnectiongetRequestMethod in class WSHTTPConnectionpublic boolean isSecure()
WSHTTPConnectionisSecure in class WSHTTPConnectionpublic Principal getUserPrincipal()
WSHTTPConnectiongetUserPrincipal in class WSHTTPConnectionpublic boolean isUserInRole(String role)
WSHTTPConnectionisUserInRole in class WSHTTPConnectionrole - Role to checkpublic String getRequestHeader(String headerName)
WSHTTPConnectionif multiple headers are present, this method returns one of them. (The implementation is free to choose which one it returns.)
getRequestHeader in class WSHTTPConnectionpublic String getQueryString()
WSHTTPConnectiongetQueryString in class WSHTTPConnection@NotNull public String getPathInfo()
WSHTTPConnectiongetPathInfo in class WSHTTPConnection@NotNull public String getRequestURI()
WSHTTPConnectiongetRequestURI in class WSHTTPConnection@NotNull public String getRequestScheme()
WSHTTPConnectiongetRequestScheme in class WSHTTPConnection@NotNull public String getServerName()
WSHTTPConnectiongetServerName in class WSHTTPConnection@NotNull public int getServerPort()
WSHTTPConnectiongetServerPort in class WSHTTPConnection@NotNull public String getContextPath()
WSHTTPConnectiongetContextPath in class WSHTTPConnection@NotNull public String getBaseAddress()
WSHTTPConnectiongetBaseAddress in class WSHTTPConnection@NotNull static String getBaseAddress(javax.servlet.http.HttpServletRequest request)
public Object getRequestAttribute(String key)
WSHTTPConnectiongetRequestAttribute in class WSHTTPConnectionkey - Request metadata keypublic javax.servlet.ServletContext getContext()
WSHTTPConnectiongetContext in class WSHTTPConnectionpublic javax.servlet.http.HttpServletResponse getResponse()
public javax.servlet.http.HttpServletRequest getRequest()
public String getRequestURL()
public String getProtocol()
WSHTTPConnectiongetProtocol in class WSHTTPConnectionpublic void setContentLengthResponseHeader(int value)
WSHTTPConnectionsetContentLengthResponseHeader in class WSHTTPConnectionpublic String getCookie(String name)
WSHTTPConnectiongetCookie in class WSHTTPConnectionpublic void setCookie(String name, String value)
WSHTTPConnectionsetCookie in class WSHTTPConnectionpublic HaInfo getHaInfo()
public void setHaInfo(HaInfo replicaInfo)
protected org.jvnet.ws.message.BasePropertySet.PropertyMap getPropertyMap()
org.jvnet.ws.message.BasePropertySetProperty.
Model of PropertySet class.
At the end of the derivation chain this method just needs to be implemented as:
private static final PropertyMap model;
static {
model = parse(MyDerivedClass.class);
}
protected PropertyMap getPropertyMap() {
return model;
}
getPropertyMap in class org.jvnet.ws.message.BasePropertySetCopyright (c) 1997-2012 Oracle and/or its affiliates. All rights reserved.