Package org.apache.wicket.protocol.ws
Class WebSocketSettings
- java.lang.Object
-
- org.apache.wicket.protocol.ws.WebSocketSettings
-
public class WebSocketSettings extends Object
Web Socket related settings. More documentation is available about each setting in the setter method for the property.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WebSocketSettings.Holder
Holds this WebSocketSettings in the Application's metadata.static class
WebSocketSettings.SameThreadExecutor
Simple executor that runs the tasks in the caller thread.static class
WebSocketSettings.ThreadFactory
static class
WebSocketSettings.WebSocketPushMessageExecutor
-
Constructor Summary
Constructors Constructor Description WebSocketSettings()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getAsynchronousPushTimeout()
CharSequence
getBaseUrl()
IWebSocketConnectionFilter
getConnectionFilter()
IWebSocketConnectionRegistry
getConnectionRegistry()
CharSequence
getContextPath()
CharSequence
getFilterPrefix()
Integer
getPort()
Integer
getSecurePort()
Executor
getSendPayloadExecutor()
The executor that broadcasts theWebSocketPayload
via Wicket's event bus.IWebSocketSessionConfigurer
getSocketSessionConfigurer()
Executor
getWebSocketPushMessageExecutor()
boolean
isAsynchronousPush()
WebRequest
newWebSocketRequest(javax.servlet.http.HttpServletRequest request, String filterPath)
A factory method for theWebRequest
that should be used in the WebSocket processing request cycleWebSocketRequestHandler
newWebSocketRequestHandler(Page page, IWebSocketConnection connection)
A factory method for creating instances ofWebSocketRequestHandler
for processing a web socket requestWebResponse
newWebSocketResponse(IWebSocketConnection connection)
A factory method for theWebResponse
that should be used to write the response back to the client/browserWebResponse
newWebSocketResponse(IWebSocketConnection connection, boolean asynchronousPush, long timeout)
A factory method for theWebResponse
that should be used to write the response back to the client/browservoid
setAsynchronousPush(boolean asynchronousPush)
void
setAsynchronousPushTimeout(long asynchronousPushTimeout)
void
setBaseUrl(CharSequence baseUrl)
void
setConnectionFilter(IWebSocketConnectionFilter connectionFilter)
Sets the filter for checking the incoming connectionsWebSocketSettings
setConnectionRegistry(IWebSocketConnectionRegistry connectionRegistry)
Sets the connection registryvoid
setContextPath(CharSequence contextPath)
void
setFilterPrefix(CharSequence filterPrefix)
void
setNotifyOnCloseEvent(Function<Integer,Boolean> notifyOnCloseEvent)
void
setNotifyOnErrorEvent(Function<Throwable,Boolean> notifyOnErrorEvent)
void
setPort(int wsPort)
Sets the port that should be used forws:
connections.void
setSecurePort(int wssPort)
Sets the port that should be used forwss:
connections.WebSocketSettings
setSendPayloadExecutor(Executor sendPayloadExecutor)
The executor that broadcasts theWebSocketPayload
via Wicket's event bus.void
setSocketSessionConfigurer(IWebSocketSessionConfigurer socketSessionConfigurer)
Sets the IWebSocketSessionConfigurerWebSocketSettings
setWebSocketPushMessageExecutor(Executor executor)
Set the executor for processing websocket push messages broadcasted to all sessions.boolean
shouldNotifyOnCloseEvent(int closeCode)
boolean
shouldNotifyOnErrorEvent(Throwable throwable)
-
-
-
Constructor Detail
-
WebSocketSettings
public WebSocketSettings()
-
-
Method Detail
-
shouldNotifyOnCloseEvent
public boolean shouldNotifyOnCloseEvent(int closeCode)
-
setNotifyOnCloseEvent
public void setNotifyOnCloseEvent(Function<Integer,Boolean> notifyOnCloseEvent)
-
shouldNotifyOnErrorEvent
public boolean shouldNotifyOnErrorEvent(Throwable throwable)
-
setNotifyOnErrorEvent
public void setNotifyOnErrorEvent(Function<Throwable,Boolean> notifyOnErrorEvent)
-
setWebSocketPushMessageExecutor
public WebSocketSettings setWebSocketPushMessageExecutor(Executor executor)
Set the executor for processing websocket push messages broadcasted to all sessions. Default executor does all the processing in the caller thread. Using a proper thread pool is adviced for applications that send push events from ajax calls to avoid page level deadlocks.- Parameters:
executor
- The executor used for processing push messages.
-
getWebSocketPushMessageExecutor
public Executor getWebSocketPushMessageExecutor()
- Returns:
- the executor for processing websocket push messages broadcasted to all sessions.
-
getConnectionRegistry
public IWebSocketConnectionRegistry getConnectionRegistry()
- Returns:
- The registry that tracks all currently connected WebSocket clients
-
setConnectionRegistry
public WebSocketSettings setConnectionRegistry(IWebSocketConnectionRegistry connectionRegistry)
Sets the connection registry- Parameters:
connectionRegistry
- The registry that tracks all currently connected WebSocket clients- Returns:
this
, for method chaining
-
setSendPayloadExecutor
public WebSocketSettings setSendPayloadExecutor(Executor sendPayloadExecutor)
The executor that broadcasts theWebSocketPayload
via Wicket's event bus. Default executor does all the processing in the caller thread.- Parameters:
sendPayloadExecutor
- The executor used for broadcasting the events with web socket payloads toWebSocketBehavior
s andWebSocketResource
s.
-
getSendPayloadExecutor
public Executor getSendPayloadExecutor()
The executor that broadcasts theWebSocketPayload
via Wicket's event bus.- Returns:
- The executor used for broadcasting the events with web socket payloads to
WebSocketBehavior
s andWebSocketResource
s.
-
setSocketSessionConfigurer
public void setSocketSessionConfigurer(IWebSocketSessionConfigurer socketSessionConfigurer)
Sets the IWebSocketSessionConfigurer- Parameters:
socketSessionConfigurer
- A non-nullIWebSocketSessionConfigurer
-
getSocketSessionConfigurer
public IWebSocketSessionConfigurer getSocketSessionConfigurer()
- Returns:
- returns the
IWebSocketSessionConfigurer
-
setConnectionFilter
public void setConnectionFilter(IWebSocketConnectionFilter connectionFilter)
Sets the filter for checking the incoming connections- Parameters:
connectionFilter
- the filter for checking the incoming connections- See Also:
WebSocketConnectionFilterCollection
-
getConnectionFilter
public IWebSocketConnectionFilter getConnectionFilter()
- Returns:
- the filter for checking the incoming connections
- See Also:
WebSocketConnectionFilterCollection
-
newWebSocketResponse
public WebResponse newWebSocketResponse(IWebSocketConnection connection)
A factory method for theWebResponse
that should be used to write the response back to the client/browser- Parameters:
connection
- The active web socket connection- Returns:
- the response object that should be used to write the response back to the client
-
newWebSocketResponse
public WebResponse newWebSocketResponse(IWebSocketConnection connection, boolean asynchronousPush, long timeout)
A factory method for theWebResponse
that should be used to write the response back to the client/browser- Parameters:
connection
- The active web socket connectionasynchronousPush
- Whether asynchronous push is wanted or not.timeout
- The timeout to be used for push operations- Returns:
- the response object that should be used to write the response back to the client
-
newWebSocketRequestHandler
public WebSocketRequestHandler newWebSocketRequestHandler(Page page, IWebSocketConnection connection)
A factory method for creating instances ofWebSocketRequestHandler
for processing a web socket request- Parameters:
page
- The page with the web socket client. A dummy page in case of usage ofWebSocketResource
connection
- The active web socket connection- Returns:
- a new instance of WebSocketRequestHandler for processing a web socket request
-
newWebSocketRequest
public WebRequest newWebSocketRequest(javax.servlet.http.HttpServletRequest request, String filterPath)
A factory method for theWebRequest
that should be used in the WebSocket processing request cycle- Parameters:
request
- The upgraded http requestfilterPath
- The configured filter path of WicketFilter in web.xml- Returns:
- the request object that should be used in the WebSocket processing request cycle
-
setFilterPrefix
public void setFilterPrefix(CharSequence filterPrefix)
-
getFilterPrefix
public CharSequence getFilterPrefix()
-
setContextPath
public void setContextPath(CharSequence contextPath)
-
getContextPath
public CharSequence getContextPath()
-
setBaseUrl
public void setBaseUrl(CharSequence baseUrl)
-
getBaseUrl
public CharSequence getBaseUrl()
-
setPort
public void setPort(int wsPort)
Sets the port that should be used forws:
connections. If unset then the current HTTP port will be used.- Parameters:
wsPort
- The custom port for WS connections
-
setSecurePort
public void setSecurePort(int wssPort)
Sets the port that should be used forwss:
connections. If unset then the current HTTPS port will be used.- Parameters:
wssPort
- The custom port for WSS connections
-
getSecurePort
public Integer getSecurePort()
- Returns:
- The custom port for WSS connections
-
setAsynchronousPush
public void setAsynchronousPush(boolean asynchronousPush)
-
isAsynchronousPush
public boolean isAsynchronousPush()
-
setAsynchronousPushTimeout
public void setAsynchronousPushTimeout(long asynchronousPushTimeout)
-
getAsynchronousPushTimeout
public long getAsynchronousPushTimeout()
-
-