Top Description Inners Fields Constructors Methods
com.sun.faces.push

public Class WebsocketChannelManager

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@SessionScoped
Static Imports
com.sun.faces.cdi.CdiUtils.getBeanInstance, com.sun.faces.push.WebsocketUserManager.getUserChannels, java.util.Collections.emptyMap

This web socket channel manager holds all application and session scoped web socket channel identifiers registered by <f:websocket>.

Author
Bauke Scholtz
Since
2.3
See Also
Push

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
public static class
WebsocketChannelManager.ViewScope

This helps the web socket channel manager to hold view scoped web socket channel identifiers registered by <f:websocket>.

Field Summary

Modifier and TypeField and Description
private static final ConcurrentMap<String, String>
pack-priv static final Map<String, String>
private static final String
private static final String
private static final int
private static final int
private static final int
pack-priv static final int
private static final int
private static final long
private final ConcurrentMap<String, String>
private final ConcurrentMap<Serializable, String>
private WebsocketSessionManager
private WebsocketUserManager

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
deregisterSessionScope()

When current session scope is about to be destroyed, deregister all session scope channels and explicitly close any open web sockets associated with it to avoid stale websockets.

pack-priv static String
getChannelId(String channel, Map<String, String> sessionScope, Map<String, String> viewScope)

For internal usage only.

pack-priv static Map<String, String>
getSessionScope()

For internal usage only.

pack-priv static Map<String, String>
getViewScope(boolean create)

For internal usage only.

private void
public String

Returns:

The web socket URL.
register
(FacesContext
The involved faces context.
context
,
String
The web socket channel.
channel
,
String
The web socket scope. Supported values are application, session and view, case insensitive. If null, the default is application.
scope
,
Serializable
The user object representing the owner of the given channel. If not null, then scope may not be application.
user
)

Register given channel on given scope and returns the web socket channel identifier.

private String
register(FacesContext context, Serializable user, String channel, Map<String, String> targetScope, Map<String, String>... otherScopes)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

APPLICATION_SCOPEback to summary
private static final ConcurrentMap<String, String> APPLICATION_SCOPE
EMPTY_SCOPEback to summary
pack-priv static final Map<String, String> EMPTY_SCOPE
ERROR_DUPLICATE_CHANNELback to summary
private static final String ERROR_DUPLICATE_CHANNEL
ERROR_INVALID_SCOPEback to summary
private static final String ERROR_INVALID_SCOPE
ESTIMATED_CHANNELS_PER_APPLICATIONback to summary
private static final int ESTIMATED_CHANNELS_PER_APPLICATION
ESTIMATED_CHANNELS_PER_SESSIONback to summary
private static final int ESTIMATED_CHANNELS_PER_SESSION
ESTIMATED_CHANNELS_PER_VIEWback to summary
private static final int ESTIMATED_CHANNELS_PER_VIEW
ESTIMATED_TOTAL_CHANNELSback to summary
pack-priv static final int ESTIMATED_TOTAL_CHANNELS
ESTIMATED_USERS_PER_SESSIONback to summary
private static final int ESTIMATED_USERS_PER_SESSION
serialVersionUIDback to summary
private static final long serialVersionUID
sessionScopeback to summary
private final ConcurrentMap<String, String> sessionScope
sessionUsersback to summary
private final ConcurrentMap<Serializable, String> sessionUsers
socketSessionsback to summary
private WebsocketSessionManager socketSessions
Annotations
@Inject
socketUsersback to summary
private WebsocketUserManager socketUsers
Annotations
@Inject

Constructor Detail

WebsocketChannelManagerback to summary
public WebsocketChannelManager()

Method Detail

deregisterSessionScopeback to summary
protected void deregisterSessionScope()

When current session scope is about to be destroyed, deregister all session scope channels and explicitly close any open web sockets associated with it to avoid stale websockets. If any, also deregister session users.

Annotations
@PreDestroy
getChannelIdback to summary
pack-priv static String getChannelId(String channel, Map<String, String> sessionScope, Map<String, String> viewScope)

For internal usage only. This makes it possible to resolve the session and view scope channel ID during push send time in WebsocketPushContext.

getSessionScopeback to summary
pack-priv static Map<String, String> getSessionScope()

For internal usage only. This makes it possible to remember session scope channel IDs during injection time of WebsocketPushContext (the CDI session scope is not necessarily active during push send time).

getViewScopeback to summary
pack-priv static Map<String, String> getViewScope(boolean create)

For internal usage only. This makes it possible to remember view scope channel IDs during injection time of WebsocketPushContext (the CDI view scope is not necessarily active during push send time).

readObjectback to summary
private void readObject(ObjectInputStream input) throws IOException, ClassNotFoundException
Annotations
@SuppressWarnings:unchecked
registerback to summary
public String register(FacesContext context, String channel, String scope, Serializable user)

Register given channel on given scope and returns the web socket channel identifier.

Parameters
context:FacesContext

The involved faces context.

channel:String

The web socket channel.

scope:String

The web socket scope. Supported values are application, session and view, case insensitive. If null, the default is application.

user:Serializable

The user object representing the owner of the given channel. If not null, then scope may not be application.

Returns:String

The web socket URL.

Annotations
@SuppressWarnings:unchecked
Exceptions
IllegalArgumentException:
When the scope is invalid or when channel already exists on a different scope.
registerback to summary
private String register(FacesContext context, Serializable user, String channel, Map<String, String> targetScope, Map<String, String>... otherScopes)
Annotations
@SuppressWarnings:unchecked
writeObjectback to summary
private void writeObject(ObjectOutputStream output) throws IOException
com.sun.faces.push back to summary

private final Enum WebsocketChannelManager.Scope

extends Enum<WebsocketChannelManager.Scope>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final WebsocketChannelManager.Scope
public static final WebsocketChannelManager.Scope
public static final WebsocketChannelManager.Scope

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static WebsocketChannelManager.Scope
of(String value, Serializable user)

public static WebsocketChannelManager.Scope
public static WebsocketChannelManager.Scope[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

APPLICATIONback to summary
public static final WebsocketChannelManager.Scope APPLICATION
SESSIONback to summary
public static final WebsocketChannelManager.Scope SESSION
VIEWback to summary
public static final WebsocketChannelManager.Scope VIEW

Constructor Detail

Scopeback to summary
private Scope()

Method Detail

ofback to summary
pack-priv static WebsocketChannelManager.Scope of(String value, Serializable user)
valueOfback to summary
public static WebsocketChannelManager.Scope valueOf(String name)
valuesback to summary
public static WebsocketChannelManager.Scope[] values()
com.sun.faces.push back to summary

public Class WebsocketChannelManager.ViewScope

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@ViewScoped

This helps the web socket channel manager to hold view scoped web socket channel identifiers registered by <f:websocket>.
Author
Bauke Scholtz
Since
2.3
See Also
WebsocketChannelManager

Field Summary

Modifier and TypeField and Description
private static final long
private ConcurrentMap<String, String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
deregisterViewScope()

When current view scope is about to be destroyed, deregister all view scope channels and explicitly close any open web sockets associated with it to avoid stale websockets.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID
viewScopeback to summary
private ConcurrentMap<String, String> viewScope

Constructor Detail

ViewScopeback to summary
public ViewScope()

Method Detail

deregisterViewScopeback to summary
protected void deregisterViewScope()

When current view scope is about to be destroyed, deregister all view scope channels and explicitly close any open web sockets associated with it to avoid stale websockets.

Annotations
@PreDestroy