org.wso2.msf4j.Request.setProperty()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(140)

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

Request.setProperty介绍

[英]Set a property in the underlining Carbon Message.
[中]在带下划线的碳素消息中设置属性。

代码示例

代码示例来源:origin: wso2/msf4j

/**
   * Stores an attribute in this request.
   *
   * @param name a {@link String} specifying the name of the attribute
   * @param obj  the {@link Object} to be stored
   */
  public void setAttribute(String name, Object obj) {
    request.setProperty(name, obj);
  }
}

代码示例来源:origin: org.wso2.msf4j/msf4j-core

/**
   * Stores an attribute in this request.
   *
   * @param name a {@link String} specifying the name of the attribute
   * @param obj  the {@link Object} to be stored
   */
  public void setAttribute(String name, Object obj) {
    request.setProperty(name, obj);
  }
}

代码示例来源:origin: wso2/msf4j

@Override
  public boolean interceptRequest(Request request, Response response) throws Exception {
    String propertyName = "SampleProperty";
    String property = "Sample Object";
    request.setProperty(propertyName, property);
    log.info("Property {} set to request", propertyName);
    return true;
  }
}

代码示例来源:origin: wso2/msf4j

@Override
  public boolean interceptRequest(Request request, Response response) throws Exception {
    String propertyName = "SampleProperty";
    String property = "Sample Object";
    request.setProperty(propertyName, property);
    log.info("Property {} set to request", propertyName);
    return true;
  }
}

代码示例来源:origin: org.wso2.msf4j.samples/interceptor-common

@Override
  public boolean interceptRequest(Request request, Response response) throws Exception {
    String propertyName = "SampleProperty";
    String property = "Sample Object";
    request.setProperty(propertyName, property);
    log.info("Property {} set to request", propertyName);
    return true;
  }
}

代码示例来源:origin: org.wso2.carbon.auth/org.wso2.carbon.auth.rest.api.commons

