/* * Created on Mar 15, 2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package org.apache.commons.chain.web.servlet; import org.apache.commons.chain.Catalog; import org.apache.commons.chain.Command; import org.apache.commons.chain.Context; import org.apache.commons.chain.generic.LookupCommand; /** * @author germuska * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public abstract class AbstractMapper extends LookupCommand { protected Command getCommand(Context context) { // Map to the Command specified by the extra path info Catalog catalog = (Catalog) context.get(getCatalogKey()); if (catalog == null) { ServletWebContext swContext = (ServletWebContext) context; catalog = (Catalog) swContext.getRequestScope().get(getCatalogKey()); } return catalog.getCommand(getCommandName(context)); } protected abstract String getCommandName(Context context); private String catalogKey = ChainProcessor.CATALOG_DEFAULT; /** *
Return the context key under which our {@link Catalog} has been * stored.
*/ public String getCatalogKey() { return (this.catalogKey); } /** *Set the context key under which our {@link Catalog} has been * stored.
* * @param catalogKey The new catalog key */ public void setCatalogKey(String catalogKey) { this.catalogKey = catalogKey; } }