develog

[Java] Quartz job fire manually (in JSP) 본문

Dev/Java

[Java] Quartz job fire manually (in JSP)

냐옴 2015. 10. 14. 14:30
// Quartz 1.8.6
<%!
	private void fireJobManually(ApplicationContext context, String triggerName, String refBeanNm) throws Exception {
		System.out.println(">> fireJobManually()");
	
		StdScheduler scheduler = (StdScheduler) context.getBean("scheduler");
		
		String[] triggerGroupNames = scheduler.getTriggerGroupNames();
		String triggerGroup = triggerGroupNames[0];
		
		String[] triggerNames = scheduler.getTriggerNames(triggerGroup);
		Trigger trigger = scheduler.getTrigger(triggerName, triggerGroup);
		
		System.out.println("scheduler : " + scheduler);
		System.out.println("triggerGroupNames : " + Arrays.toString(triggerGroupNames));
		System.out.println("triggerGroup : " + triggerGroup);
		System.out.println("triggerNames : " + Arrays.toString(triggerNames));
		System.out.println("trigger : " + trigger);
		
		String jobName = trigger.getJobName();
		
		System.out.println();
		System.out.println("jobName : " + jobName);
		System.out.println("triggerName : " + triggerName);
		System.out.println("triggerGroup : " + triggerGroup);
		
		JobDataMap jobDataMap = new JobDataMap();
		if (refBeanNm != null) {
			jobDataMap.put(refBeanNm, context.getBean(refBeanNm));
		}
		scheduler.triggerJob(jobName, triggerGroup, jobDataMap);
	}
%>
<%
	ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(Utils.getServletContext());
	
	fireJobManually(context, "myTrigger", "myServiceBean");
%>

'Dev > Java' 카테고리의 다른 글

[Java] log4j  (0) 2016.05.29
[Java] .class 버전 확인, javap  (0) 2016.03.27
JSP, download 구현시  (0) 2015.03.05
[Java] password validation with regex  (0) 2015.02.03
[Maven] Eclipse, Maven, Dynamic Web Project  (0) 2014.12.21
Comments