org.springframework.core.NamedThreadLocal.get()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(62)

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

NamedThreadLocal.get介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

static InjectionPoint setCurrentInjectionPoint(@Nullable InjectionPoint injectionPoint) {
  InjectionPoint old = currentInjectionPoint.get();
  if (injectionPoint != null) {
    currentInjectionPoint.set(injectionPoint);
  }
  else {
    currentInjectionPoint.remove();
  }
  return old;
}

代码示例来源:origin: a466350665/smart

@Override
  public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
      throws Exception {
    long endTime = System.currentTimeMillis();// 2、结束时间
    long beginTime = startTimeThreadLocal.get();// 得到线程绑定的局部变量(开始时间)
    long consumeTime = endTime - beginTime;// 3、消耗的时间
    if (consumeTime > 500) {// 此处认为处理时间超过500毫秒的请求为慢请求
      logger.info(String.format("%s consume %d millis", request.getRequestURI(), consumeTime));
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Overridden in order to implicitly register the currently created bean as
 * dependent on further beans getting programmatically retrieved during a
 * {@link Supplier} callback.
 * @since 5.0
 * @see #obtainFromSupplier
 */
@Override
protected Object getObjectForBeanInstance(
    Object beanInstance, String name, String beanName, @Nullable RootBeanDefinition mbd) {
  String currentlyCreatedBean = this.currentlyCreatedBean.get();
  if (currentlyCreatedBean != null) {
    registerDependentBean(beanName, currentlyCreatedBean);
  }
  return super.getObjectForBeanInstance(beanInstance, name, beanName, mbd);
}

代码示例来源:origin: org.springframework/spring-beans

static InjectionPoint setCurrentInjectionPoint(@Nullable InjectionPoint injectionPoint) {
  InjectionPoint old = currentInjectionPoint.get();
  if (injectionPoint != null) {
    currentInjectionPoint.set(injectionPoint);
  }
  else {
    currentInjectionPoint.remove();
  }
  return old;
}

代码示例来源:origin: org.springframework/spring-beans

/**
 * Overridden in order to implicitly register the currently created bean as
 * dependent on further beans getting programmatically retrieved during a
 * {@link Supplier} callback.
 * @since 5.0
 * @see #obtainFromSupplier
 */
@Override
protected Object getObjectForBeanInstance(
    Object beanInstance, String name, String beanName, @Nullable RootBeanDefinition mbd) {
  String currentlyCreatedBean = this.currentlyCreatedBean.get();
  if (currentlyCreatedBean != null) {
    registerDependentBean(beanName, currentlyCreatedBean);
  }
  return super.getObjectForBeanInstance(beanInstance, name, beanName, mbd);
}

代码示例来源:origin: spring-projects/spring-framework

InjectionPoint injectionPoint = currentInjectionPoint.get();
if (injectionPoint == null) {
  throw new IllegalStateException("No current InjectionPoint available for " + param);

代码示例来源:origin: spring-projects/spring-framework

/**
 * Obtain a bean instance from the given supplier.
 * @param instanceSupplier the configured supplier
 * @param beanName the corresponding bean name
 * @return a BeanWrapper for the new instance
 * @since 5.0
 * @see #getObjectForBeanInstance
 */
protected BeanWrapper obtainFromSupplier(Supplier<?> instanceSupplier, String beanName) {
  Object instance;
  String outerBean = this.currentlyCreatedBean.get();
  this.currentlyCreatedBean.set(beanName);
  try {
    instance = instanceSupplier.get();
  }
  finally {
    if (outerBean != null) {
      this.currentlyCreatedBean.set(outerBean);
    }
    else {
      this.currentlyCreatedBean.remove();
    }
  }
  if (instance == null) {
    instance = new NullBean();
  }
  BeanWrapper bw = new BeanWrapperImpl(instance);
  initBeanWrapper(bw);
  return bw;
}

代码示例来源:origin: org.springframework/spring-beans

InjectionPoint injectionPoint = currentInjectionPoint.get();
if (injectionPoint == null) {
  throw new IllegalStateException("No current InjectionPoint available for " + param);

代码示例来源:origin: org.springframework/spring-beans

/**
 * Obtain a bean instance from the given supplier.
 * @param instanceSupplier the configured supplier
 * @param beanName the corresponding bean name
 * @return a BeanWrapper for the new instance
 * @since 5.0
 * @see #getObjectForBeanInstance
 */
protected BeanWrapper obtainFromSupplier(Supplier<?> instanceSupplier, String beanName) {
  Object instance;
  String outerBean = this.currentlyCreatedBean.get();
  this.currentlyCreatedBean.set(beanName);
  try {
    instance = instanceSupplier.get();
  }
  finally {
    if (outerBean != null) {
      this.currentlyCreatedBean.set(outerBean);
    }
    else {
      this.currentlyCreatedBean.remove();
    }
  }
  if (instance == null) {
    instance = new NullBean();
  }
  BeanWrapper bw = new BeanWrapperImpl(instance);
  initBeanWrapper(bw);
  return bw;
}

代码示例来源:origin: Cosium/spring-data-jpa-entity-graph

static boolean isCountQuery() {
 return IS_COUNT_QUERY.get() == null ? false : IS_COUNT_QUERY.get();
}

代码示例来源:origin: com.wuyushuo/vplus-data

public static String getDataSourceKey() {
  Lookup dsLookup = (Lookup)lookup.get();
  String dataSourceKey = null;
  if (dsLookup != null) {
    dataSourceKey = dsLookup.getDataSourceKey();
    return dataSourceKey;
  } else {
    throw new IllegalArgumentException("数据源指定错误 or 获取连接错误 or SQL错误");
  }
}

代码示例来源:origin: com.wuyushuo/vplus-data

public static String getTableName() {
  return ((Lookup)lookup.get()).getTableName();
}

代码示例来源:origin: apache/servicemix-bundles

static InjectionPoint setCurrentInjectionPoint(InjectionPoint injectionPoint) {
  InjectionPoint old = currentInjectionPoint.get();
  if (injectionPoint != null) {
    currentInjectionPoint.set(injectionPoint);
  }
  else {
    currentInjectionPoint.remove();
  }
  return old;
}

相关文章

微信公众号

最新文章

更多