Hi,
I had executed a spring Quartz project as a stand alone
java application. Now, I am trying to deploy it on a Server, where it will deployed in to ear file and will be called automatically.
Please find the files created:
sqTest.java
package com.hitesh.java;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class sqTest {
public static void main(
String[] args) {
System.out.println("Before Scheduler starts....");
ApplicationContext ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml");
System.out.println("After Scheduler starts....");
}}
MyJob.java
package com.hitesh.java;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
public class MyJob extends QuartzJobBean {
protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException {
System.out.println("EXECUTING QUARTZ JOB");
}}
ApplicationContext.xml
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <bean name="myJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.hitesh.java.MyJob"/>
</bean>
<bean id="simpleTrigger"
class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="myJob"/>
<property name="startDelay" value="2000"/>
<property name="repeatInterval" value="1000"/>
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="simpleTrigger"/>
</list>
</property>
</bean>
</beans>
This xml is placed at project level. Jar files needed are Spring.jar, Quartz-1.5.0.jar
Please let me know how to migrate this thing EAR which can be executed on a Server and process is executed automatically.
Regards,
Hitesh