Class AbstractBayeuxContext
java.lang.Object
org.cometd.websocket.server.common.AbstractBayeuxContext
- All Implemented Interfaces:
BayeuxContext
public abstract class AbstractBayeuxContext extends Object implements BayeuxContext
-
Constructor Summary
Constructors Constructor Description AbstractBayeuxContext(javax.servlet.ServletContext context, String uri, String query, Map<String,List<String>> headers, Map<String,List<String>> parameters, Principal principal, javax.servlet.http.HttpSession session, InetSocketAddress local, InetSocketAddress remote, List<Locale> locales)
-
Method Summary
Modifier and Type Method Description Object
getContextAttribute(String name)
Access the ServletContext (if any) attributes.String
getContextInitParameter(String name)
Access the ServletContext (if any) init parameter.String
getCookie(String name)
Get a transport cookie.String
getHeader(String name)
Get a transport header.List<String>
getHeaderValues(String name)
Get a multi valued transport header.Object
getHttpSessionAttribute(String name)
Access the HTTP Session (if any) attributes.String
getHttpSessionId()
Access the HTTP Session (if any) ID.InetSocketAddress
getLocalAddress()
List<Locale>
getLocales()
String
getParameter(String name)
Get a transport parameter.List<String>
getParameterValues(String name)
Get a multi valued transport parameter.InetSocketAddress
getRemoteAddress()
Object
getRequestAttribute(String name)
Access the Request (if any) attributes.String
getURL()
Principal
getUserPrincipal()
void
invalidateHttpSession()
Invalidate the HTTP Session.boolean
isUserInRole(String role)
void
setHttpSessionAttribute(String name, Object value)
Access the HTTP Session (if any) attributes.
-
Constructor Details
-
AbstractBayeuxContext
public AbstractBayeuxContext(javax.servlet.ServletContext context, String uri, String query, Map<String,List<String>> headers, Map<String,List<String>> parameters, Principal principal, javax.servlet.http.HttpSession session, InetSocketAddress local, InetSocketAddress remote, List<Locale> locales)
-
-
Method Details
-
getURL
- Specified by:
getURL
in interfaceBayeuxContext
- Returns:
- the full request URI complete with query string if present.
-
getHeader
Description copied from interface:BayeuxContext
Get a transport header.Get a header for any current transport mechanism (eg HTTP request). For transports like websocket, the header may be from the initial handshake.
- Specified by:
getHeader
in interfaceBayeuxContext
- Parameters:
name
- The name of the header- Returns:
- The header value or null if no current transport mechanism or no such header.
-
getHeaderValues
Description copied from interface:BayeuxContext
Get a multi valued transport header.Get a header for any current transport mechanism (eg HTTP request). For transports like websocket, the header may be from the initial handshake.
- Specified by:
getHeaderValues
in interfaceBayeuxContext
- Parameters:
name
- The name of the header- Returns:
- The header value or null if no current transport mechanism or no such header.
-
getParameter
Description copied from interface:BayeuxContext
Get a transport parameter.Get a parameter for any current transport mechanism (eg HTTP request). For transports like websocket, the parameter may be from the initial handshake.
- Specified by:
getParameter
in interfaceBayeuxContext
- Parameters:
name
- The name of the parameter- Returns:
- The parameter value or null if no current transport mechanism or no such parameter.
-
getParameterValues
Description copied from interface:BayeuxContext
Get a multi valued transport parameter.Get a parameter for any current transport mechanism (eg HTTP request). For transports like websocket, the parameter may be from the initial handshake.
- Specified by:
getParameterValues
in interfaceBayeuxContext
- Parameters:
name
- The name of the parameter- Returns:
- The parameter value or null if no current transport mechanism or no such parameter.
-
getUserPrincipal
- Specified by:
getUserPrincipal
in interfaceBayeuxContext
- Returns:
- The user Principal (if any)
-
isUserInRole
- Specified by:
isUserInRole
in interfaceBayeuxContext
- Parameters:
role
- the role to check whether the user belongs to- Returns:
- true if there is a known user and they are in the given role.
-
getHttpSessionId
Description copied from interface:BayeuxContext
Access the HTTP Session (if any) ID. TheSession.getId()
should be used in preference to the HTTP Session.- Specified by:
getHttpSessionId
in interfaceBayeuxContext
- Returns:
- HTTP session ID or null
-
getHttpSessionAttribute
Description copied from interface:BayeuxContext
Access the HTTP Session (if any) attributes. TheSession.getAttribute(String)
should be used in preference to the HTTP Session.- Specified by:
getHttpSessionAttribute
in interfaceBayeuxContext
- Parameters:
name
- the attribute name- Returns:
- The attribute value
-
setHttpSessionAttribute
Description copied from interface:BayeuxContext
Access the HTTP Session (if any) attributes. TheSession.setAttribute(String, Object)
should be used in preference to the HTTP Session.- Specified by:
setHttpSessionAttribute
in interfaceBayeuxContext
- Parameters:
name
- the attribute namevalue
- the attribute value
-
invalidateHttpSession
public void invalidateHttpSession()Description copied from interface:BayeuxContext
Invalidate the HTTP Session. TheSession.getId()
should be used in preference to the HTTP Session.- Specified by:
invalidateHttpSession
in interfaceBayeuxContext
-
getRemoteAddress
- Specified by:
getRemoteAddress
in interfaceBayeuxContext
- Returns:
- the remote socket address
-
getLocalAddress
- Specified by:
getLocalAddress
in interfaceBayeuxContext
- Returns:
- the local socket address
-
getLocales
- Specified by:
getLocales
in interfaceBayeuxContext
- Returns:
- the request Locales, in order of preference, or the default server Locale if the request Locales are missing.
-
getCookie
Description copied from interface:BayeuxContext
Get a transport cookie.Get a cookie for any current transport mechanism (eg HTTP request). For transports like websocket, the cookie may be from the initial handshake.
- Specified by:
getCookie
in interfaceBayeuxContext
- Parameters:
name
- The name of the cookie- Returns:
- The cookie value or null if no current transport mechanism or no such cookie.
-
getRequestAttribute
Description copied from interface:BayeuxContext
Access the Request (if any) attributes.- Specified by:
getRequestAttribute
in interfaceBayeuxContext
- Parameters:
name
- the attribute name- Returns:
- The attribute value
-
getContextAttribute
Description copied from interface:BayeuxContext
Access the ServletContext (if any) attributes.- Specified by:
getContextAttribute
in interfaceBayeuxContext
- Parameters:
name
- the attribute name- Returns:
- The attribute value
-
getContextInitParameter
Description copied from interface:BayeuxContext
Access the ServletContext (if any) init parameter.- Specified by:
getContextInitParameter
in interfaceBayeuxContext
- Parameters:
name
- the init parameter name- Returns:
- The attribute value
-