当前位置: 首页>>代码示例>>Java>>正文


Java IAccessEvent类代码示例

本文整理汇总了Java中ch.qos.logback.access.spi.IAccessEvent的典型用法代码示例。如果您正苦于以下问题:Java IAccessEvent类的具体用法?Java IAccessEvent怎么用?Java IAccessEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IAccessEvent类属于ch.qos.logback.access.spi包,在下文中一共展示了IAccessEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: postInvoke

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
@Override
public void postInvoke(Request request, Response response)
        throws IOException, ServletException {
    final HttpServletRequest httpRequest = (HttpServletRequest) request.getRequest();
    try {
        CatalinaAdapter adapter = new CatalinaAdapter(request, response);
        IAccessEvent accessEvent = new AccessEvent(httpRequest, (HttpServletResponse) response.getResponse(),
            adapter);

        if (ctx.getFilterChainDecision(accessEvent) == FilterReply.DENY) {
            return;
        }

        // TODO better tion handling
        ctx.callAppenders(accessEvent);
    } finally {
        httpRequest.removeAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
    }
}
 
开发者ID:goodees,项目名称:goodees,代码行数:20,代码来源:CatalinaValve.java

示例2: logbackAccessEvent

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void logbackAccessEvent() {

    RequestEntity<Void> request = RequestEntity
            .get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text"))
            .header("X-Forwarded-Port", "12345")
            .header("X-Forwarded-For", "1.2.3.4")
            .header("X-Forwarded-Proto", "https")
            .build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();

    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event)
            .hasServerName("localhost")
            .hasLocalPort(12345)
            .hasRemoteAddr("1.2.3.4")
            .hasRemoteHost("1.2.3.4")
            .hasProtocol("HTTP/1.1");

}
 
开发者ID:akihyro,项目名称:logback-access-spring-boot-starter,代码行数:24,代码来源:TomcatForwardHeadersUsingTest.java

示例3: convert

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
@Override
public String convert(IAccessEvent ae) {
  StringBuilder buf = new StringBuilder();
  
  buf.append("HTTP/1.1 ");
  int statusCode = ae.getStatusCode();
  buf.append(statusCode);
  buf.append(" ");
  buf.append(getStatusCodeDescription(statusCode));
  buf.append(CoreConstants.LINE_SEPARATOR);
  
  List<String> hnList = ae.getResponseHeaderNameList();
  for(String headerName: hnList) {
    buf.append(headerName);
    buf.append(": ");
    buf.append(ae.getResponseHeader(headerName));
    buf.append(CoreConstants.LINE_SEPARATOR);
  }
  buf.append(CoreConstants.LINE_SEPARATOR);
  buf.append(ae.getResponseContent());
  buf.append(CoreConstants.LINE_SEPARATOR);
  return buf.toString();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:24,代码来源:FullResponseConverter.java

示例4: logbackAccessEventWithoutContentLengthResponseHeader

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
/**
 * Tests a Logback-access event without a response header of content length.
 */
@Test
public void logbackAccessEventWithoutContentLengthResponseHeader() {

    ResponseEntity<String> response = rest.getForEntity("/test/json", String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();

    assertThat(response)
            .hasStatusCode(HttpStatus.OK)
            .doesNotHaveContentLengthHeader()
            .hasBody("{\"TEST-KEY\":\"TEST-VALUE\"}");
    assertThat(event)
            .hasContentLength("{\"TEST-KEY\":\"TEST-VALUE\"}".getBytes(StandardCharsets.UTF_8).length);

}
 
开发者ID:akihyro,项目名称:logback-access-spring-boot-starter,代码行数:19,代码来源:AbstractLogbackAccessEventsTest.java

示例5: convert

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
@Override
  public String convert(IAccessEvent accessEvent) {
    if(!isStarted()) {
      return "INACTIVE_REPONSE_HEADER_CONV";
    }
    
    return accessEvent.getResponseHeader(key);
    //return null;
    
//    HttpServletResponse response = accessEvent.getHttpResponse();
//
//    Object value = null; // = response.getHeader(key);
//    if (value == null) {
//      return AccessConverter.NA;
//    } else {
//      return value.toString();
//    }
  }
 
开发者ID:cscfa,项目名称:bartleby,代码行数:19,代码来源:ResponseHeaderConverter.java

示例6: logbackAccessEventWithRequestHeader

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
/**
 * Tests a Logback-access event with a request header.
 */
@Test
public void logbackAccessEventWithRequestHeader() {

    RequestEntity<Void> request = RequestEntity
            .get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text"))
            .header("X-Test-Header", "TEST-HEADER")
            .build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();

    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event)
            .hasRequestHeaderName("X-Test-Header")
            .hasRequestHeader("X-Test-Header", "TEST-HEADER")
            .hasRequestHeaderInMap("X-Test-Header", "TEST-HEADER");

}
 
开发者ID:akihyro,项目名称:logback-access-spring-boot-starter,代码行数:22,代码来源:AbstractLogbackAccessEventsTest.java

示例7: logbackAccessEvent

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void logbackAccessEvent() {

    RequestEntity<Void> request = RequestEntity
            .get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text"))
            .header("X-Forwarded-Host", "forwarded-host")
            .header("X-Forwarded-Port", "12345")
            .build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();

    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event).hasLocalPort(port);

}
 
开发者ID:akihyro,项目名称:logback-access-spring-boot-starter,代码行数:18,代码来源:UndertowServerPortUnusingTest.java

