1 16 17 package org.springframework.web.portlet.handler; 18 19 import java.util.Map ; 20 21 import javax.portlet.PortletRequest; 22 23 import org.springframework.beans.BeansException; 24 import org.springframework.util.Assert; 25 import org.springframework.util.CollectionUtils; 26 27 52 public class ParameterHandlerMapping extends AbstractMapBasedHandlerMapping { 53 54 57 public final static String DEFAULT_PARAMETER_NAME = "action"; 58 59 60 private String parameterName = DEFAULT_PARAMETER_NAME; 61 62 private Map parameterMap; 63 64 65 69 public void setParameterName(String parameterName) { 70 Assert.hasText(parameterName, "'parameterName' must not be empty"); 71 this.parameterName = parameterName; 72 } 73 74 79 public void setParameterMap(Map parameterMap) { 80 this.parameterMap = parameterMap; 81 } 82 83 84 89 public void initApplicationContext() throws BeansException { 90 super.initApplicationContext(); 91 registerHandlers(this.parameterMap); 92 } 93 94 99 protected void registerHandlers(Map parameterMap) throws BeansException { 100 if (CollectionUtils.isEmpty(parameterMap)) { 101 logger.warn("'parameterMap' is empty on ParameterHandlerMapping"); 102 } 103 else { 104 super.registerHandlers(parameterMap); 105 } 106 } 107 108 109 113 protected Object getLookupKey(PortletRequest request) throws Exception { 114 return request.getParameter(this.parameterName); 115 } 116 117 } 118 | Popular Tags |