Asterisk-Java

org.asteriskjava.fastagi
Class ResourceBundleMappingStrategy

java.lang.Object
  extended by org.asteriskjava.fastagi.AbstractMappingStrategy
      extended by org.asteriskjava.fastagi.ResourceBundleMappingStrategy
All Implemented Interfaces:
MappingStrategy

public class ResourceBundleMappingStrategy
extends AbstractMappingStrategy

A MappingStrategy that is configured via a resource bundle.

The resource bundle contains the script part of the url as key and the fully qualified class name of the corresponding AgiScript as value.

Example:

 leastcostdial.agi = com.example.fastagi.LeastCostDialAgiScript
 hello.agi = com.example.fastagi.HelloAgiScript
 
LeastCostDialAgiScript and HelloAgiScript must both implement the AgiScript interface and have a default constructor with no parameters.

The resource bundle (properties) file is called fastagi-mapping.properties by default and must be available on the classpath.

Version:
$Id: ResourceBundleMappingStrategy.java 1140 2008-08-18 18:49:36Z srt $
Author:
srt

Field Summary
 
Fields inherited from class org.asteriskjava.fastagi.AbstractMappingStrategy
logger
 
Constructor Summary
ResourceBundleMappingStrategy()
          Creates a new ResourceBundleMappingStrategy using shared instances..
ResourceBundleMappingStrategy(boolean shareInstances)
          Creates a new ResourceBundleMappingStrategy indicating whether to use shared instances or not.
ResourceBundleMappingStrategy(java.lang.String resourceBundleName)
          Creates a new ResourceBundleMappingStrategy with the given basename of the resource bundle to use.
ResourceBundleMappingStrategy(java.lang.String resourceBundleName, boolean shareInstances)
          Creates a new ResourceBundleMappingStrategy with the given basename of the resource bundle to use and indicating whether to use shared instances or not.
 
Method Summary
 AgiScript determineScript(AgiRequest request)
          Returns the AgiScript instance that is responsible to handle the given request.
 void setResourceBundleName(java.lang.String resourceBundleName)
          Sets the basename of the resource bundle to use.
 void setShareInstances(boolean shareInstances)
          Sets whether to use shared instances or not.
 
Methods inherited from class org.asteriskjava.fastagi.AbstractMappingStrategy
createAgiScriptInstance, getClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceBundleMappingStrategy

public ResourceBundleMappingStrategy()
Creates a new ResourceBundleMappingStrategy using shared instances..


ResourceBundleMappingStrategy

public ResourceBundleMappingStrategy(java.lang.String resourceBundleName)
Creates a new ResourceBundleMappingStrategy with the given basename of the resource bundle to use.

Parameters:
resourceBundleName - basename of the resource bundle to use

ResourceBundleMappingStrategy

public ResourceBundleMappingStrategy(boolean shareInstances)
Creates a new ResourceBundleMappingStrategy indicating whether to use shared instances or not.

Parameters:
shareInstances - true to use shared instances, false to create a new instance for each request.
Since:
0.3

ResourceBundleMappingStrategy

public ResourceBundleMappingStrategy(java.lang.String resourceBundleName,
                                     boolean shareInstances)
Creates a new ResourceBundleMappingStrategy with the given basename of the resource bundle to use and indicating whether to use shared instances or not.

Parameters:
resourceBundleName - basename of the resource bundle to use
shareInstances - true to use shared instances, false to create a new instance for each request.
Since:
0.3
Method Detail

setResourceBundleName

public void setResourceBundleName(java.lang.String resourceBundleName)
Sets the basename of the resource bundle to use.

Default is "fastagi-mapping".

Parameters:
resourceBundleName - basename of the resource bundle to use

setShareInstances

public void setShareInstances(boolean shareInstances)
Sets whether to use shared instances or not. If set to true all AgiRequests are served by the same instance of an AgiScript, if set to false a new instance is created for each request.

Default is true.

Parameters:
shareInstances - true to use shared instances, false to create a new instance for each request.
Since:
0.3

determineScript

public AgiScript determineScript(AgiRequest request)
Description copied from interface: MappingStrategy
Returns the AgiScript instance that is responsible to handle the given request.

Parameters:
request - the request to lookup.
Returns:
the AgiScript instance to handle this request or null if none could be determined by this strategy.

Asterisk-Java

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