Class ServletConnectionImpl
- java.lang.Object
-
- com.oracle.webservices.api.message.BasePropertySet
-
- com.sun.xml.ws.transport.http.WSHTTPConnection
-
- com.sun.xml.ws.transport.http.servlet.ServletConnectionImpl
-
- All Implemented Interfaces:
PropertySet
,WebServiceContextDelegate
public class ServletConnectionImpl extends WSHTTPConnection implements WebServiceContextDelegate
WSHTTPConnection
implemented forHttpServlet
.- Author:
- WS Development Team
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.oracle.webservices.api.message.BasePropertySet
BasePropertySet.Accessor, BasePropertySet.PropertyMap, BasePropertySet.PropertyMapEntry
-
Nested classes/interfaces inherited from interface com.oracle.webservices.api.message.PropertySet
PropertySet.Property
-
-
Field Summary
-
Fields inherited from class com.sun.xml.ws.transport.http.WSHTTPConnection
INTERNAL_ERR, MALFORMED_XML, OK, ONEWAY, UNSUPPORTED_MEDIA
-
-
Constructor Summary
Constructors Constructor Description ServletConnectionImpl(ServletAdapter adapter, jakarta.servlet.ServletContext context, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getBaseAddress()
Gets the absolute URL up to the context path.jakarta.servlet.ServletContext
getContext()
Environment specific context , if availableString
getContextPath()
Portion of the request URI that groups related service addresses.String
getCookie(String name)
Subclasses are expected to overrideString
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 streamString
getPathInfo()
Extra portion of the request URI after the end of the expected address of the service but before the query stringprotected BasePropertySet.PropertyMap
getPropertyMap()
Map representing the Fields and Methods annotated withPropertySet.Property
.String
getProtocol()
Subclasses are expected to overrideString
getQueryString()
HTTP Query string, such as "foo=bar", or null if none exists.jakarta.servlet.http.HttpServletRequest
getRequest()
Object
getRequestAttribute(String key)
Gets request metadata attributeString
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()
jakarta.servlet.http.HttpServletResponse
getResponse()
Map<String,List<String>>
getResponseHeaders()
String
getServerName()
Server nameint
getServerPort()
Server portint
getStatus()
Gets the last value set byWSHTTPConnection.setStatus(int)
.Principal
getUserPrincipal()
User principal associated with the requestPrincipal
getUserPrincipal(Packet p)
ImplementsWebServiceContext.getUserPrincipal()
for the given packet.WebServiceContextDelegate
getWebServiceContextDelegate()
Returns theWebServiceContextDelegate
for this connection.String
getWSDLAddress(Packet request, WSEndpoint endpoint)
Gets the address of the primary WSDL.boolean
isSecure()
Whether connection is HTTPS or notboolean
isUserInRole(Packet p, String role)
ImplementsWebServiceContext.isUserInRole(String)
for the given packet.boolean
isUserInRole(String role)
Whether user associated with the request holds the given rolevoid
setContentLengthResponseHeader(int value)
Subclasses are expected to overridevoid
setContentTypeResponseHeader(String value)
Sets the"Content-Type"
header.void
setCookie(String name, String value)
Subclasses are expected to overridevoid
setHaInfo(HaInfo replicaInfo)
void
setResponseHeader(String key, String value)
void
setResponseHeader(String key, List<String> value)
void
setResponseHeaders(Map<String,List<String>> headers)
sets response headers.void
setStatus(int status)
Sets the HTTP response code likeWSHTTPConnection.OK
.-
Methods inherited from class com.sun.xml.ws.transport.http.WSHTTPConnection
close, isClosed
-
Methods inherited from class com.oracle.webservices.api.message.BasePropertySet
asMap, containsKey, createEntrySet, createMapView, createView, get, mapAllowsAdditionalProperties, parse, parse, put, remove, supports
-
-
-
-
Constructor Detail
-
ServletConnectionImpl
public ServletConnectionImpl(@NotNull ServletAdapter adapter, jakarta.servlet.ServletContext context, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
-
-
Method Detail
-
getRequestHeaders
@NotNull public Map<String,List<String>> getRequestHeaders()
Description copied from class:WSHTTPConnection
HTTP request headers.- Specified by:
getRequestHeaders
in classWSHTTPConnection
- Returns:
- can be empty but never null.
-
getRequestHeaderNames
public Set<String> getRequestHeaderNames()
Description copied from class:WSHTTPConnection
HTTP request header names.- Specified by:
getRequestHeaderNames
in classWSHTTPConnection
- Returns:
- can be empty but never null.
-
getRequestHeaderValues
public List<String> getRequestHeaderValues(@NotNull String headerName)
Description copied from class:WSHTTPConnection
Gets an HTTP request header.- Specified by:
getRequestHeaderValues
in classWSHTTPConnection
- Returns:
- null if no header exists.
-
setResponseHeaders
public void setResponseHeaders(Map<String,List<String>> headers)
sets response headers.- Specified by:
setResponseHeaders
in classWSHTTPConnection
- Parameters:
headers
- SeeURLConnection.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.- See Also:
WSHTTPConnection.setContentTypeResponseHeader(String)
-
setResponseHeader
public void setResponseHeader(String key, String value)
- Overrides:
setResponseHeader
in classWSHTTPConnection
-
setResponseHeader
public void setResponseHeader(String key, List<String> value)
- Specified by:
setResponseHeader
in classWSHTTPConnection
-
getResponseHeaders
public Map<String,List<String>> getResponseHeaders()
- Specified by:
getResponseHeaders
in classWSHTTPConnection
- Returns:
- HTTP response headers.
-
setStatus
public void setStatus(int status)
Description copied from class:WSHTTPConnection
Sets the HTTP response code likeWSHTTPConnection.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 untilWSHTTPConnection.getOutput()
is invoked.- Specified by:
setStatus
in classWSHTTPConnection
-
getStatus
public int getStatus()
Description copied from class:WSHTTPConnection
Gets the last value set byWSHTTPConnection.setStatus(int)
.- Specified by:
getStatus
in classWSHTTPConnection
- Returns:
- if
WSHTTPConnection.setStatus(int)
has not been invoked yet, return 0.
-
setContentTypeResponseHeader
public void setContentTypeResponseHeader(@NotNull String value)
Description copied from class:WSHTTPConnection
Sets the"Content-Type"
header.If 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
WSHTTPConnection.setResponseHeaders(java.util.Map)
may be invoked in any arbitrary order.- Specified by:
setContentTypeResponseHeader
in classWSHTTPConnection
- Parameters:
value
- strings like"application/xml; charset=UTF-8"
or"image/jpeg"
.
-
getInput
@NotNull public InputStream getInput() throws IOException
Description copied from class:WSHTTPConnection
Transport's underlying input stream.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
.- Specified by:
getInput
in classWSHTTPConnection
- Returns:
- the stream from which the request body will be read.
- Throws:
IOException
-
getOutput
@NotNull public OutputStream getOutput() throws IOException
Description copied from class:WSHTTPConnection
Transport's underlying output streamThis 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>>)
, andWSHTTPConnection.setContentTypeResponseHeader(String)
will never be invoked.- Specified by:
getOutput
in classWSHTTPConnection
- Throws:
IOException
-
getWebServiceContextDelegate
@NotNull public WebServiceContextDelegate getWebServiceContextDelegate()
Description copied from class:WSHTTPConnection
Returns theWebServiceContextDelegate
for this connection.- Specified by:
getWebServiceContextDelegate
in classWSHTTPConnection
-
getUserPrincipal
public Principal getUserPrincipal(Packet p)
Description copied from interface:WebServiceContextDelegate
ImplementsWebServiceContext.getUserPrincipal()
for the given packet.- Specified by:
getUserPrincipal
in interfaceWebServiceContextDelegate
- Parameters:
p
- Always non-null. See class javadoc.- See Also:
WebServiceContext.getUserPrincipal()
-
isUserInRole
public boolean isUserInRole(Packet p, String role)
Description copied from interface:WebServiceContextDelegate
ImplementsWebServiceContext.isUserInRole(String)
for the given packet.- Specified by:
isUserInRole
in interfaceWebServiceContextDelegate
- Parameters:
p
- Always non-null. See class javadoc.- See Also:
WebServiceContext.isUserInRole(String)
-
getEPRAddress
@NotNull public String getEPRAddress(Packet p, WSEndpoint endpoint)
Description copied from interface:WebServiceContextDelegate
Gets the address of the endpoint.The "address" of endpoints is always affected by a particular client being served, hence it's up to transport to provide this information.
- Specified by:
getEPRAddress
in interfaceWebServiceContextDelegate
- Parameters:
p
- Always non-null. See class javadoc.endpoint
- The endpoint whose address will be returned.- Returns:
- Absolute URL of the endpoint. This shold be an address that the client can use to talk back to this same service later.
- See Also:
WebServiceContext.getEndpointReference(org.w3c.dom.Element...)
-
getWSDLAddress
public String getWSDLAddress(@NotNull Packet request, @NotNull WSEndpoint endpoint)
Description copied from interface:WebServiceContextDelegate
Gets the address of the primary WSDL.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 (IOWreturning null
.- Specified by:
getWSDLAddress
in interfaceWebServiceContextDelegate
- Parameters:
request
- Always non-null. See class javadoc.endpoint
- The endpoint whose address will be returned.- Returns:
- null if the implementation does not support the notion of WSDL publishing.
-
getRequestMethod
@NotNull public String getRequestMethod()
Description copied from class:WSHTTPConnection
HTTP request method, such as "GET" or "POST".- Specified by:
getRequestMethod
in classWSHTTPConnection
-
isSecure
public boolean isSecure()
Description copied from class:WSHTTPConnection
Whether connection is HTTPS or not- Specified by:
isSecure
in classWSHTTPConnection
- Returns:
- if the received request is on HTTPS, return true else false
-
getUserPrincipal
public Principal getUserPrincipal()
Description copied from class:WSHTTPConnection
User principal associated with the request- Overrides:
getUserPrincipal
in classWSHTTPConnection
- Returns:
- user principal
-
isUserInRole
public boolean isUserInRole(String role)
Description copied from class:WSHTTPConnection
Whether user associated with the request holds the given role- Overrides:
isUserInRole
in classWSHTTPConnection
- Parameters:
role
- Role to check- Returns:
- if the caller holds the role
-
getRequestHeader
public String getRequestHeader(String headerName)
Description copied from class:WSHTTPConnection
Gets an HTTP request header.if multiple headers are present, this method returns one of them. (The implementation is free to choose which one it returns.)
- Specified by:
getRequestHeader
in classWSHTTPConnection
- Returns:
- null if no header exists.
-
getQueryString
public String getQueryString()
Description copied from class:WSHTTPConnection
HTTP Query string, such as "foo=bar", or null if none exists.- Specified by:
getQueryString
in classWSHTTPConnection
-
getPathInfo
@NotNull public String getPathInfo()
Description copied from class:WSHTTPConnection
Extra portion of the request URI after the end of the expected address of the service but before the query string- Specified by:
getPathInfo
in classWSHTTPConnection
-
getRequestURI
@NotNull public String getRequestURI()
Description copied from class:WSHTTPConnection
Requested path. A string like "/foo/bar/baz"- Specified by:
getRequestURI
in classWSHTTPConnection
-
getRequestScheme
@NotNull public String getRequestScheme()
Description copied from class:WSHTTPConnection
Requested scheme, e.g. "http" or "https"- Specified by:
getRequestScheme
in classWSHTTPConnection
-
getServerName
@NotNull public String getServerName()
Description copied from class:WSHTTPConnection
Server name- Specified by:
getServerName
in classWSHTTPConnection
-
getServerPort
@NotNull public int getServerPort()
Description copied from class:WSHTTPConnection
Server port- Specified by:
getServerPort
in classWSHTTPConnection
-
getContextPath
@NotNull public String getContextPath()
Description copied from class:WSHTTPConnection
Portion of the request URI that groups related service addresses. The value, if non-empty, will always begin with '/', but will never end with '/'. Environments that do not support context paths must return an empty string.- Overrides:
getContextPath
in classWSHTTPConnection
-
getBaseAddress
@NotNull public String getBaseAddress()
Description copied from class:WSHTTPConnection
Gets the absolute URL up to the context path.- Overrides:
getBaseAddress
in classWSHTTPConnection
- Returns:
- String like "http://myhost/myapp"
-
getRequestAttribute
public Object getRequestAttribute(String key)
Description copied from class:WSHTTPConnection
Gets request metadata attribute- Overrides:
getRequestAttribute
in classWSHTTPConnection
- Parameters:
key
- Request metadata key- Returns:
- Value of metadata attribute or null, if no value present
-
getContext
public jakarta.servlet.ServletContext getContext()
Description copied from class:WSHTTPConnection
Environment specific context , if available- Overrides:
getContext
in classWSHTTPConnection
-
getResponse
public jakarta.servlet.http.HttpServletResponse getResponse()
-
getRequest
public jakarta.servlet.http.HttpServletRequest getRequest()
-
getRequestURL
public String getRequestURL()
-
getProtocol
public String getProtocol()
Description copied from class:WSHTTPConnection
Subclasses are expected to override- Overrides:
getProtocol
in classWSHTTPConnection
- Returns:
- a
String
containing the protocol name and version number
-
setContentLengthResponseHeader
public void setContentLengthResponseHeader(int value)
Description copied from class:WSHTTPConnection
Subclasses are expected to override- Overrides:
setContentLengthResponseHeader
in classWSHTTPConnection
-
getCookie
public String getCookie(String name)
Description copied from class:WSHTTPConnection
Subclasses are expected to override- Overrides:
getCookie
in classWSHTTPConnection
- Returns:
- value of given cookie
-
setCookie
public void setCookie(String name, String value)
Description copied from class:WSHTTPConnection
Subclasses are expected to override- Overrides:
setCookie
in classWSHTTPConnection
-
getHaInfo
public HaInfo getHaInfo()
-
setHaInfo
public void setHaInfo(HaInfo replicaInfo)
-
getPropertyMap
protected BasePropertySet.PropertyMap getPropertyMap()
Description copied from class:BasePropertySet
Map representing the Fields and Methods annotated withPropertySet.Property
. Model ofPropertySet
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; }
or if the implementation is in different Java module.private static final PropertyMap model; static { model = parse(MyDerivedClass.class, MethodHandles.lookup()); } protected PropertyMap getPropertyMap() { return model; }
- Specified by:
getPropertyMap
in classBasePropertySet
- Returns:
- the map of strongly-typed known properties keyed by property names
-
-