org.granite.gravity
Class DefaultGravity

java.lang.Object
  extended by org.granite.gravity.DefaultGravity
All Implemented Interfaces:
ShutdownListener, DefaultGravityMBean, Gravity
Direct Known Subclasses:
GAEGravity

public class DefaultGravity
extends Object
implements Gravity, DefaultGravityMBean

Author:
William DRAI, Franck WOLFF

Field Summary
 
Fields inherited from interface org.granite.gravity.Gravity
BYTEARRAY_BODY_HEADER, RECONNECT_INTERVAL_MS_KEY, RECONNECT_MAX_ATTEMPTS_KEY
 
Constructor Summary
DefaultGravity(GravityConfig gravityConfig, ServicesConfig servicesConfig, GraniteConfig graniteConfig)
           
 
Method Summary
 boolean access(String channelId)
           
 boolean cancel(AsyncChannelRunner runner)
           
protected  Channel createChannel()
           
 void execute(AsyncChannelRunner runner)
           
 Channel getChannel(String channelId)
           
 String getChannelFactoryName()
           
 long getChannelIdleTimeoutMillis()
           
 int getCorePoolSize()
           
 GraniteConfig getGraniteConfig()
           
 GravityConfig getGravityConfig()
           
 String getGravityFactoryName()
           
 long getKeepAliveTimeMillis()
           
 long getLongPollingTimeoutMillis()
           
 int getMaximumPoolSize()
           
 int getMaxMessagesQueuedPerChannel()
           
 int getQueueCapacity()
           
 int getQueueRemainingCapacity()
           
 int getQueueSize()
           
 long getReconnectIntervalMillis()
           
 int getReconnectMaxAttempts()
           
 ServiceAdapter getServiceAdapter(String messageType, String destinationId)
           
 ServicesConfig getServicesConfig()
           
 Message handleMessage(Message message)
           
 Message handleMessage(Message message, boolean skipInterceptor)
           
 GraniteContext initThread()
           
protected  void internalStart()
           
 boolean isRetryOnError()
           
 boolean isStarted()
           
protected  void postManage(Channel channel)
           
 Message publishMessage(AsyncMessage message)
           
 Message publishMessage(Channel fromChannel, AsyncMessage message)
           
 void reconfigure(GravityConfig gravityConfig, GraniteConfig graniteConfig)
           
 void releaseThread()
           
 Channel removeChannel(String channelId)
           
 void restart()
           
 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()
           
 void stop()
           
 void stop(boolean now)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultGravity

public DefaultGravity(GravityConfig gravityConfig,
                      ServicesConfig servicesConfig,
                      GraniteConfig graniteConfig)
Method Detail

getGravityConfig

public GravityConfig getGravityConfig()
Specified by:
getGravityConfig in interface Gravity

getServicesConfig

public ServicesConfig getServicesConfig()
Specified by:
getServicesConfig in interface Gravity

getGraniteConfig

public GraniteConfig getGraniteConfig()
Specified by:
getGraniteConfig in interface Gravity

isStarted

public boolean isStarted()
Specified by:
isStarted in interface DefaultGravityMBean
Specified by:
isStarted in interface Gravity

getServiceAdapter

public ServiceAdapter getServiceAdapter(String messageType,
                                        String destinationId)
Specified by:
getServiceAdapter in interface Gravity

start

public void start()
           throws Exception
Specified by:
start in interface DefaultGravityMBean
Specified by:
start in interface Gravity
Throws:
Exception

internalStart

protected void internalStart()

restart

public void restart()
             throws Exception
Specified by:
restart in interface DefaultGravityMBean
Throws:
Exception

reconfigure

public void reconfigure(GravityConfig gravityConfig,
                        GraniteConfig graniteConfig)
Specified by:
reconfigure in interface Gravity

stop

public void stop()
          throws Exception
Specified by:
stop in interface ShutdownListener
Specified by:
stop in interface DefaultGravityMBean
Specified by:
stop in interface Gravity
Throws:
Exception

stop

public void stop(boolean now)
          throws Exception
Specified by:
stop in interface Gravity
Throws:
Exception

getGravityFactoryName

public String getGravityFactoryName()
Specified by:
getGravityFactoryName in interface DefaultGravityMBean

getChannelFactoryName

public String getChannelFactoryName()
Specified by:
getChannelFactoryName in interface DefaultGravityMBean

