package com.tenwa.lease.app.quartzmession; import jbo.sys.QRTZ_TRIGGERS; import org.quartz.JobExecutionContext; import org.quartz.JobKey; import com.amarsoft.are.jbo.BizObject; import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOException; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; public class JobInitUserName { private static JobInitUserName instance; private JobInitUserName (){} public static synchronized JobInitUserName getInstance() { if (instance == null) { instance = new JobInitUserName(); } return instance; } public static String getUserId(JobExecutionContext arg0,JBOTransaction tx ) throws JBOException{ JobKey jobKey = arg0.getJobDetail().getKey(); String jobName=jobKey.getName(); BizObjectManager Bm=JBOFactory.getBizObjectManager(QRTZ_TRIGGERS.CLASS_NAME, tx); BizObject bo = Bm.createQuery(" NEXT_FIRE_TIME is null and JOB_NAME='" + jobName + "'").getSingleResult(false); return bo!=null?bo.getAttribute(QRTZ_TRIGGERS.USERID).toString():"8009U00000002";//反之为system用户 } }