1 16 package org.apache.cocoon.matching; 17 18 import org.apache.avalon.framework.configuration.Configurable; 19 import org.apache.avalon.framework.configuration.Configuration; 20 import org.apache.avalon.framework.configuration.ConfigurationException; 21 import org.apache.avalon.framework.parameters.Parameters; 22 23 import org.apache.cocoon.environment.ObjectModelHelper; 24 25 import java.util.Map ; 26 27 39 public class WildcardSessionAttributeMatcher extends AbstractWildcardMatcher 40 implements Configurable 41 { 42 private String defaultParam; 43 44 public void configure(Configuration config) throws ConfigurationException { 45 this.defaultParam = config.getChild("attribute-name").getValue(null); 46 if (getLogger().isDebugEnabled()) { 47 getLogger().debug("Default attribute-name is = '" + this.defaultParam + "'"); 48 } 49 } 50 51 protected String getMatchString(Map objectModel, Parameters parameters) { 52 53 String paramName = parameters.getParameter("attribute-name", this.defaultParam); 54 if (paramName == null) { 55 getLogger().warn("No attribute name given. FAILING"); 56 return null; 57 } 58 59 Object result = ObjectModelHelper.getRequest(objectModel).getSession().getAttribute(paramName); 60 if (result == null) { 61 getLogger().debug("Session attribute '" + paramName + "' not set."); 62 return null; 63 } 64 65 return result.toString(); 66 } 67 } 68 | Popular Tags |