1 28 29 package com.caucho.server.webapp; 30 31 import com.caucho.config.types.Period; 32 import com.caucho.util.L10N; 33 34 import javax.annotation.PostConstruct; 35 import javax.servlet.ServletException ; 36 37 40 public class CacheMapping { 41 static L10N L = new L10N(CacheMapping.class); 42 43 private String _urlPattern; 45 private String _urlRegexp; 46 47 private long _maxAge = Long.MIN_VALUE; 49 private long _sMaxAge = Long.MIN_VALUE; 50 51 54 public CacheMapping() 55 { 56 } 57 58 61 public void setUrlPattern(String urlPattern) 62 { 63 _urlPattern = urlPattern; 64 } 65 66 69 public String getUrlPattern() 70 { 71 return _urlPattern; 72 } 73 74 77 public void setUrlRegexp(String urlRegexp) 78 { 79 _urlRegexp = urlRegexp; 80 } 81 82 85 public String getUrlRegexp() 86 { 87 return _urlRegexp; 88 } 89 90 93 public void setExpires(Period period) 94 { 95 setMaxAge(period); 96 } 97 98 101 public void setMaxAge(Period period) 102 { 103 _maxAge = period.getPeriod(); 104 } 105 106 109 public long getMaxAge() 110 { 111 return _maxAge; 112 } 113 114 117 public void setSMaxAge(Period period) 118 { 119 _sMaxAge = period.getPeriod(); 120 } 121 122 125 public long getSMaxAge() 126 { 127 return _sMaxAge; 128 } 129 130 133 @PostConstruct 134 public void init() 135 throws ServletException 136 { 137 if (_urlPattern == null && _urlRegexp == null) 138 throw new ServletException (L.l("cache-mapping needs 'url-pattern' attribute.")); 139 if (_maxAge == Long.MIN_VALUE && _sMaxAge == Long.MIN_VALUE) 140 throw new ServletException (L.l("cache-mapping needs 'max-age' attribute.")); 141 } 142 } 143 | Popular Tags |