boolean authenticated = userStoreManager.doAuthenticate(username, password);
if (authenticated) {
  request.setProperty(RestAPIConstants.LOGGED_IN_USER, username);
  request.setProperty(RestAPIConstants.LOGGED_IN_PSEUDO_USER, userNameMapper
      .getLoggedInPseudoNameFromUserID(username));
  return true;

代码示例来源:origin: org.wso2.carbon.auth/org.wso2.carbon.auth.rest.api.commons

boolean authenticated = introspectionResponse.isActive();
if (authenticated) {
  request.setProperty(RestAPIConstants.LOGGED_IN_USER, introspectionResponse.getUsername());
  try {
    request.setProperty(RestAPIConstants.LOGGED_IN_PSEUDO_USER, userNameMapper
        .getLoggedInPseudoNameFromUserID(introspectionResponse.getUsername()));
  } catch (AuthException e) {

代码示例来源:origin: wso2/msf4j

Request request, MicroservicesRegistryImpl microservicesRegistry, boolean isSubResource) throws Exception {
Class<?> clazz = httpMethodInfo.method.getDeclaringClass();
request.setProperty(MSF4JConstants.METHOD_PROPERTY_NAME, httpMethodInfo.method); // Required for analytics

代码示例来源:origin: org.wso2.msf4j/msf4j-core

Request request, MicroservicesRegistryImpl microservicesRegistry, boolean isSubResource) throws Exception {
Class<?> clazz = httpMethodInfo.method.getDeclaringClass();
request.setProperty(MSF4JConstants.METHOD_PROPERTY_NAME, httpMethodInfo.method); // Required for analytics

代码示例来源:origin: org.wso2.carbon.analytics-common/org.wso2.carbon.analytics.msf4j.interceptor.common

String username = idPClient.authenticate(accessToken);
  if (username != null) {
    request.setProperty(InterceptorConstants.PROPERTY_USERNAME, username);
    return true;
    return false;
  request.setProperty(InterceptorConstants.PROPERTY_USERNAME, userName);
  return true;
} else {

代码示例来源:origin: org.wso2.carbon.auth/org.wso2.carbon.auth.rest.api.authenticators

/**
 * Get defined HTTP methods in the swagger definition as a comma separated string
 *
 * @param request Request
 * @return Http Methods as a comma separated string
 */
public static RestAPIInfo getElectedRestApiInfo(Request request) {
  if (request.getProperty(RestAPIConstants.ELECTED_BASE_PATH) != null) {
    return ServiceReferenceHolder.getInstance().getSwaggerDefinitionMap().get(request.getProperty
        (RestAPIConstants.ELECTED_BASE_PATH));
  }
  String requestURI = request.getUri().toLowerCase(Locale.ENGLISH);
  RestAPIInfo electedSwagger = null;
  for (String basePath : ServiceReferenceHolder.getInstance().getSwaggerDefinitionMap().keySet()) {
    if (requestURI.contains(basePath)) {
      electedSwagger = ServiceReferenceHolder.getInstance().getSwaggerDefinitionMap().get(basePath);
      break;
    }
  }
  if (electedSwagger != null) {
    request.setProperty(RestAPIConstants.ELECTED_BASE_PATH, electedSwagger.getBasePath());
  }
  return electedSwagger;
}

代码示例来源:origin: wso2/msf4j

/**
 * Calls the http resource method.
 *
 * @param destination           matching Destinations for the route
 * @param request               original request
 * @param httpMethodInfo        http method information
 * @param microservicesRegistry micro-services registry
 * @throws Exception if error occurs while invoking the resource method
 */
public void invoke(PatternPathRouter.RoutableDestination<HttpResourceModel> destination, Request request,
          HttpMethodInfo httpMethodInfo, MicroservicesRegistryImpl microservicesRegistry)
    throws Exception {
  request.setProperty(DECLARING_CLASS_LIST_CONSTANT, new ArrayList<Class<?>>());
  request.setProperty(RESOURCE_METHOD_LIST_CONSTANT, new ArrayList<Method>());
  ImmutablePair<Boolean, Object> returnVal =
      invokeResource(destination, httpMethodInfo, request, microservicesRegistry, false);
  // Execute method level interceptors of sub-resources and resources (first in - last out order)
  if (returnVal.getFirst()
      && InterceptorExecutor.executeMethodResponseInterceptorsForMethods(request, httpMethodInfo.responder,
      (ArrayList<Method>) request.getProperty(RESOURCE_METHOD_LIST_CONSTANT))
      // Execute class level interceptors of sub-resources and resources (first in - last out order)
      && InterceptorExecutor.executeClassResponseInterceptorsForClasses(request, httpMethodInfo.responder,
      (ArrayList<Class<?>>) request.getProperty(DECLARING_CLASS_LIST_CONSTANT))
      // Execute global interceptors
      && InterceptorExecutor.executeGlobalResponseInterceptors(microservicesRegistry, request,
      httpMethodInfo.responder)) {
    responder.setEntity(returnVal.getSecond());
  }
  responder.send();
}

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.msf4j.interceptor.common

String username = idPClient.authenticate(accessToken);
if (username != null) {
  request.setProperty(InterceptorConstants.PROPERTY_USERNAME, username);
  return true;
    return false;
  request.setProperty(InterceptorConstants.PROPERTY_USERNAME, userName);
  return true;

代码示例来源:origin: org.wso2.msf4j/msf4j-core

/**
 * Calls the http resource method.
 *
 * @param destination           matching Destinations for the route
 * @param request               original request
 * @param httpMethodInfo        http method information
 * @param microservicesRegistry micro-services registry
 * @throws Exception if error occurs while invoking the resource method
 */
public void invoke(PatternPathRouter.RoutableDestination<HttpResourceModel> destination, Request request,
          HttpMethodInfo httpMethodInfo, MicroservicesRegistryImpl microservicesRegistry)
    throws Exception {
  request.setProperty(DECLARING_CLASS_LIST_CONSTANT, new ArrayList<Class<?>>());
  request.setProperty(RESOURCE_METHOD_LIST_CONSTANT, new ArrayList<Method>());
  ImmutablePair<Boolean, Object> returnVal =
      invokeResource(destination, httpMethodInfo, request, microservicesRegistry, false);
  // Execute method level interceptors of sub-resources and resources (first in - last out order)
  if (returnVal.getFirst()
      && InterceptorExecutor.executeMethodResponseInterceptorsForMethods(request, httpMethodInfo.responder,
      (ArrayList<Method>) request.getProperty(RESOURCE_METHOD_LIST_CONSTANT))
      // Execute class level interceptors of sub-resources and resources (first in - last out order)
      && InterceptorExecutor.executeClassResponseInterceptorsForClasses(request, httpMethodInfo.responder,
      (ArrayList<Class<?>>) request.getProperty(DECLARING_CLASS_LIST_CONSTANT))
      // Execute global interceptors
      && InterceptorExecutor.executeGlobalResponseInterceptors(microservicesRegistry, request,
      httpMethodInfo.responder)) {
    responder.setEntity(returnVal.getSecond());
  }
  responder.send();
}

相关文章