AbstractDataLoadCallable.java 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. *
  3. */
  4. package cn.com.lzt.callable;
  5. import java.util.HashMap;
  6. import java.util.concurrent.Callable;
  7. import org.jeecgframework.core.common.service.impl.CommonServiceImpl;
  8. /**
  9. * @author xzx
  10. *
  11. * 2019年9月1日
  12. *
  13. */
  14. public abstract class AbstractDataLoadCallable implements Callable<HashMap<String, HashMap<String, Object>>> {
  15. protected CommonServiceImpl commonService;
  16. public AbstractDataLoadCallable(CommonServiceImpl commonService) {
  17. super();
  18. this.commonService = commonService;
  19. }
  20. public CommonServiceImpl getCommonService() {
  21. return commonService;
  22. }
  23. public void setCommonService(CommonServiceImpl commonService) {
  24. this.commonService = commonService;
  25. }
  26. @Override
  27. public HashMap<String, HashMap<String, Object>> call() throws Exception {
  28. commonService.bindHibernateSessionToThread();
  29. HashMap<String, HashMap<String, Object>> result = loadData();
  30. commonService.closeHibernateSessionFromThread();
  31. return result;
  32. }
  33. abstract HashMap<String, HashMap<String, Object>> loadData() throws Exception;
  34. }