• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IAccessEvent类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: configureRequestLogImpl

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
@Override
protected void configureRequestLogImpl() {
  NotifyingListAppender appender = new NotifyingListAppender();
  appender.setContext(requestLogImpl);
  appender.setName("list");
  appender.start();

  ConsoleAppender<IAccessEvent> console = new ConsoleAppender<IAccessEvent>();
  console.setContext(requestLogImpl);
  console.setName("console");
  PatternLayoutEncoder layout = new PatternLayoutEncoder();
  layout.setContext(requestLogImpl);
  layout.setPattern("%date %server %clientHost");
  console.setEncoder(layout);
  layout.start();
  console.start();

  requestLogImpl.addAppender(appender);
  requestLogImpl.addAppender(console);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:21,代码来源:JettyFixtureWithListAndConsoleAppenders.java


示例17: eventGoesToAppenders

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
@Test
public void eventGoesToAppenders() throws Exception {
  URL url = new URL(JETTY_FIXTURE.getUrl());
  HttpURLConnection connection = (HttpURLConnection) url.openConnection();
  connection.setDoInput(true);

  String result = Util.readToString(connection.getInputStream());

  assertEquals("hello world", result);

  NotifyingListAppender listAppender = (NotifyingListAppender) REQYEST_LOG_IMPL
      .getAppender("list");
  synchronized (listAppender) {
    listAppender.wait(100);
  }

  assertTrue(listAppender.list.size() > 0);
  IAccessEvent event = listAppender.list.get(0);
  assertEquals("127.0.0.1", event.getRemoteHost());
  assertEquals("localhost", event.getServerName());
  listAppender.list.clear();
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:23,代码来源:JettyBasicTest.java


示例18: build

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
public Appender<IAccessEvent> build(
    LoggerContext context,
    String applicationName,
    LayoutFactory<IAccessEvent> layoutFactory,
    LevelFilterFactory<IAccessEvent> levelFilterFactory,
    AsyncAppenderFactory<IAccessEvent> asyncAppenderFactory
  ) {

  final AccessEventCompositeJsonEncoder encoder = new AccessEventCompositeJsonEncoder();
  encoder.setContext(context);

  encoder.getProviders().addProvider(withPattern("{ \"type\": \"access\" }", new AccessEventPatternJsonProvider(), context));
  encoder.getProviders().addProvider(withName("timestamp" ,new AccessEventFormattedTimestampJsonProvider(), context));
  encoder.getProviders().addProvider(withName("status", new StatusCodeJsonProvider(), context));
  encoder.getProviders().addProvider(withName("method", new MethodJsonProvider(), context));
  encoder.getProviders().addProvider(withName("protocol", new ProtocolJsonProvider(), context));
  encoder.getProviders().addProvider(withName("uri", new RequestedUriJsonProvider(), context));
  encoder.getProviders().addProvider(withName("client-ip", new RemoteHostJsonProvider(), context));
  encoder.getProviders().addProvider(withName("user", new RemoteUserJsonProvider(), context));
  encoder.getProviders().addProvider(withName("elapsed-time", new ElapsedTimeJsonProvider(), context));
  encoder.getProviders().addProvider(withName("content-length", new ContentLengthJsonProvider(), context));
  encoder.getProviders().addProvider(withPattern("{ \"user-agent\": \"%i{User-Agent}\" }", new AccessEventPatternJsonProvider(), context));
  encoder.start();

  final ConsoleAppender<IAccessEvent> appender = new ConsoleAppender<>();
  appender.setContext(context);
  appender.setEncoder(encoder);
  appender.start();

  return wrapAsync(appender, asyncAppenderFactory);
}
 
开发者ID:atgse,项目名称:sam,代码行数:32,代码来源:JsonAccessLogAppender.java


示例19: withPattern

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
private AbstractPatternJsonProvider<IAccessEvent> withPattern(
    String pattern,
    AbstractPatternJsonProvider<IAccessEvent> provider,
    LoggerContext context
  ) {

  provider.setContext(context);
  provider.setPattern(pattern);
  return provider;
}
 
开发者ID:atgse,项目名称:sam,代码行数:11,代码来源:JsonAccessLogAppender.java


示例20: convert

import ch.qos.logback.access.spi.IAccessEvent; //导入依赖的package包/类
@Override
public String convert(IAccessEvent accessEvent) {
  
  String user = accessEvent.getRemoteUser();
  if(user == null) {
    return IAccessEvent.NA;
  } else {
    return user;
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:11,代码来源:RemoteUserConverter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SpanInjector类代码示例发布时间:2022-05-22
下一篇:
Java InkscapeLoader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap