All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lframework.web.common.threads.DefaultCallable Maven / Gradle / Ivy

package com.lframework.web.common.threads;

import com.lframework.web.common.security.AbstractUserDetails;
import com.lframework.web.common.security.SecurityUtil;
import java.util.concurrent.Callable;

/**
 * 默认Callable 可传递当前登录人信息
 *
 * @author zmj
 * @since 2022/8/19
 */
public class DefaultCallable implements Callable {

  private final AbstractUserDetails user;

  private final Callable callable;

  public DefaultCallable(AbstractUserDetails user, Callable callable) {
    this.user = user;
    this.callable = callable;
  }

  @Override
  public T call() throws Exception {
    try {
      SecurityUtil.setCurrentUser(this.user);
      return this.callable.call();
    } finally {
      SecurityUtil.removeCurrentUser();
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy