org.apache.catalina.connector.Request.getRequestedSessionId()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(248)

本文整理了Java中org.apache.catalina.connector.Request.getRequestedSessionId方法的一些代码示例,展示了Request.getRequestedSessionId的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getRequestedSessionId方法的具体详情如下:
包路径:org.apache.catalina.connector.Request
类名称:Request
方法名:getRequestedSessionId

Request.getRequestedSessionId介绍

[英]Return the session identifier included in this request, if any.
[中]返回此请求中包含的会话标识符(如果有)。

代码示例

代码示例来源:origin: apache/geode

private void handlePossibleFailover(Request request, DeltaSessionManager manager,
  String localJvmRoute) {
 String sessionId = request.getRequestedSessionId();
 if (sessionId != null) {

代码示例来源:origin: redisson/redisson

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
  String sessionId = request.getRequestedSessionId();
  Session session = request.getContext().getManager().findSession(sessionId);
  if (session != null) {
    if (!session.isValid()) {
      session.expire();
      request.getContext().getManager().remove(session);
    } else {
      manager.add(session);
      session.access();
      session.endAccess();
    }
  }
  
  try {
    getNext().invoke(request, response);
  } finally {
    manager.store(request.getSession(false));
  }
}

代码示例来源:origin: redisson/redisson

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
  String sessionId = request.getRequestedSessionId();
  Session session = request.getContext().getManager().findSession(sessionId);
  if (session != null) {
    if (!session.isValid()) {
      session.expire();
      request.getContext().getManager().remove(session);
    } else {
      manager.add(session);
      session.access();
      session.endAccess();
    }
  }
  
  try {
    getNext().invoke(request, response);
  } finally {
    manager.store(request.getSession(false));
  }
}

代码示例来源:origin: redisson/redisson

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
  String sessionId = request.getRequestedSessionId();
  Session session = request.getContext().getManager().findSession(sessionId);
  if (session != null) {
    if (!session.isValid()) {
      session.expire();
      request.getContext().getManager().remove(session);
    } else {
      manager.add(session);
      session.access();
      session.endAccess();
    }
  }
  
  try {
    getNext().invoke(request, response);
  } finally {
    manager.store(request.getSession(false));
  }
}

代码示例来源:origin: redisson/redisson

@Override
public void invoke(Request request, Response response) throws IOException, ServletException {
  String sessionId = request.getRequestedSessionId();
  Session session = request.getContext().getManager().findSession(sessionId);
  if (session != null) {
    if (!session.isValid()) {
      session.expire();
      request.getContext().getManager().remove(session);
    } else {
      manager.add(session);
      session.access();
      session.endAccess();
    }
  }
  
  try {
    getNext().invoke(request, response);
  } finally {
    manager.store(request.getSession(false));
  }
}

代码示例来源:origin: magro/memcached-session-manager

/**
 * If there's a session for a requested session id that is taken over (tomcat failover) or
 * that will be relocated (memcached failover), the new session id will be set (via {@link Request#changeSessionId(String)}).
 *
 * @param request the request
 * @param response the response
 *
 * @return <code>true</code> if the id of a valid session was changed.
 *
 * @see Request#changeSessionId(String)
 */
private boolean changeRequestedSessionId( final Request request, final Response response ) {
  /*
   * Check for session relocation only if a session id was requested
   */
  if ( request.getRequestedSessionId() != null ) {
    String newSessionId = _sessionBackupService.changeSessionIdOnTomcatFailover( request.getRequestedSessionId() );
    if ( newSessionId == null ) {
      newSessionId = _sessionBackupService.changeSessionIdOnMemcachedFailover( request.getRequestedSessionId() );
    }
    if ( newSessionId != null ) {
      request.changeSessionId( newSessionId );
      return true;
    }
  }
  return false;
}

代码示例来源:origin: magro/memcached-session-manager

private String getSessionId(final Request request, final Response response) {
  // If the context is configured with cookie="false" there's no session cookie
  // sent so we must rely on data from MemcachedSessionService
  String sessionId = (String) request.getNote(MemcachedSessionService.NEW_SESSION_ID);
  if(sessionId == null) {
    sessionId = getSessionIdFromResponseSessionCookie( response );
  }
  return sessionId != null ? sessionId : request.getRequestedSessionId();
}

代码示例来源:origin: magro/memcached-session-manager

@Test
public final void testRequestFinishedShouldBeInvokedForIgnoredResources() throws IOException, ServletException {
  when( _request.getRequestedSessionId() ).thenReturn( "foo" );
  when(_request.getRequestURI()).thenReturn("/pixel.gif");
  _sessionTrackerValve.invoke( _request, _response );
  verify( _service ).requestFinished( eq( "foo" ), anyString() );
}

