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


Java ContainerRequestContext.setProperty方法代码示例

本文整理汇总了Java中javax.ws.rs.container.ContainerRequestContext.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ContainerRequestContext.setProperty方法的具体用法?Java ContainerRequestContext.setProperty怎么用?Java ContainerRequestContext.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.container.ContainerRequestContext的用法示例。


在下文中一共展示了ContainerRequestContext.setProperty方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext context) throws IOException {
    if (!shouldFilter(context, resourceInfo)) {
        // do nothing if the filter doesn't apply
        return;
    }

    try {
        Tracer.SpanBuilder builder = tracer.buildSpan(getOperationName(context, resourceInfo))
            .withTag(Tags.SPAN_KIND.getKey(), Tags.SPAN_KIND_SERVER)
            .withTag(Tags.HTTP_METHOD.getKey(), context.getMethod())
            .withTag(Tags.HTTP_URL.getKey(), context.getUriInfo().getAbsolutePath().toString());

        builder.asChildOf(tracer.extract(Format.Builtin.HTTP_HEADERS, new ContainerRequestContextTextMap(context)));
        final Span span = builder.startManual();

        context.setProperty(SERVER_SPAN_CONTEXT_KEY, span);
    } catch (Exception e) {
        LOGGER.error("Server Request Filter failed", e);
    }
}
 
开发者ID:ExpediaDotCom,项目名称:haystack-client-java,代码行数:22,代码来源:ServerFilter.java

示例2: checkOrigin

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
protected void checkOrigin(ContainerRequestContext requestContext, String origin) {
    if (!allowedOrigins.contains("*") && !allowedOrigins.contains(origin)) {
        requestContext.setProperty("cors.failure", true);
        throw new ForbiddenException("Origin not allowed: " + origin);
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:7,代码来源:CorsFilter.java

示例3: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(final ContainerRequestContext ctx) throws IOException {
    final SecurityContext sec = ctx.getSecurityContext();
    LOGGER.debug("Checking security context: {}", sec.getUserPrincipal());
    if (isNull(sec.getUserPrincipal())) {
        ctx.setProperty(SESSION_PROPERTY, new HttpSession());
    } else if (adminUsers.contains(sec.getUserPrincipal().getName())) {
        ctx.setProperty(SESSION_PROPERTY, new HttpSession(AdministratorAgent));
    } else if (sec.getUserPrincipal().getName().isEmpty()) {
        ctx.setProperty(SESSION_PROPERTY, new HttpSession());
    } else {
        ctx.setProperty(SESSION_PROPERTY, new HttpSession(agentService.asAgent(sec.getUserPrincipal().getName())));
    }
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:15,代码来源:AgentAuthorizationFilter.java

示例4: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
  String correlationId = requestContext.getHeaderString(headerName);
  if (correlationId == null) {
    correlationId = UUID.randomUUID().toString();
  }
  requestContext.setProperty(mdcName, correlationId);
  MDC.put(mdcName, correlationId);
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:10,代码来源:CorrelationIdFilter.java

示例5: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
    HttpContextHelper.put(grizzlyRequestProvider.get());
    if (!whiteSheetVerifier(grizzlyRequestProvider.get())) {
        throw new NulsRuntimeException(ErrorCode.REQUEST_DENIED);
    }
    requestContext.setProperty("start", System.currentTimeMillis());
}
 
开发者ID:nuls-io,项目名称:nuls,代码行数:9,代码来源:RpcServerFilter.java

示例6: get

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public Object get(final String name,
    final ObjectFactory<?> objectFactory) {

    final ContainerRequestContext containerRequest = containerRequestHolder.get();
    Object scopedObject = containerRequest.getProperty(name);
    if (scopedObject == null) {
        scopedObject = objectFactory.getObject();
        containerRequest.setProperty(name, scopedObject);
    }
    return scopedObject;
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:13,代码来源:ContainerRequestScope.java

示例7: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext request) {
    MDC.put(USERNAME, getUsername(servletRequest));

    if (request.getProperty(START_TIME) == null) {
        request.setProperty(START_TIME, System.currentTimeMillis());
    } else {
        log.warn("{} is already set -- possible configuration error", START_TIME);
    }
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:11,代码来源:SimpleAccessLoggingFilter.java

示例8: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
	String calledMethod = requestContext.getMethod();
	requestContext.setProperty("calledMethod", calledMethod);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:6,代码来源:RegisterCall.java

示例9: setRequestContext

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
public static void setRequestContext(final ContainerRequestContext containerRequest) {

        containerRequestHolder.set(containerRequest);
        containerRequest.setProperty(DESTRUCTION_CALLBACK_PROPERTY, new HashMap<String, Runnable>());
    }
 
开发者ID:trajano,项目名称:app-ms,代码行数:6,代码来源:ContainerRequestScope.java

示例10: filter

import javax.ws.rs.container.ContainerRequestContext; //导入方法依赖的package包/类
@Override
public void filter(ContainerRequestContext request) throws IOException {
    if (serverLogger.fastTrackFilters.stream().anyMatch(it -> it.test(request))) {
        return;
    }

    Class<?> handlingClass = resourceInfo.getResourceClass();
    Method handlingMethod = resourceInfo.getResourceMethod();

    LogParams logParams = serverLogger.LogParamsForCall(handlingClass, handlingMethod);

    if (! logParams.enableLogging) {
        return;
    }

    request.setProperty(PROPERTYNAME, System.nanoTime());

    LogRequest.LogRequestBuilder logRequest = LogRequest.builder();

    logRequest.uri(getUri(request));

    UibBruker uibBruker = uibBrukerProvider.get();
    if (uibBruker != null) {
        List<String> bruker = Lists.newArrayList();
        bruker.add(uibBruker.fornavn + " " + uibBruker.etternavn);
        if (! Strings.isNullOrEmpty(uibBruker.adBrukernavn)) {
            bruker.add(uibBruker.adBrukernavn);
        }
        if (! Strings.isNullOrEmpty(uibBruker.personid)) {
            bruker.add(uibBruker.personid);
        }
        logRequest.user(Joiner.on(", ").join(bruker));
    }


    String headerString = request.getHeaderString(Constants.CLIENT_APPNAME_HEADER);
    if (Strings.isNullOrEmpty(headerString)) {
        logRequest.clientApplication(headerString);
    }

    if (logParams.logHeaders) {
        Map<String, String> headers = FormatUtil.MultiMapAsStringMap(request.getHeaders());
        logRequest.headers((ImmutableMap.copyOf(headers)));
    }



    if (logParams.logRequestPayload) {
        logRequest.entity(extractRequestEntity(request));
    }

    serverLogger.handleRequest(logRequest.build(), logParams);
}
 
开发者ID:code-obos,项目名称:servicebuilder,代码行数:54,代码来源:ServerLogFilter.java


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