Asterisk-Java

org.asteriskjava.fastagi
Class DefaultAgiServer

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

public class DefaultAgiServer
extends AbstractAgiServer
implements AgiServer

Default implementation of the AgiServer interface for FastAGI.

Version:
$Id: DefaultAgiServer.java 1304 2009-05-12 22:51:12Z srt $
Author:
srt

Constructor Summary
DefaultAgiServer()
          Creates a new DefaultAgiServer.
DefaultAgiServer(AgiScript agiScript)
          Creates a new DefaultAgiServer that runs the given AgiScript for all requests.
DefaultAgiServer(MappingStrategy mappingStrategy)
          Creates a new DefaultAgiServer that uses the given MappingStrategy.
DefaultAgiServer(java.lang.String configResourceBundleName)
          Creates a new DefaultAgiServer and loads its configuration from an alternative resource bundle.
DefaultAgiServer(java.lang.String configResourceBundleName, MappingStrategy mappingStrategy)
          Creates a new DefaultAgiServer and loads its configuration from an alternative resource bundle and uses the given MappingStrategy.
 
Method Summary
protected  ServerSocketFacade createServerSocket()
           
protected  void finalize()
           
 int getPort()
          Returns the TCP port this server is configured to bind to.
static void main(java.lang.String[] args)
           
 void run()
           
 void setBindPort(int bindPort)
          Deprecated. use setPort(int) instead
 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 org.asteriskjava.fastagi.AbstractAgiServer
createPool, execute, getMappingStrategy, isDie, setMappingStrategy, setMaximumPoolSize, setPoolSize
 
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.


DefaultAgiServer

public DefaultAgiServer(java.lang.String configResourceBundleName)
Creates a new DefaultAgiServer and loads its configuration from an alternative resource bundle.

Parameters:
configResourceBundleName - the name of the conifiguration resource bundle (default is "fastagi").

DefaultAgiServer

public DefaultAgiServer(MappingStrategy mappingStrategy)
Creates a new DefaultAgiServer that uses the given MappingStrategy.

Parameters:
mappingStrategy - the MappingStrategy to use to determine the AgiScript to run.
Since:
1.0.0

DefaultAgiServer

public DefaultAgiServer(AgiScript agiScript)
Creates a new DefaultAgiServer that runs the given AgiScript for all requests.

Parameters:
agiScript - the AgiScript to run.
Since:
1.0.0

DefaultAgiServer

public DefaultAgiServer(java.lang.String configResourceBundleName,
                        MappingStrategy mappingStrategy)
Creates a new DefaultAgiServer and loads its configuration from an alternative resource bundle and uses the given MappingStrategy.

Parameters:
configResourceBundleName - the name of the conifiguration resource bundle (default is "fastagi").
mappingStrategy - the MappingStrategy to use to determine the AgiScript to run.
Since:
1.0.0
Method Detail

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

getPort

public int getPort()
Returns the TCP port this server is configured to bind to.

Returns:
the TCP port this server is configured to bind to.
Since:
1.0.0

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()

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
Overrides:
shutdown in class AbstractAgiServer
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 AbstractAgiServer
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-2009 Stefan Reuter. All Rights Reserved.