示例8: logbackAccessEvent

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
/**
 * Tests a Logback-access event.
 */
@Test
public void logbackAccessEvent() {

    RequestEntity<Void> request = RequestEntity
            .get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text"))
            .header("X-Forwarded-Port", "12345")
            .header("X-Forwarded-For", "1.2.3.4")
            .header("X-Forwarded-Proto", "https")
            .build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();

    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event)
            .hasServerName("localhost")
            .hasLocalPort(port)
            .hasRemoteAddr("127.0.0.1")
            .hasRemoteHost("127.0.0.1")
            .hasProtocol("HTTP/1.1");

}
 
开发者ID:akihyro,项目名称:logback-access-spring-boot-starter,代码行数:26,代码来源:TomcatRequestAttributesDisablingTest.java

示例9: logbackAccessEvent

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void logbackAccessEvent() {

    RequestEntity<Void> request = RequestEntity
            .get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text"))
            .header("X-Forwarded-Host", "forwarded-host:12345")
            .build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();

    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event).hasLocalPort(port);

}
 
开发者ID:akihyro,项目名称:logback-access-spring-boot-starter,代码行数:17,代码来源:JettyServerPortUnusingTest.java

示例10: getRawDiscriminatingValue

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
public String getRawDiscriminatingValue(IAccessEvent acccessEvent) {
  switch (fieldName) {
  case COOKIE:
    // tested
    return acccessEvent.getCookie(additionalKey);
  case LOCAL_PORT:
    return String.valueOf(acccessEvent.getLocalPort());
  case REQUEST_ATTRIBUTE:
    // tested
    return getRequestAttribute(acccessEvent);
  case SESSION_ATTRIBUTE:
    return getSessionAttribute(acccessEvent);
  case REMOTE_ADDRESS:
    return acccessEvent.getRemoteAddr();
  case REQUEST_URI:
    // tested
    return getRequestURI(acccessEvent);
  default:
    return null;
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:22,代码来源:AccessEventDiscriminator.java

示例11: getSessionAttribute

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
private String getSessionAttribute(IAccessEvent acccessEvent) {
  HttpServletRequest req = acccessEvent.getRequest();
  if (req != null) {
    HttpSession session = req.getSession(false);
    if (session != null) {
      if ("id".equalsIgnoreCase(additionalKey)) {
        return session.getId();
      } else {
        Object v = session.getAttribute(additionalKey);
        if (v != null) {
          return v.toString();
        }
      }
    }
  }
  return null;
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:18,代码来源:AccessEventDiscriminator.java

示例12: testCheckNoHeadersAreInserted

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
@Test
public void testCheckNoHeadersAreInserted() throws Exception {
  setInsertHeadersAndStart(false);

  IAccessEvent event = createAccessEvent();
  appender.append(event);
  StatusPrinter.print(context.getStatusManager());

  //Check that no headers were inserted
  Statement stmt = connectionSource.getConnection().createStatement();
  ResultSet rs = null;
  rs = stmt.executeQuery("SELECT * FROM access_event_header where EVENT_ID = " + existingEventTableRowCount);

  assertFalse(rs.next());
  rs.close();
  stmt.close();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:18,代码来源:DBAppenderHSQLTest.java

示例13: logbackAccessEvent

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void logbackAccessEvent() {

    RequestEntity<Void> request = RequestEntity
            .get(rest.getRestTemplate().getUriTemplateHandler().expand("/test/text"))
            .header("X-Forwarded-Port", "12345")
            .build();
    ResponseEntity<String> response = rest.exchange(request, String.class);
    IAccessEvent event = LogbackAccessEventQueuingAppender.appendedEventQueue.pop();
    LogbackAccessEventQueuingListener.appendedEventQueue.pop();

    assertThat(response).hasStatusCode(HttpStatus.OK);
    assertThat(event).hasLocalPort(port);

}
 
开发者ID:akihyro,项目名称:logback-access-spring-boot-starter,代码行数:17,代码来源:TomcatServerPortUnusingTest.java

示例14: testAppendMultipleEvents

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
@Test
public void testAppendMultipleEvents() throws SQLException {
  setInsertHeadersAndStart(false);
  String uri = "testAppendMultipleEvents";
  for (int i = 0; i < 10; i++) {
    IAccessEvent event = createAccessEvent(uri);
    appender.append(event);
  }

  StatusPrinter.print(context);

  Statement stmt = connectionSource.getConnection().createStatement();
  ResultSet rs = null;
  rs = stmt.executeQuery("SELECT * FROM access_event where requestURI='" + uri + "'");
  int count = 0;
  while (rs.next()) {
    count++;
  }
  assertEquals(10, count);

  rs.close();
  stmt.close();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:24,代码来源:DBAppenderHSQLTest.java

示例15: doTest

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
public void doTest(String configFile) throws JoranException {
  JoranConfigurator configurator = new JoranConfigurator();
  configurator.setContext(context);
  configurator.doConfigure(configFile);

  Appender<IAccessEvent> appender = context.getAppender("DB");
  
  for (int i = 0; i < 10; i++) {
    IAccessEvent event = DummyAccessEventBuilder.buildNewAccessEvent();
    appender.doAppend(event);
  }
  
  StatusPrinter.print(context);
  
  // check that there were no errors
  assertEquals(Status.INFO,  statusChecker.getHighestLevel(0));
  
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:19,代码来源:DBAppenderIntegrationTest.java


注:本文中的ch.qos.logback.access.spi.IAccessEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。