getChannelIdleTimeoutMillis

public long getChannelIdleTimeoutMillis()
Specified by:
getChannelIdleTimeoutMillis in interface DefaultGravityMBean

setChannelIdleTimeoutMillis

public void setChannelIdleTimeoutMillis(long channelIdleTimeoutMillis)
Specified by:
setChannelIdleTimeoutMillis in interface DefaultGravityMBean

isRetryOnError

public boolean isRetryOnError()
Specified by:
isRetryOnError in interface DefaultGravityMBean

setRetryOnError

public void setRetryOnError(boolean retryOnError)
Specified by:
setRetryOnError in interface DefaultGravityMBean

getLongPollingTimeoutMillis

public long getLongPollingTimeoutMillis()
Specified by:
getLongPollingTimeoutMillis in interface DefaultGravityMBean

setLongPollingTimeoutMillis

public void setLongPollingTimeoutMillis(long longPollingTimeoutMillis)
Specified by:
setLongPollingTimeoutMillis in interface DefaultGravityMBean

getMaxMessagesQueuedPerChannel

public int getMaxMessagesQueuedPerChannel()
Specified by:
getMaxMessagesQueuedPerChannel in interface DefaultGravityMBean

setMaxMessagesQueuedPerChannel

public void setMaxMessagesQueuedPerChannel(int maxMessagesQueuedPerChannel)
Specified by:
setMaxMessagesQueuedPerChannel in interface DefaultGravityMBean

getReconnectIntervalMillis

public long getReconnectIntervalMillis()
Specified by:
getReconnectIntervalMillis in interface DefaultGravityMBean

getReconnectMaxAttempts

public int getReconnectMaxAttempts()
Specified by:
getReconnectMaxAttempts in interface DefaultGravityMBean

getCorePoolSize

public int getCorePoolSize()
Specified by:
getCorePoolSize in interface DefaultGravityMBean

setCorePoolSize

public void setCorePoolSize(int corePoolSize)
Specified by:
setCorePoolSize in interface DefaultGravityMBean

getKeepAliveTimeMillis

public long getKeepAliveTimeMillis()
Specified by:
getKeepAliveTimeMillis in interface DefaultGravityMBean

setKeepAliveTimeMillis

public void setKeepAliveTimeMillis(long keepAliveTimeMillis)
Specified by:
setKeepAliveTimeMillis in interface DefaultGravityMBean

getMaximumPoolSize

public int getMaximumPoolSize()
Specified by:
getMaximumPoolSize in interface DefaultGravityMBean

setMaximumPoolSize

public void setMaximumPoolSize(int maximumPoolSize)
Specified by:
setMaximumPoolSize in interface DefaultGravityMBean

getQueueCapacity

public int getQueueCapacity()
Specified by:
getQueueCapacity in interface DefaultGravityMBean

getQueueRemainingCapacity

public int getQueueRemainingCapacity()
Specified by:
getQueueRemainingCapacity in interface DefaultGravityMBean

getQueueSize

public int getQueueSize()
Specified by:
getQueueSize in interface DefaultGravityMBean

createChannel

protected Channel createChannel()

getChannel

public Channel getChannel(String channelId)
Specified by:
getChannel in interface Gravity

removeChannel

public Channel removeChannel(String channelId)
Specified by:
removeChannel in interface Gravity

access

public boolean access(String channelId)
Specified by:
access in interface Gravity

execute

public void execute(AsyncChannelRunner runner)
Specified by:
execute in interface Gravity

cancel

public boolean cancel(AsyncChannelRunner runner)
Specified by:
cancel in interface Gravity

handleMessage

public Message handleMessage(Message message)
Specified by:
handleMessage in interface Gravity

handleMessage

public Message handleMessage(Message message,
                             boolean skipInterceptor)
Specified by:
handleMessage in interface Gravity

initThread

public GraniteContext initThread()
Specified by:
initThread in interface Gravity

releaseThread

public void releaseThread()
Specified by:
releaseThread in interface Gravity

publishMessage

public Message publishMessage(AsyncMessage message)
Specified by:
publishMessage in interface Gravity

publishMessage

public Message publishMessage(Channel fromChannel,
                              AsyncMessage message)
Specified by:
publishMessage in interface Gravity

postManage

protected void postManage(Channel channel)