Asterisk-Java

org.asteriskjava.fastagi
Class DefaultAgiServer

java.lang.Object
  extended by org.asteriskjava.fastagi.DefaultAgiServer
All Implemented Interfaces:
AgiServer

public class DefaultAgiServer
extends java.lang.Object
implements AgiServer

Default implementation of the AgiServer interface.

Version:
$Id: DefaultAgiServer.java 538 2006-08-11 12:48:39Z srt $
Author:
srt

Constructor Summary
DefaultAgiServer()
          Creates a new DefaultAgiServer.
 
Method Summary
protected  ServerSocketFacade createServerSocket()
           
 void die()
           
protected  void finalize()
           
static void main(java.lang.String[] args)
           
 void run()
           
 void setBindPort(int bindPort)
          Deprecated. use setPort(int) instead
 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.
 void setPort(int port)
          Sets the TCP port to listen on for new connections.
 void shutdown()
          Stops this AgiServer.
 void startup()
          Starts this AgiServer.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultAgiServer

public DefaultAgiServer()
Creates a new DefaultAgiServer.

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.

setBindPort

public void setBindPort(int bindPort)
Deprecated. use setPort(int) instead

Sets the TCP port to listen on for new connections.

The default port is 4573.

Parameters:
bindPort - the port to bind to.

setPort

public void setPort(int port)
Sets the TCP port to listen on for new connections.

The default port is 4573.

Parameters:
port - the port to bind to.
Since:
0.2

setMappingStrategy

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

The default mapping strategy is a ResourceBundleMappingStrategy.

Parameters:
mappingStrategy - the mapping strategy to use.
See Also:
ResourceBundleMappingStrategy

createServerSocket

protected ServerSocketFacade createServerSocket()
                                         throws java.io.IOException
Throws:
java.io.IOException

startup

public void startup()
             throws java.io.IOException,
                    java.lang.IllegalStateException
Description copied from interface: AgiServer
Starts this AgiServer.

After calling startup() this AgiServer is ready to receive requests from Asterisk servers and process them.

Note that this method will not return until the AgiServer has been shut down. If you want to run the AgiServer in the background use wrap it with an AgiServerThread.

Specified by:
startup in interface AgiServer
Throws:
java.io.IOException - if the server socket cannot be bound.
java.lang.IllegalStateException - if this AgiServer is already running.

run

public void run()

die

public void die()

shutdown

public void shutdown()
              throws java.lang.IllegalStateException
Description copied from interface: AgiServer
Stops this AgiServer.

The server socket is closed, new connections are refused and resources are freed. Any running AgiScripts are finish before shutdown completes.

Specified by:
shutdown in interface AgiServer
Throws:
java.lang.IllegalStateException - if this AgiServer is already shut down or has not yet been started.

finalize

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

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

Asterisk-Java

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