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
WSHTTPConnectionimplemented 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 StringgetBaseAddress()Gets the absolute URL up to the context path.jakarta.servlet.ServletContextgetContext()Environment specific context , if availableStringgetContextPath()Portion of the request URI that groups related service addresses.StringgetCookie(String name)Subclasses are expected to overrideStringgetEPRAddress(Packet p, WSEndpoint endpoint)Gets the address of the endpoint.HaInfogetHaInfo()InputStreamgetInput()Transport's underlying input stream.OutputStreamgetOutput()Transport's underlying output streamStringgetPathInfo()Extra portion of the request URI after the end of the expected address of the service but before the query stringprotected BasePropertySet.PropertyMapgetPropertyMap()Map representing the Fields and Methods annotated withPropertySet.Property.StringgetProtocol()Subclasses are expected to overrideStringgetQueryString()HTTP Query string, such as "foo=bar", or null if none exists.jakarta.servlet.http.HttpServletRequestgetRequest()ObjectgetRequestAttribute(String key)Gets request metadata attributeStringgetRequestHeader(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.StringgetRequestMethod()HTTP request method, such as "GET" or "POST".StringgetRequestScheme()Requested scheme, e.g.StringgetRequestURI()Requested path.StringgetRequestURL()jakarta.servlet.http.HttpServletResponsegetResponse()Map<String,List<String>>getResponseHeaders()StringgetServerName()Server nameintgetServerPort()Server portintgetStatus()Gets the last value set byWSHTTPConnection.setStatus(int).PrincipalgetUserPrincipal()User principal associated with the requestPrincipalgetUserPrincipal(Packet p)ImplementsWebServiceContext.getUserPrincipal()for the given packet.WebServiceContextDelegategetWebServiceContextDelegate()Returns theWebServiceContextDelegatefor this connection.StringgetWSDLAddress(Packet request, WSEndpoint endpoint)Gets the address of the primary WSDL.booleanisSecure()Whether connection is HTTPS or notbooleanisUserInRole(Packet p, String role)ImplementsWebServiceContext.isUserInRole(String)for the given packet.booleanisUserInRole(String role)Whether user associated with the request holds the given rolevoidsetContentLengthResponseHeader(int value)Subclasses are expected to overridevoidsetContentTypeResponseHeader(String value)Sets the"Content-Type"header.voidsetCookie(String name, String value)Subclasses are expected to overridevoidsetHaInfo(HaInfo replicaInfo)voidsetResponseHeader(String key, String value)voidsetResponseHeader(String key, List<String> value)voidsetResponseHeaders(Map<String,List<String>> headers)sets response headers.voidsetStatus(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:WSHTTPConnectionHTTP request headers.- Specified by:
getRequestHeadersin classWSHTTPConnection- Returns:
- can be empty but never null.
-
getRequestHeaderNames
public Set<String> getRequestHeaderNames()
Description copied from class:WSHTTPConnectionHTTP request header names.- Specified by:
getRequestHeaderNamesin classWSHTTPConnection- Returns:
- can be empty but never null.
-
getRequestHeaderValues
public List<String> getRequestHeaderValues(@NotNull String headerName)
Description copied from class:WSHTTPConnectionGets an HTTP request header.- Specified by:
getRequestHeaderValuesin classWSHTTPConnection- Returns:
- null if no header exists.
-
setResponseHeaders
public void setResponseHeaders(Map<String,List<String>> headers)
sets response headers.- Specified by:
setResponseHeadersin 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:
setResponseHeaderin classWSHTTPConnection
-
setResponseHeader
public void setResponseHeader(String key, List<String> value)
- Specified by:
setResponseHeaderin classWSHTTPConnection
-
getResponseHeaders
public Map<String,List<String>> getResponseHeaders()
- Specified by:
getResponseHeadersin classWSHTTPConnection- Returns:
- HTTP response headers.
-
setStatus
public void setStatus(int status)
Description copied from class:WSHTTPConnectionSets 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:
setStatusin classWSHTTPConnection
-
getStatus
public int getStatus()
Description copied from class:WSHTTPConnectionGets the last value set byWSHTTPConnection.setStatus(int).- Specified by:
getStatusin classWSHTTPConnection- Returns:
- if
WSHTTPConnection.setStatus(int)has not been invoked yet, return 0.
-
setContentTypeResponseHeader
public void setContentTypeResponseHeader(@NotNull String value)Description copied from class:WSHTTPConnectionSets 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:
setContentTypeResponseHeaderin classWSHTTPConnection- Parameters:
value- strings like"application/xml; charset=UTF-8"or"image/jpeg".
-
getInput
@NotNull public InputStream getInput() throws IOException
Description copied from class:WSHTTPConnectionTransport'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:
getInputin 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:WSHTTPConnectionTransport'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:
getOutputin classWSHTTPConnection- Throws:
IOException
-
getWebServiceContextDelegate
@NotNull public WebServiceContextDelegate getWebServiceContextDelegate()
Description copied from class:WSHTTPConnectionReturns theWebServiceContextDelegatefor this connection.- Specified by:
getWebServiceContextDelegatein classWSHTTPConnection
-
getUserPrincipal
public Principal getUserPrincipal(Packet p)
Description copied from interface:WebServiceContextDelegateImplementsWebServiceContext.getUserPrincipal()for the given packet.- Specified by:
getUserPrincipalin 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:WebServiceContextDelegateImplementsWebServiceContext.isUserInRole(String)for the given packet.- Specified by:
isUserInRolein 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:WebServiceContextDelegateGets 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:
getEPRAddressin 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:WebServiceContextDelegateGets 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
WSEndpointdoes not have a corresponding WSDL to begin with (IOWreturning null.- Specified by:
getWSDLAddressin 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:WSHTTPConnectionHTTP request method, such as "GET" or "POST".- Specified by:
getRequestMethodin classWSHTTPConnection
-
isSecure
public boolean isSecure()
Description copied from class:WSHTTPConnectionWhether connection is HTTPS or not- Specified by:
isSecurein classWSHTTPConnection- Returns:
- if the received request is on HTTPS, return true else false
-
getUserPrincipal
public Principal getUserPrincipal()
Description copied from class:WSHTTPConnectionUser principal associated with the request- Overrides:
getUserPrincipalin classWSHTTPConnection- Returns:
- user principal
-
isUserInRole
public boolean isUserInRole(String role)
Description copied from class:WSHTTPConnectionWhether user associated with the request holds the given role- Overrides:
isUserInRolein classWSHTTPConnection- Parameters:
role- Role to check- Returns:
- if the caller holds the role
-
getRequestHeader
public String getRequestHeader(String headerName)
Description copied from class:WSHTTPConnectionGets 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:
getRequestHeaderin classWSHTTPConnection- Returns:
- null if no header exists.
-
getQueryString
public String getQueryString()
Description copied from class:WSHTTPConnectionHTTP Query string, such as "foo=bar", or null if none exists.- Specified by:
getQueryStringin classWSHTTPConnection
-
getPathInfo
@NotNull public String getPathInfo()
Description copied from class:WSHTTPConnectionExtra portion of the request URI after the end of the expected address of the service but before the query string- Specified by:
getPathInfoin classWSHTTPConnection
-
getRequestURI
@NotNull public String getRequestURI()
Description copied from class:WSHTTPConnectionRequested path. A string like "/foo/bar/baz"- Specified by:
getRequestURIin classWSHTTPConnection
-
getRequestScheme
@NotNull public String getRequestScheme()
Description copied from class:WSHTTPConnectionRequested scheme, e.g. "http" or "https"- Specified by:
getRequestSchemein classWSHTTPConnection
-
getServerName
@NotNull public String getServerName()
Description copied from class:WSHTTPConnectionServer name- Specified by:
getServerNamein classWSHTTPConnection
-
getServerPort
@NotNull public int getServerPort()
Description copied from class:WSHTTPConnectionServer port- Specified by:
getServerPortin classWSHTTPConnection
-
getContextPath
@NotNull public String getContextPath()
Description copied from class:WSHTTPConnectionPortion 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:
getContextPathin classWSHTTPConnection
-
getBaseAddress
@NotNull public String getBaseAddress()
Description copied from class:WSHTTPConnectionGets the absolute URL up to the context path.- Overrides:
getBaseAddressin classWSHTTPConnection- Returns:
- String like "http://myhost/myapp"
-
getRequestAttribute
public Object getRequestAttribute(String key)
Description copied from class:WSHTTPConnectionGets request metadata attribute- Overrides:
getRequestAttributein 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:WSHTTPConnectionEnvironment specific context , if available- Overrides:
getContextin 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:WSHTTPConnectionSubclasses are expected to override- Overrides:
getProtocolin classWSHTTPConnection- Returns:
- a
Stringcontaining the protocol name and version number
-
setContentLengthResponseHeader
public void setContentLengthResponseHeader(int value)
Description copied from class:WSHTTPConnectionSubclasses are expected to override- Overrides:
setContentLengthResponseHeaderin classWSHTTPConnection
-
getCookie
public String getCookie(String name)
Description copied from class:WSHTTPConnectionSubclasses are expected to override- Overrides:
getCookiein classWSHTTPConnection- Returns:
- value of given cookie
-
setCookie
public void setCookie(String name, String value)
Description copied from class:WSHTTPConnectionSubclasses are expected to override- Overrides:
setCookiein classWSHTTPConnection
-
getHaInfo
public HaInfo getHaInfo()
-
setHaInfo
public void setHaInfo(HaInfo replicaInfo)
-
getPropertyMap
protected BasePropertySet.PropertyMap getPropertyMap()
Description copied from class:BasePropertySetMap representing the Fields and Methods annotated withPropertySet.Property. Model ofPropertySetclass.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:
getPropertyMapin classBasePropertySet- Returns:
- the map of strongly-typed known properties keyed by property names
-
-