Asterisk-Java

org.asteriskjava.fastagi
Class AbstractAgiServer

java.lang.Object
  extended by org.asteriskjava.fastagi.AbstractAgiServer
Direct Known Subclasses:
AsyncAgiServer, DefaultAgiServer

public abstract class AbstractAgiServer
extends java.lang.Object

Abstract base class for FastAGI and AsyncAGI servers.

Since:
1.0.0

Constructor Summary
AbstractAgiServer()
           
 
Method Summary
protected  java.util.concurrent.ThreadPoolExecutor createPool()
          Creates a new ThreadPoolExecutor to serve the AGI requests.
protected  void execute(java.lang.Runnable command)
           
protected  void finalize()
           
protected  MappingStrategy getMappingStrategy()
           
protected  boolean isDie()
           
 void setMappingStrategy(MappingStrategy mappingStrategy)
          Sets the strategy to use for mapping AgiRequests to AgiScripts that serve them.
 void setMaximumPoolSize(int maximumPoolSize)
          Sets the maximum number of worker threads in the thread pool.
 void setPoolSize(int poolSize)
          Sets the number of worker threads in the thread pool.
protected  void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractAgiServer

public AbstractAgiServer()
Method Detail

setPoolSize

public void setPoolSize(int poolSize)
Sets the number of worker threads in the thread pool.

This is the number of threads that are available even if they are idle.

The default pool size is 10.

Parameters:
poolSize - the size of the worker thread pool.

setMaximumPoolSize

public void setMaximumPoolSize(int maximumPoolSize)
Sets the maximum number of worker threads in the thread pool.

This equals the maximum number of concurrent requests this AgiServer can serve.

The default maximum pool size is 100.

Parameters:
maximumPoolSize - the maximum size of the worker thread pool.

setMappingStrategy

public void setMappingStrategy(MappingStrategy mappingStrategy)
Sets the strategy to use for mapping AgiRequests to AgiScripts that serve them.

Parameters:
mappingStrategy - the mapping strategy to use.

getMappingStrategy

protected MappingStrategy getMappingStrategy()

isDie

protected boolean isDie()

shutdown

protected void shutdown()

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

execute

protected void execute(java.lang.Runnable command)

createPool

protected java.util.concurrent.ThreadPoolExecutor createPool()
Creates a new ThreadPoolExecutor to serve the AGI requests. The nature of this pool defines how many concurrent requests can be handled. The default implementation returns a dynamic thread pool defined by the poolSize and maximumPoolSize properties.

You can override this method to change this behavior. For example you can use a cached pool with

 return Executors.newCachedThreadPool(new DaemonThreadFactory());
 

Returns:
the ThreadPoolExecutor to use for serving AGI requests.
See Also:
setPoolSize(int), setMaximumPoolSize(int)

Asterisk-Java

Copyright © 2004-2009 Stefan Reuter. All Rights Reserved.