All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.asteriskjava.fastagi.SimpleMappingStrategy Maven / Gradle / Ivy

There is a newer version: 3.39.0
Show newest version
/*
 *  Copyright 2004-2006 Stefan Reuter
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package org.asteriskjava.fastagi;

import java.util.Map;

/**
 * A MappingStrategy that is configured via a fixed set of properties.

* This mapping strategy is most useful when used with the Spring framework.

* Example (using Spring): * *

 * <beans>
 *    <bean id="mapping"
 *          class="org.asteriskjava.fastagi.SimpleMappingStrategy">
 *        <property name="mappings">
 *            <map>
 *                <entry>
 *                    <key><value>hello.agi</value></key>
 *                    <ref local="hello"/>
 *                </entry>
 *                <entry>
 *                    <key><value>leastcostdial.agi</value></key>
 *                    <ref local="leastCostDial"/>
 *                </entry>
 *            </map>
 *        </property>
 *    </bean>
 *
 *    <bean id="hello"
 *          class="com.example.fastagi.HelloAgiScript"/>
 *
 *    <bean id="leastCostDial"
 *          class="com.example.fastagi.LeastCostDialAgiScript">
 *        <property name="rates"><value>rates.txt</value></property>
 *    </bean>
 * <beans>
 * 
* * LeastCostDialAgiScript and HelloAgiScript must both implement the AgiScript.

* * @author srt * @version $Id$ * @since 0.2 */ public class SimpleMappingStrategy implements MappingStrategy { private Map mappings; /** * Set the "path to AgiScript" mapping.

* Use the path (for example hello.agi) as key and your * AgiScript (for example new HelloAgiScript()) as value of * this map. * * @param mappings the path to AgiScript mapping. */ public void setMappings(Map mappings) { this.mappings = mappings; } @Override public AgiScript determineScript(AgiRequest request, AgiChannel channel) { if (mappings == null) { return null; } return mappings.get(request.getScript()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy