當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。