代码示例来源:origin: magro/memcached-session-manager

@Test
public final void testChangeSessionIdForRelocatedSession() throws IOException, ServletException {
  final String sessionId = "bar";
  final String newSessionId = "newId";
  when( _request.getRequestedSessionId() ).thenReturn( sessionId );
  when( _service.changeSessionIdOnMemcachedFailover( eq( sessionId ) ) ).thenReturn( newSessionId );
  _sessionTrackerValve.invoke( _request, _response );
  verify( _request ).changeSessionId( eq( newSessionId ) );
  verify(_request).setNote(eq(RequestTrackingHostValve.SESSION_ID_CHANGED), eq(Boolean.TRUE));
}

代码示例来源:origin: magro/memcached-session-manager

@Test
public final void testBackupSessionNotInvokedWhenNoSessionIdPresent() throws IOException, ServletException {
  when( _request.getRequestedSessionId() ).thenReturn( null );
  when( _response.getHeader( eq( "Set-Cookie" ) ) ).thenReturn( null );
  _sessionTrackerValve.invoke( _request, _response );
  verify( _service, never() ).backupSession( anyString(), anyBoolean(), anyString() );
}

代码示例来源:origin: magro/memcached-session-manager

@Test
public final void testChangeSessionIdForRelocatedSession() throws IOException, ServletException {
  final String sessionId = "bar";
  final String newSessionId = "newId";
  when(_request.getNote(eq(RequestTrackingHostValve.SESSION_ID_CHANGED))).thenReturn(Boolean.TRUE);
  when( _request.getRequestedSessionId() ).thenReturn( sessionId );
  final Cookie cookie = new Cookie( _sessionTrackerValve.getSessionCookieName(), newSessionId );
  setupGetResponseSetCookieHeadersExpectations(_response, new String[]{generateCookieString( cookie )});
  _sessionTrackerValve.invoke( _request, _response );
  verify( _service ).backupSession( eq( newSessionId ), eq( true ), anyString() );
}

代码示例来源:origin: magro/memcached-session-manager

@Test
public final void testBackupSessionInvokedWhenResponseCookiePresent() throws IOException, ServletException {
  when( _request.getRequestedSessionId() ).thenReturn( null );
  final Cookie cookie = new Cookie( _sessionTrackerValve.getSessionCookieName(), "foo" );
  setupGetResponseSetCookieHeadersExpectations(_response, new String[]{generateCookieString( cookie )});
  _sessionTrackerValve.invoke( _request, _response );
  verify( _service ).backupSession( eq( "foo" ), eq( false), anyString() );
}

代码示例来源:origin: org.apache.geronimo.modules/geronimo-tomcat7-clustering-wadi

public String getRequestedSessionId() {
    if (null == request) {
      return null;
    }
    return request.getRequestedSessionId();
  }
}

代码示例来源:origin: org.jboss.web/jbossweb

public void addElement(StringBuilder buf, Date date,
      Request request, Response response, long time) {
    buf.append(wrap(request.getRequestedSessionId()));
  }
};

代码示例来源:origin: magro/memcached-session-manager

} else if ( _ignorePattern != null && _ignorePattern.matcher( requestId ).matches() ) {
  if(_log.isDebugEnabled()) {
    _log.debug( ">>>>>> Ignoring: " + requestId + " (requestedSessionId "+ request.getRequestedSessionId() +") ==================" );
    _log.debug( ">>>>>> Request starting: " + requestId + " (requestedSessionId "+ request.getRequestedSessionId() +") ==================" );

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
public String getRequestedSessionId() {
  if (request == null) {
    throw new IllegalStateException(
            sm.getString("requestFacade.nullRequest"));
  }
  return request.getRequestedSessionId();
}

代码示例来源:origin: org.jboss.web/jbossweb

public String getRequestedSessionId() {
  if (request == null) {
    throw MESSAGES.nullRequestFacade();
  }
  return request.getRequestedSessionId();
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

@Override
public String getRequestedSessionId() {
  if (request == null) {
    throw new IllegalStateException(
            sm.getString("requestFacade.nullRequest"));
  }
  return request.getRequestedSessionId();
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

@Override
public String getRequestedSessionId() {
  if (request == null) {
    throw new IllegalStateException(
            sm.getString("requestFacade.nullRequest"));
  }
  return request.getRequestedSessionId();
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
  public void addElement(CharArrayWriter buf, Date date,
      Request request, Response response, long time) {
    buf.append(wrap(request.getRequestedSessionId()));
  }
};

相关文章

Request类方法