public class DefaultGravity extends java.lang.Object implements Gravity, GravityInternal, DefaultGravityMBean
Gravity.ListenerBYTEARRAY_BODY_HEADER, ENCODE_MESSAGE_BODY_KEY, RECONNECT_INTERVAL_MS_KEY, RECONNECT_MAX_ATTEMPTS_KEY| Constructor and Description |
|---|
DefaultGravity(GravityConfig gravityConfig,
ServicesConfig servicesConfig,
GraniteConfig graniteConfig) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
access(java.lang.String channelId) |
boolean |
cancel(AsyncChannelRunner runner) |
protected <C extends Channel> |
createChannel(ChannelFactory<C> channelFactory,
java.lang.String clientId) |
void |
execute(AsyncChannelRunner runner) |
Channel |
findChannelByClientId(java.lang.String clientId)
Find the channel for a specified clientId
|
java.util.List<Channel> |
findConnectedChannelsByUser(java.lang.String name)
Find all channels for an authenticated user name
|
Channel |
findCurrentChannel(java.lang.String destination)
Current channel for the specified destination
|
<C extends Channel> |
getChannel(ChannelFactory<C> channelFactory,
java.lang.String clientId) |
long |
getChannelIdleTimeoutMillis() |
java.util.List<Channel> |
getConnectedChannels()
Currently connected channels
|
java.util.List<Channel> |
getConnectedChannelsByDestination(java.lang.String destination)
Channels currently connected for a specified destination
|
java.util.Set<java.security.Principal> |
getConnectedUsers()
Currently connected authenticated users
|
java.util.Set<java.security.Principal> |
getConnectedUsersByDestination(java.lang.String destination)
Authenticated users currently connected for a specified destination
|
int |
getCorePoolSize() |
GraniteConfig |
getGraniteConfig()
Current Granite configuration
|
GravityConfig |
getGravityConfig()
Current Gravity configuration
|
java.lang.String |
getGravityFactoryName() |
long |
getKeepAliveTimeMillis() |
long |
getLongPollingTimeoutMillis() |
int |
getMaximumPoolSize() |
int |
getMaxMessagesQueuedPerChannel() |
int |
getQueueCapacity() |
int |
getQueueRemainingCapacity() |
int |
getQueueSize() |
long |
getReconnectIntervalMillis() |
int |
getReconnectMaxAttempts() |
ServiceAdapter |
getServiceAdapter(java.lang.String messageType,
java.lang.String destinationId) |
ServicesConfig |
getServicesConfig()
Current services configuration
|
UdpReceiverFactory |
getUdpReceiverFactory() |
Message |
handleMessage(ChannelFactory<?> channelFactory,
Message message) |
Message |
handleMessage(ChannelFactory<?> channelFactory,
Message message,
boolean skipInterceptor) |
Message |
handleMessage(Message message)
Handle a message using the configured service adapter
|
Message |
handleMessage(Message message,
boolean skipInterceptor)
Handle a message using the configured service adapter, optionally skipping interceptors
|
boolean |
hasUdpReceiverFactory() |
GraniteContext |
initThread(java.lang.String sessionId,
java.lang.String clientType) |
protected void |
internalStart() |
boolean |
isRetryOnError() |
boolean |
isStarted()
State of the Gravity component
|
void |
notifyAuthenticated(Channel channel,
java.security.Principal principal) |
void |
notifyConnected(Channel channel) |
void |
notifyDisconnected(Channel channel) |
protected void |
postManage(Channel channel) |
Message |
publishMessage(AsyncMessage message)
Publish a message to connected users from the default server channel
|
Message |
publishMessage(Channel fromChannel,
AsyncMessage message)
Publish a message to connected users from the specified user channel
|
void |
reconfigure(GravityConfig gravityConfig,
GraniteConfig graniteConfig)
Update the current configuration and restarts
|
void |
registerListener(Gravity.Listener listener)
Registers a listener which will be notified of channel events (connect/disconnect/subscription/unsubscription)
|
void |
releaseThread() |
Channel |
removeChannel(java.lang.String channelId,
boolean timeout) |
void |
restart() |
Message |
sendRequest(Channel fromChannel,
AsyncMessage message)
Send a server-to-client request, waiting synchronously for the response
|
void |
setChannelIdleTimeoutMillis(long channelIdleTimeoutMillis) |
void |
setCorePoolSize(int corePoolSize) |
void |
setKeepAliveTimeMillis(long keepAliveTimeMillis) |
void |
setLongPollingTimeoutMillis(long longPollingTimeoutMillis) |
void |
setMaximumPoolSize(int maximumPoolSize) |
void |
setMaxMessagesQueuedPerChannel(int maxMessagesQueuedPerChannel) |
void |
setRetryOnError(boolean retryOnError) |
void |
start()
Start the Gravity component
|
void |
stop()
Stop the Gravity component
|
void |
stop(boolean now)
Stop the Gravity component, optionally forcing immediate shutdown (without waiting for channel closing)
|
void |
unregisterListener(Gravity.Listener listener)
Unregisters a listener which will be notified of channel events (connect/disconnect/subscription/unsubscription)
|
public DefaultGravity(GravityConfig gravityConfig, ServicesConfig servicesConfig, GraniteConfig graniteConfig)
public GravityConfig getGravityConfig()
GravitygetGravityConfig in interface GravitygetGravityConfig in interface GravityInternalpublic ServicesConfig getServicesConfig()
GravitygetServicesConfig in interface GravitygetServicesConfig in interface GravityInternalpublic GraniteConfig getGraniteConfig()
GravitygetGraniteConfig in interface GravitygetGraniteConfig in interface GravityInternalpublic boolean isStarted()
GravityisStarted in interface DefaultGravityMBeanisStarted in interface GravityisStarted in interface GravityInternalpublic ServiceAdapter getServiceAdapter(java.lang.String messageType, java.lang.String destinationId)
getServiceAdapter in interface GravityInternalpublic void start()
throws java.lang.Exception
Gravitystart in interface DefaultGravityMBeanstart in interface Gravityjava.lang.Exceptionprotected void internalStart()
public void restart()
throws java.lang.Exception
restart in interface DefaultGravityMBeanjava.lang.Exceptionpublic void reconfigure(GravityConfig gravityConfig, GraniteConfig graniteConfig)
Gravityreconfigure in interface GravitygravityConfig - Gravity configgraniteConfig - Granite configpublic void stop()
throws java.lang.Exception
Gravitystop in interface ShutdownListenerstop in interface DefaultGravityMBeanstop in interface Gravityjava.lang.Exceptionpublic void stop(boolean now)
throws java.lang.Exception
Gravitypublic java.lang.String getGravityFactoryName()
getGravityFactoryName in interface DefaultGravityMBeanpublic long getChannelIdleTimeoutMillis()
getChannelIdleTimeoutMillis in interface DefaultGravityMBeanpublic void setChannelIdleTimeoutMillis(long channelIdleTimeoutMillis)
setChannelIdleTimeoutMillis in interface DefaultGravityMBeanpublic boolean isRetryOnError()
isRetryOnError in interface DefaultGravityMBeanpublic void setRetryOnError(boolean retryOnError)
setRetryOnError in interface DefaultGravityMBeanpublic long getLongPollingTimeoutMillis()
getLongPollingTimeoutMillis in interface DefaultGravityMBeanpublic void setLongPollingTimeoutMillis(long longPollingTimeoutMillis)
setLongPollingTimeoutMillis in interface DefaultGravityMBeanpublic int getMaxMessagesQueuedPerChannel()
getMaxMessagesQueuedPerChannel in interface DefaultGravityMBeanpublic void setMaxMessagesQueuedPerChannel(int maxMessagesQueuedPerChannel)
setMaxMessagesQueuedPerChannel in interface DefaultGravityMBeanpublic long getReconnectIntervalMillis()
getReconnectIntervalMillis in interface DefaultGravityMBeanpublic int getReconnectMaxAttempts()
getReconnectMaxAttempts in interface DefaultGravityMBeanpublic int getCorePoolSize()
getCorePoolSize in interface DefaultGravityMBeanpublic void setCorePoolSize(int corePoolSize)
setCorePoolSize in interface DefaultGravityMBeanpublic long getKeepAliveTimeMillis()
getKeepAliveTimeMillis in interface DefaultGravityMBeanpublic void setKeepAliveTimeMillis(long keepAliveTimeMillis)
setKeepAliveTimeMillis in interface DefaultGravityMBeanpublic int getMaximumPoolSize()
getMaximumPoolSize in interface DefaultGravityMBeanpublic void setMaximumPoolSize(int maximumPoolSize)
setMaximumPoolSize in interface DefaultGravityMBeanpublic int getQueueCapacity()
getQueueCapacity in interface DefaultGravityMBeanpublic int getQueueRemainingCapacity()
getQueueRemainingCapacity in interface DefaultGravityMBeanpublic int getQueueSize()
getQueueSize in interface DefaultGravityMBeanpublic boolean hasUdpReceiverFactory()
hasUdpReceiverFactory in interface GravityInternalpublic UdpReceiverFactory getUdpReceiverFactory()
getUdpReceiverFactory in interface GravityInternalprotected <C extends Channel> C createChannel(ChannelFactory<C> channelFactory, java.lang.String clientId)
public <C extends Channel> C getChannel(ChannelFactory<C> channelFactory, java.lang.String clientId)
getChannel in interface GravityInternalpublic Channel removeChannel(java.lang.String channelId, boolean timeout)
removeChannel in interface GravityInternalpublic boolean access(java.lang.String channelId)
access in interface GravityInternalpublic void execute(AsyncChannelRunner runner)
execute in interface GravityInternalpublic boolean cancel(AsyncChannelRunner runner)
cancel in interface GravityInternalpublic Message handleMessage(Message message)
GravityhandleMessage in interface Gravitymessage - messagepublic Message handleMessage(Message message, boolean skipInterceptor)
GravityhandleMessage in interface Gravitymessage - messageskipInterceptor - skip interceptorspublic Message handleMessage(ChannelFactory<?> channelFactory, Message message)
handleMessage in interface GravityInternalpublic Message handleMessage(ChannelFactory<?> channelFactory, Message message, boolean skipInterceptor)
handleMessage in interface GravityInternalpublic GraniteContext initThread(java.lang.String sessionId, java.lang.String clientType)
initThread in interface GravityInternalpublic void releaseThread()
releaseThread in interface GravityInternalpublic void registerListener(Gravity.Listener listener)
GravityregisterListener in interface Gravitypublic void unregisterListener(Gravity.Listener listener)
GravityunregisterListener in interface Gravitypublic void notifyConnected(Channel channel)
notifyConnected in interface GravityInternalpublic void notifyDisconnected(Channel channel)
notifyDisconnected in interface GravityInternalpublic void notifyAuthenticated(Channel channel, java.security.Principal principal)
notifyAuthenticated in interface GravityInternalpublic java.util.List<Channel> getConnectedChannels()
GravitygetConnectedChannels in interface Gravitypublic java.util.Set<java.security.Principal> getConnectedUsers()
GravitygetConnectedUsers in interface Gravitypublic java.util.List<Channel> getConnectedChannelsByDestination(java.lang.String destination)
GravitygetConnectedChannelsByDestination in interface Gravitydestination - a destinationpublic java.util.Set<java.security.Principal> getConnectedUsersByDestination(java.lang.String destination)
GravitygetConnectedUsersByDestination in interface Gravitydestination - a destinationpublic java.util.List<Channel> findConnectedChannelsByUser(java.lang.String name)
GravityfindConnectedChannelsByUser in interface Gravityname - user namepublic Channel findChannelByClientId(java.lang.String clientId)
GravityfindChannelByClientId in interface GravityclientId - client idpublic Channel findCurrentChannel(java.lang.String destination)
GravityfindCurrentChannel in interface Gravitydestination - destinationpublic Message publishMessage(AsyncMessage message)
GravitypublishMessage in interface Gravitymessage - message to publishpublic Message publishMessage(Channel fromChannel, AsyncMessage message)
GravitypublishMessage in interface GravityfromChannel - originating channelmessage - message to publishpublic Message sendRequest(Channel fromChannel, AsyncMessage message)
GravitysendRequest in interface GravityfromChannel - originating channelmessage - requestprotected void postManage(Channel channel)