1 16 package org.apache.webapp.balancer.rules; 17 18 import javax.servlet.http.HttpServletRequest ; 19 20 21 28 public class RequestParameterRule extends BaseRule { 29 33 private String paramName; 34 35 41 private String paramValue; 42 43 48 public void setParamName(String theParamName) { 49 if (theParamName == null) { 50 throw new IllegalArgumentException ("paramName cannot be null."); 51 } else { 52 paramName = theParamName; 53 } 54 } 55 56 61 protected String getParamName() { 62 return paramName; 63 } 64 65 70 public void setParamValue(String theParamValue) { 71 paramValue = theParamValue; 72 } 73 74 80 protected String getParamValue() { 81 return paramValue; 82 } 83 84 87 public boolean matches(HttpServletRequest request) { 88 String actualParamValue = request.getParameter(getParamName()); 89 90 if (actualParamValue == null) { 91 return (getParamValue() == null); 92 } else { 93 return (actualParamValue.compareTo(getParamValue()) == 0); 94 } 95 } 96 97 102 public String toString() { 103 StringBuffer buffer = new StringBuffer (); 104 105 buffer.append("["); 106 buffer.append(getClass().getName()); 107 buffer.append(": "); 108 109 buffer.append("Target param name: "); 110 buffer.append(getParamName()); 111 buffer.append(" / "); 112 113 buffer.append("Target param value: "); 114 buffer.append(getParamValue()); 115 buffer.append(" / "); 116 117 buffer.append("Redirect URL: "); 118 buffer.append(getRedirectUrl()); 119 120 buffer.append("]"); 121 122 return buffer.toString(); 123 } 124 } 125 126 127 | Popular Tags |