com.nexaweb.server.pushconnection.flushpolicies
Class IdlePeriodFlushPolicy

java.lang.Object
  extended byTimerBasedFlushPolicy
      extended bycom.nexaweb.server.pushconnection.flushpolicies.IdlePeriodFlushPolicy
Direct Known Subclasses:
IdlePeriodWithSizeThresholdFlushPolicy

public class IdlePeriodFlushPolicy
extends TimerBasedFlushPolicy

This policy will take action if, after a message is sent, the connection remains idle for a specified period of time. This policy is used when your application sends groups of messages down the push connection with idle time in between. Configuring this policy to be tolerant of the time between messages in a group and taking action between groups is the goal.

Example Configurations

   <policy>
      <rules>
         <match xpath="starts-with(/client-info/java-version, '1.4')" />
         <match xpath="starts-with(/client-info/java-vendor, 'Sun')" />
         <match xpath="contains(/client-info/user-agent, 'MSIE 6')" />
         <match address="127.0.0.*" />
      </rules>		 
      <configuration class="com.nexaweb.server.pushconnection.flushpolicies.IdlePeriodFlushPolicy">
         <flush-size>8 K</flush-size>
         <period>10 sec.</period>
      </configuration>
   </policy>

   <policy>
      <rules>
         <match xpath="starts-with(/client-info/java-version, '1.4')" />
         <match xpath="starts-with(/client-info/java-vendor, 'Sun')" />
         <match xpath="contains(/client-info/user-agent, 'MSIE 6')" />
         <match address="127.0.0.*" />
      </rules>		 
      <configuration class="com.nexaweb.server.pushconnection.flushpolicies.IdlePeriodFlushPolicy">
         <is-stream-closed-on-flush>true</is-stream-closed-on-flush>
         <period>10 sec.</period>
      </configuration>
   </policy>
 

See Also:
Serialized Form

Constructor Summary
IdlePeriodFlushPolicy()
          This constructor is only for use by Nexaweb internally.
IdlePeriodFlushPolicy(long idlePeriod)
          Constructs a IdlePeriodFlushPolicy with the specified idlePeriod which will return true from isFlushMechanismStreamClose().
IdlePeriodFlushPolicy(long idlePeriod, int flushSize)
          Constructs a IdlePeriodFlushPolicy with the specified idlePeriod and flushSize.
 
Method Summary
 void configure(Element policy)
           
 int getFlushSizeInBytes()
           
protected  long getIdlePeriod()
           
 boolean isStreamClosedOnFlush()
           
protected  boolean messageMeetsFlushTaskResetCriteria(Flushable flushable, byte[] content)
           
 void onMessageSend(Flushable flushable, byte[] content)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IdlePeriodFlushPolicy

public IdlePeriodFlushPolicy()
This constructor is only for use by Nexaweb internally. If you wish to construct this object directly for use on a PushConnection, use IdlePeriodFlushPolicy(long, int) or IdlePeriodFlushPolicy(long).


IdlePeriodFlushPolicy

public IdlePeriodFlushPolicy(long idlePeriod,
                             int flushSize)
Constructs a IdlePeriodFlushPolicy with the specified idlePeriod and flushSize.

Parameters:
idlePeriod - The period of time in milliseconds that the stream must remain idle before it is flushed.
flushSize - The size of the flush that will be used when flushing.

IdlePeriodFlushPolicy

public IdlePeriodFlushPolicy(long idlePeriod)
Constructs a IdlePeriodFlushPolicy with the specified idlePeriod which will return true from isFlushMechanismStreamClose().

Parameters:
idlePeriod - The period of time in milliseconds that the stream must remain idle before it is flushed.
Method Detail

configure

public void configure(Element policy)
               throws ConfigurationException
Throws:
ConfigurationException
See Also:
ConfigurableFlushPolicy.configure(Element)

getFlushSizeInBytes

public int getFlushSizeInBytes()
See Also:
FlushPolicy#getFlushSizeInBytes

isStreamClosedOnFlush

public boolean isStreamClosedOnFlush()
See Also:
FlushPolicy#isStreamClosedOnFlush

onMessageSend

public void onMessageSend(Flushable flushable,
                          byte[] content)
                   throws java.io.IOException
Throws:
java.io.IOException
See Also:
FlushPolicy#onMessageSend(Flushable,byte[])

messageMeetsFlushTaskResetCriteria

protected boolean messageMeetsFlushTaskResetCriteria(Flushable flushable,
                                                     byte[] content)

getIdlePeriod

protected long getIdlePeriod()


Copyright © 2005 Nexaweb Technologies, Inc. All Rights Reserved.