Asterisk-Java

org.asteriskjava.fastagi
Class CompositeMappingStrategy

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

public class CompositeMappingStrategy
extends java.lang.Object
implements MappingStrategy

A mapping strategy that tries a sequence of other mapping strategies to find an AgiScript matching the request. The first strategy that returns a result wins, so the order of the mapping strategies passed to the CompositeMappingStrategy matters.

Example:

 new CompositeMappingStrategy(
       new ResourceBundleMappingStrategy(),
       new ClassNameMappingStrategy());
 
This creates a new mapping strategy that first tries to look up the script in fastagi-mapping.properties and - if the properties file is not present on the classpath or contains no mapping for the request - uses a ClassNameMappingStrategy to get the script.

Since:
0.3
Version:
$Id: CompositeMappingStrategy.java 1015 2008-04-04 21:56:36Z srt $
Author:
srt
See Also:
ResourceBundleMappingStrategy, ClassNameMappingStrategy

Constructor Summary
CompositeMappingStrategy()
          Creates a new empty CompositeMappingStrategy.
CompositeMappingStrategy(java.util.List<MappingStrategy> strategies)
          Creates a new CompositeMappingStrategy.
CompositeMappingStrategy(MappingStrategy... strategies)
          Creates a new CompositeMappingStrategy.
 
Method Summary
 void addStrategy(MappingStrategy strategy)
          Adds a strategy (at the end of the list).
 AgiScript determineScript(AgiRequest request)
          Returns the AgiScript instance that is responsible to handle the given request.
 void setStrategies(java.util.List<MappingStrategy> strategies)
          Sets the strategies to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeMappingStrategy

public CompositeMappingStrategy()
Creates a new empty CompositeMappingStrategy.


CompositeMappingStrategy

public CompositeMappingStrategy(MappingStrategy... strategies)
Creates a new CompositeMappingStrategy.

Parameters:
strategies - the strategies to use.

CompositeMappingStrategy

public CompositeMappingStrategy(java.util.List<MappingStrategy> strategies)
Creates a new CompositeMappingStrategy.

Parameters:
strategies - the strategies to use.
Method Detail

addStrategy

public void addStrategy(MappingStrategy strategy)
Adds a strategy (at the end of the list).

Parameters:
strategy - the strategy to add.

setStrategies

public void setStrategies(java.util.List<MappingStrategy> strategies)
Sets the strategies to use.

Parameters:
strategies - the strategies to use.

determineScript

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

Specified by:
determineScript in interface MappingStrategy
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.