Interface BayeuxContext
-
- All Known Implementing Classes:
AbstractBayeuxContext
public interface BayeuxContext
The Bayeux Context provides information about the current context of a Bayeux message.
This information may be from an associated HTTP request, or a HTTP request used to originally establish the connection (for example in a websocket handshake).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.Object
getContextAttribute(java.lang.String name)
Access the ServletContext (if any) attributes.java.lang.String
getContextInitParameter(java.lang.String name)
Access the ServletContext (if any) init parameter.java.lang.String
getContextPath()
java.lang.String
getCookie(java.lang.String name)
Get a transport cookie.java.lang.String
getHeader(java.lang.String name)
Get a transport header.java.util.List<java.lang.String>
getHeaderValues(java.lang.String name)
Get a multi valued transport header.java.lang.Object
getHttpSessionAttribute(java.lang.String name)
Access the HTTP Session (if any) attributes.java.lang.String
getHttpSessionId()
Access the HTTP Session (if any) ID.java.net.InetSocketAddress
getLocalAddress()
java.util.List<java.util.Locale>
getLocales()
java.lang.String
getParameter(java.lang.String name)
Get a transport parameter.java.util.List<java.lang.String>
getParameterValues(java.lang.String name)
Get a multi valued transport parameter.java.lang.String
getProtocol()
java.net.InetSocketAddress
getRemoteAddress()
java.lang.Object
getRequestAttribute(java.lang.String name)
Access the Request (if any) attributes.java.lang.String
getURL()
java.security.Principal
getUserPrincipal()
void
invalidateHttpSession()
Invalidate the HTTP Session.boolean
isSecure()
boolean
isUserInRole(java.lang.String role)
void
setHttpSessionAttribute(java.lang.String name, java.lang.Object value)
Access the HTTP Session (if any) attributes.
-
-
-
Method Detail
-
getUserPrincipal
java.security.Principal getUserPrincipal()
- Returns:
- The user Principal (if any)
-
isUserInRole
boolean isUserInRole(java.lang.String role)
- 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.
-
getRemoteAddress
java.net.InetSocketAddress getRemoteAddress()
- Returns:
- the remote socket address
-
getLocalAddress
java.net.InetSocketAddress getLocalAddress()
- Returns:
- the local socket address
-
getHeader
java.lang.String getHeader(java.lang.String name)
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.
- Parameters:
name
- The name of the header- Returns:
- The header value or null if no current transport mechanism or no such header.
-
getHeaderValues
java.util.List<java.lang.String> getHeaderValues(java.lang.String name)
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.
- Parameters:
name
- The name of the header- Returns:
- The header value or null if no current transport mechanism or no such header.
-
getParameter
java.lang.String getParameter(java.lang.String name)
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.
- Parameters:
name
- The name of the parameter- Returns:
- The parameter value or null if no current transport mechanism or no such parameter.
-
getParameterValues
java.util.List<java.lang.String> getParameterValues(java.lang.String name)
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.
- Parameters:
name
- The name of the parameter- Returns:
- The parameter value or null if no current transport mechanism or no such parameter.
-
getCookie
java.lang.String getCookie(java.lang.String name)
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.
- Parameters:
name
- The name of the cookie- Returns:
- The cookie value or null if no current transport mechanism or no such cookie.
-
getHttpSessionId
java.lang.String getHttpSessionId()
Access the HTTP Session (if any) ID. TheSession.getId()
should be used in preference to the HTTP Session.- Returns:
- HTTP session ID or null
-
getHttpSessionAttribute
java.lang.Object getHttpSessionAttribute(java.lang.String name)
Access the HTTP Session (if any) attributes. TheSession.getAttribute(String)
should be used in preference to the HTTP Session.- Parameters:
name
- the attribute name- Returns:
- The attribute value
-
setHttpSessionAttribute
void setHttpSessionAttribute(java.lang.String name, java.lang.Object value)
Access the HTTP Session (if any) attributes. TheSession.setAttribute(String, Object)
should be used in preference to the HTTP Session.- Parameters:
name
- the attribute namevalue
- the attribute value
-
invalidateHttpSession
void invalidateHttpSession()
Invalidate the HTTP Session. TheSession.getId()
should be used in preference to the HTTP Session.
-
getRequestAttribute
java.lang.Object getRequestAttribute(java.lang.String name)
Access the Request (if any) attributes.- Parameters:
name
- the attribute name- Returns:
- The attribute value
-
getContextAttribute
java.lang.Object getContextAttribute(java.lang.String name)
Access the ServletContext (if any) attributes.- Parameters:
name
- the attribute name- Returns:
- The attribute value
-
getContextInitParameter
java.lang.String getContextInitParameter(java.lang.String name)
Access the ServletContext (if any) init parameter.- Parameters:
name
- the init parameter name- Returns:
- The attribute value
-
getContextPath
java.lang.String getContextPath()
- Returns:
- the application context path
-
getURL
java.lang.String getURL()
- Returns:
- the full request URI complete with query string if present.
-
getLocales
java.util.List<java.util.Locale> getLocales()
- Returns:
- the request Locales, in order of preference, or the default server Locale if the request Locales are missing.
-
getProtocol
java.lang.String getProtocol()
- Returns:
- a string containing the protocol name and version number
-
isSecure
boolean isSecure()
- Returns:
- whether the request was made over a secure channel
-
-