@Nonnull protected RequestTrackingHostValve createSessionTrackerValve() { return new RequestTrackingHostValve(".*\\.(png|gif|jpg|css|js|ico)$", "somesessionid", _service, Statistics.create(), new AtomicBoolean( true ), new CurrentRequest()) { @Override protected String[] getSetCookieHeaders(final Response response) { return RequestTrackingHostValveTest.this.getSetCookieHeaders(response); } }; }
/** * Determines if the request has already passed the RequestTrackerHostValve or not. * If not, e.g. CoyoteAdapter.parseSessionCookiesId (invoked from CoyoteAdapter.postParseRequest) might ask * for the session. */ private boolean isConnectorSessionLookup() { return _currentRequest.get() == null; }
void resetRequestThreadLocal() { _currentRequest.reset(); }
void storeRequestThreadLocal( @Nonnull final Request request ) { _currentRequest.set( request ); }
void storeRequestThreadLocal( @Nonnull final Request request ) { _currentRequest.set( request ); }
@Test public final void testGetSessionCookieName() throws IOException, ServletException { final RequestTrackingHostValve cut = new RequestTrackingHostValve(null, "foo", _service, Statistics.create(), new AtomicBoolean( true ), new CurrentRequest()) { @Override protected String[] getSetCookieHeaders(final Response response) { final Collection<String> result = response.getHeaders("Set-Cookie"); return result.toArray(new String[result.size()]); } }; assertEquals(cut.getSessionCookieName(), "foo"); }
/** * Is used to determine if this thread / the current request already hit the application or if this method * invocation comes from the container. */ private boolean isContainerSessionLookup() { return !_trackingContextValve.wasInvokedWith(_currentRequest.get()); }
void resetRequestThreadLocal() { _currentRequest.reset(); }
_currentRequest = new CurrentRequest(); _trackingHostValve = createRequestTrackingHostValve(sessionCookieName, _currentRequest); final Context context = _manager.getContext();
public boolean isIgnoredRequest() { final Request request = _currentRequest.get(); return request != null && request.getNote(REQUEST_IGNORED) == Boolean.TRUE; }
_currentRequest = new CurrentRequest(); _trackingHostValve = createRequestTrackingHostValve(sessionCookieName, _currentRequest); final Context context = _manager.getContext();
@Override protected LockStatus onBeforeLoadFromMemcached( final String sessionId ) throws InterruptedException, ExecutionException { final Request request = _currentRequest.get(); if ( request == null ) { throw new RuntimeException( "There's no request set, this indicates that this findSession" + "was triggered by the container which should already be handled in findSession." ); } /* let's see if we should lock the session for this request */ if ( _uriPattern.matcher( RequestTrackingHostValve.getURIWithQueryString( request ) ).matches() ) { if ( _log.isDebugEnabled() ) { _log.debug( "Lock request for request " + RequestTrackingHostValve.getURIWithQueryString( request ) ); } return lock( sessionId ); } if ( _log.isDebugEnabled() ) { _log.debug( "Not lock request for request " + RequestTrackingHostValve.getURIWithQueryString( request ) ); } _stats.nonStickySessionsReadOnlyRequest(); return LockStatus.LOCK_NOT_REQUIRED; }
@Override protected LockStatus onBeforeLoadFromMemcached( final String sessionId ) throws InterruptedException, ExecutionException { final Request request = _currentRequest.get(); if ( request == null ) { throw new RuntimeException( "There's no request set, this indicates that this findSession" + "was triggered by the container which should already be handled in findSession." ); } /* lets see if we can skip the locking as we consider this beeing a readonly request */ if ( _readOnlyRequestCache.isReadOnlyRequest( RequestTrackingHostValve.getURIWithQueryString( request ) ) ) { if ( _log.isDebugEnabled() ) { _log.debug( "Not getting lock for readonly request " + RequestTrackingHostValve.getURIWithQueryString( request ) ); } _stats.nonStickySessionsReadOnlyRequest(); return LockStatus.LOCK_NOT_REQUIRED; } return lock( sessionId ); }
/** * Determines if the request has already passed the RequestTrackerHostValve or not. * If not, e.g. CoyoteAdapter.parseSessionCookiesId (invoked from CoyoteAdapter.postParseRequest) might ask * for the session. */ private boolean isConnectorSessionLookup() { return _currentRequest.get() == null; }
/** * Is used to determine if this thread / the current request already hit the application or if this method * invocation comes from the container. */ private boolean isContainerSessionLookup() { return !_trackingContextValve.wasInvokedWith(_currentRequest.get()); }
public boolean isIgnoredRequest() { final Request request = _currentRequest.get(); return request != null && request.getNote(REQUEST_IGNORED) == Boolean.TRUE; }
final Request request = _currentRequest.get(); if(request != null) { request.setNote(NEW_SESSION_ID, sessionId);
@Override protected LockStatus onBeforeLoadFromMemcached( final String sessionId ) throws InterruptedException, ExecutionException { final Request request = _currentRequest.get(); if ( request == null ) { throw new RuntimeException( "There's no request set, this indicates that this findSession" + "was triggered by the container which should already be handled in findSession." ); } /* let's see if we should lock the session for this request */ if ( _uriPattern.matcher( RequestTrackingHostValve.getURIWithQueryString( request ) ).matches() ) { if ( _log.isDebugEnabled() ) { _log.debug( "Lock request for request " + RequestTrackingHostValve.getURIWithQueryString( request ) ); } return lock( sessionId ); } if ( _log.isDebugEnabled() ) { _log.debug( "Not lock request for request " + RequestTrackingHostValve.getURIWithQueryString( request ) ); } _stats.nonStickySessionsReadOnlyRequest(); return LockStatus.LOCK_NOT_REQUIRED; }
@Override protected LockStatus onBeforeLoadFromMemcached( final String sessionId ) throws InterruptedException, ExecutionException { final Request request = _currentRequest.get(); if ( request == null ) { throw new RuntimeException( "There's no request set, this indicates that this findSession" + "was triggered by the container which should already be handled in findSession." ); } /* lets see if we can skip the locking as we consider this beeing a readonly request */ if ( _readOnlyRequestCache.isReadOnlyRequest( RequestTrackingHostValve.getURIWithQueryString( request ) ) ) { if ( _log.isDebugEnabled() ) { _log.debug( "Not getting lock for readonly request " + RequestTrackingHostValve.getURIWithQueryString( request ) ); } _stats.nonStickySessionsReadOnlyRequest(); return LockStatus.LOCK_NOT_REQUIRED; } return lock( sessionId ); }
final Request request = _currentRequest.get(); if(request != null) { request.setNote(NEW_SESSION_ID, sessionId);