1 16 17 package org.springframework.web.servlet.mvc.multiaction; 18 19 import java.util.Collections ; 20 import java.util.HashMap ; 21 import java.util.Map ; 22 23 import org.springframework.web.util.WebUtils; 24 25 40 public class InternalPathMethodNameResolver extends AbstractUrlMethodNameResolver { 41 42 private String prefix = ""; 43 44 private String suffix = ""; 45 46 47 private final Map methodNameCache = Collections.synchronizedMap(new HashMap ()); 48 49 50 55 public void setPrefix(String prefix) { 56 this.prefix = (prefix != null ? prefix : ""); 57 } 58 59 62 protected String getPrefix() { 63 return prefix; 64 } 65 66 71 public void setSuffix(String suffix) { 72 this.suffix = (suffix != null ? suffix : ""); 73 } 74 75 78 protected String getSuffix() { 79 return suffix; 80 } 81 82 83 88 protected String getHandlerMethodNameForUrlPath(String urlPath) { 89 String methodName = (String ) this.methodNameCache.get(urlPath); 90 if (methodName == null) { 91 methodName = extractHandlerMethodNameFromUrlPath(urlPath); 92 methodName = postProcessHandlerMethodName(methodName); 93 this.methodNameCache.put(urlPath, methodName); 94 } 95 return methodName; 96 } 97 98 105 protected String extractHandlerMethodNameFromUrlPath(String uri) { 106 return WebUtils.extractFilenameFromUrlPath(uri); 107 } 108 109 120 protected String postProcessHandlerMethodName(String methodName) { 121 return getPrefix() + methodName + getSuffix(); 122 } 123 124 } 125 | Popular Tags |