1 29 30 package com.caucho.server.dispatch; 31 32 import com.caucho.log.Log; 33 import com.caucho.server.webapp.WebApp; 34 import com.caucho.util.L10N; 35 import com.caucho.vfs.Dependency; 36 37 import java.util.logging.Logger ; 38 39 42 public class Invocation extends ServletInvocation implements Dependency { 43 static final L10N L = new L10N(Invocation.class); 44 static final Logger log = Log.open(Invocation.class); 45 46 private String _rawHost; 47 48 private String _hostName; 50 private int _port; 51 52 private String _rawURI; 53 private boolean _isSecure; 54 55 private String _uri; 56 private String _sessionId; 57 58 private WebApp _webApp; 59 60 private Dependency _dependency; 61 62 public Invocation() 63 { 64 } 65 66 69 public final boolean isSecure() 70 { 71 return _isSecure; 72 } 73 74 77 public final void setSecure(boolean isSecure) 78 { 79 _isSecure = isSecure; 80 } 81 82 86 public final String getHost() 87 { 88 return _rawHost; 89 } 90 91 94 public final void setHost(String host) 95 { 96 _rawHost = host; 97 } 98 99 102 public final String getHostName() 103 { 104 return _hostName; 105 } 106 107 110 public final void setHostName(String hostName) 111 { 112 if (hostName != null && ! hostName.equals("")) 113 _hostName = hostName; 114 } 115 116 119 public final int getPort() 120 { 121 return _port; 122 } 123 124 127 public final void setPort(int port) 128 { 129 _port = port; 130 } 131 132 136 public final String getRawURI() 137 { 138 return _rawURI; 139 } 140 141 145 public final void setRawURI(String uri) 146 { 147 _rawURI = uri; 148 } 149 150 153 public int getURLLength() 154 { 155 if (_rawURI != null) 156 return _rawURI.length(); 157 else 158 return 0; 159 } 160 161 165 public final String getURI() 166 { 167 return _uri; 168 } 169 170 173 public final void setURI(String uri) 174 { 175 _uri = uri; 176 177 setContextURI(uri); 178 } 179 180 183 public final String getSessionId() 184 { 185 return _sessionId; 186 } 187 188 191 public final void setSessionId(String sessionId) 192 { 193 _sessionId = sessionId; 194 } 195 196 199 public final WebApp getWebApp() 200 { 201 return _webApp; 202 } 203 204 207 public void setWebApp(WebApp app) 208 { 209 _webApp = app; 210 } 211 212 215 public void setDependency(Dependency dependency) 216 { 217 _dependency = dependency; 218 } 219 220 223 public Dependency getDependency() 224 { 225 return _dependency; 226 } 227 228 232 public boolean isModified() 233 { 234 Dependency depend = _dependency; 235 236 if (depend != null && depend.isModified()) 237 return true; 238 239 WebApp app = _webApp; 240 241 if (app != null) { 242 depend = app.getInvocationDependency(); 243 244 if (depend != null) 245 return depend.isModified(); 246 } 247 248 return true; 249 } 250 251 254 public void copyFrom(Invocation invocation) 255 { 256 super.copyFrom(invocation); 257 258 _rawHost = invocation._rawHost; 259 _rawURI = invocation._rawURI; 260 261 _hostName = invocation._hostName; 262 _port = invocation._port; 263 _uri = invocation._uri; 264 265 _webApp = invocation._webApp; 266 _dependency = invocation._dependency; 267 } 268 269 272 public int hashCode() 273 { 274 int hash = _rawURI.hashCode(); 275 276 if (_rawHost != null) 277 hash = hash * 65521 + _rawHost.hashCode(); 278 279 hash = hash * 65521 + _port; 280 281 return hash; 282 } 283 284 287 public boolean equals(Object o) 288 { 289 if (this == o) 290 return true; 291 else if (o == null) 292 return false; 293 294 if (getClass() != o.getClass()) 295 return false; 296 297 Invocation inv = (Invocation) o; 298 299 if (_isSecure != inv._isSecure) 300 return false; 301 302 if (_rawURI != inv._rawURI && 303 (_rawURI == null || ! _rawURI.equals(inv._rawURI))) 304 return false; 305 306 if (_rawHost != inv._rawHost && 307 (_rawHost == null || ! _rawHost.equals(inv._rawHost))) 308 return false; 309 310 if (_port != inv._port) 311 return false; 312 313 String aQuery = getQueryString(); 314 String bQuery = inv.getQueryString(); 315 316 if (aQuery != bQuery && 317 (aQuery == null || ! aQuery.equals(bQuery))) 318 return false; 319 320 return true; 321 } 322 323 void close() 324 { 325 _webApp = null; 326 } 327 } 328 | Popular Tags |