org.apache.mina.filter.firewall
Class ConnectionThrottleFilter

java.lang.Object
  extended by org.apache.mina.core.filterchain.IoFilterAdapter
      extended by org.apache.mina.filter.firewall.ConnectionThrottleFilter
All Implemented Interfaces:
IoFilter

public class ConnectionThrottleFilter
extends IoFilterAdapter

A IoFilter which blocks connections from connecting at a rate faster than the specified interval.

Author:
Apache MINA Project

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter
 
Constructor Summary
ConnectionThrottleFilter()
          Default constructor.
ConnectionThrottleFilter(long allowedInterval)
          Constructor that takes in a specified wait time.
 
Method Summary
protected  boolean isConnectionOk(IoSession session)
          Method responsible for deciding if a connection is OK to continue
 void sessionCreated(IoFilter.NextFilter nextFilter, IoSession session)
          Filters IoHandler.sessionCreated(IoSession) event.
 void setAllowedInterval(long allowedInterval)
          Sets the interval between connections from a client.
 
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, exceptionCaught, filterClose, filterWrite, init, messageReceived, messageSent, onPostAdd, onPostRemove, onPreAdd, onPreRemove, sessionClosed, sessionIdle, sessionOpened, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConnectionThrottleFilter

public ConnectionThrottleFilter()
Default constructor. Sets the wait time to 1 second


ConnectionThrottleFilter

public ConnectionThrottleFilter(long allowedInterval)
Constructor that takes in a specified wait time.

Parameters:
allowedInterval - The number of milliseconds a client is allowed to wait before making another successful connection
Method Detail

setAllowedInterval

public void setAllowedInterval(long allowedInterval)
Sets the interval between connections from a client. This value is measured in milliseconds.

Parameters:
allowedInterval - The number of milliseconds a client is allowed to wait before making another successful connection

isConnectionOk

protected boolean isConnectionOk(IoSession session)
Method responsible for deciding if a connection is OK to continue

Parameters:
session - The new session that will be verified
Returns:
True if the session meets the criteria, otherwise false

sessionCreated

public void sessionCreated(IoFilter.NextFilter nextFilter,
                           IoSession session)
                    throws Exception
Description copied from class: IoFilterAdapter
Filters IoHandler.sessionCreated(IoSession) event.

Specified by:
sessionCreated in interface IoFilter
Overrides:
sessionCreated in class IoFilterAdapter
Throws:
Exception


Copyright © 2004-2011 Apache MINA Project. All Rights Reserved.