[Asterisk-java-cvs] CVS: asterisk-java/src/java/net/sf/asterisk/fastagi SimpleMappingStrategy.java,N
Brought to you by:
srt
From: Stefan R. <sr...@us...> - 2005-10-14 21:42:41
|
Update of /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24994/src/java/net/sf/asterisk/fastagi Modified Files: ResourceBundleMappingStrategy.java Added Files: SimpleMappingStrategy.java Log Message: Added SimpleMappingStrategy --- NEW FILE: SimpleMappingStrategy.java --- /* * Copyright 2004-2005 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 net.sf.asterisk.fastagi; import java.util.Properties; /** * A MappingStrategy that is configured via a fixed set of properties.<br> * This mapping strategy is most useful when used with the Spring framework.<br> * Example (using Spring): * * <pre> * <beans> * <bean id="mapping" * class="net.sf.asterisk.fastagi.SimpleMappingStrategy"> * <property name="mappings"> * <props> * <prop key="leastcostdial.agi">leastCostDial</prop> * <prop key="hello.agi">hello</prop> * </props> * </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> * </pre> * * LeastCostDialAGIScript and HelloAGIScript must both implement the AGIScript.<br> * * @author srt * @version $Id: SimpleMappingStrategy.java,v 1.1 2005/10/14 21:42:33 srt Exp $ */ public class SimpleMappingStrategy implements MappingStrategy { private Properties mappings; public void setMappings(Properties mappings) { this.mappings = mappings; } public AGIScript determineScript(AGIRequest request) { if (mappings == null) { return null; } return (AGIScript) mappings.get(request.getScript()); } } Index: ResourceBundleMappingStrategy.java =================================================================== RCS file: /cvsroot/asterisk-java/asterisk-java/src/java/net/sf/asterisk/fastagi/ResourceBundleMappingStrategy.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -p -r1.2 -r1.3 --- ResourceBundleMappingStrategy.java 31 Mar 2005 22:29:52 -0000 1.2 +++ ResourceBundleMappingStrategy.java 14 Oct 2005 21:42:33 -0000 1.3 @@ -50,12 +50,12 @@ public class ResourceBundleMappingStrate private static final String DEFAULT_RESOURCE_BUNDLE_NAME = "fastagi-mapping"; private final Log logger = LogFactory.getLog(getClass()); private String resourceBundleName; - private Map mapping; + private Map mappings; public ResourceBundleMappingStrategy() { this.resourceBundleName = DEFAULT_RESOURCE_BUNDLE_NAME; - this.mapping = null; + this.mappings = null; } public void setResourceBundleName(String propertiesName) @@ -68,7 +68,7 @@ public class ResourceBundleMappingStrate ResourceBundle resourceBundle; Enumeration keys; - mapping = new HashMap(); + mappings = new HashMap(); try { @@ -97,7 +97,7 @@ public class ResourceBundleMappingStrate continue; } - mapping.put(scriptName, agiScript); + mappings.put(scriptName, agiScript); } } @@ -125,11 +125,11 @@ public class ResourceBundleMappingStrate public AGIScript determineScript(AGIRequest request) { - if (mapping == null) + if (mappings == null) { loadResourceBundle(); } - return (AGIScript) mapping.get(request.getScript()); + return (AGIScript) mappings.get(request.getScript()); } } |