<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Need deployment structure for Quartz job with Spring framework on jboss
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/RizwanP">Rizwan P</a> in <i>Spring Integration</i> - <a href="http://community.jboss.org/message/540953#540953">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hello,</p><p>Currently my requirement is to deploy the Quartz jobs with Spring framework, executed via cron trigger.</p><p>I have managed to derive the job, trigger and springContext.xml file for this task. Also, I am getting the desired result as a stand-alone application when executed via a testclient's main method.</p><p>Now, i need the help in deploying this on the Jboss server environment and I am stuck as don't want to deploy it as WAR.</p><p>Any suggestiion or help is very much appreciated, please help</p><p>Below are the code components i have attached for the reference.</p><p><br/>import org.quartz.JobExecutionContext;<br/>import org.quartz.JobExecutionException;</p><p><br/>public interface JobInterface {</p><p> public void init(JobExecutionContext jobExecutionContext)<br/>   throws JobExecutionException;</p><p> public void execute() throws JobExecutionException;</p><p> public void destroy();</p><p>}</p><p><br/>Implementation class :</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import org.quartz.JobExecutionContext;<br/>import org.quartz.JobExecutionException;</p><p>public class RemoveJob implements JobInterface{</p><p> @Override<br/> public void destroy() {<br/>  // TODO Auto-generated method stub clearance<br/>  System.out.println("Inside destroy");<br/> }</p><p> @Override<br/> public void execute() throws JobExecutionException {<br/>  // TODO Auto-generated method stub  actuall job<br/>  System.out.println("Inside execute");<br/> }</p><p> @Override<br/> public void init(JobExecutionContext jobExecutionContext)<br/>   throws JobExecutionException {<br/>  // TODO Auto-generated method stub initialization stuff<br/>  System.out.println("Inside init");<br/> }</p><p>}</p><p><br/>Delegator class <br/>   </p><p>public class DelegatingJobBean extends QuartzJobBean{<br/> private static final String App_Key = "applicationContext";<br/> private static final String Job_Key = "job.bean.name";<br/>// /protected org.apache.commons.logging.Log log = LogFactory.getLog(getClass());</p><p> @Override<br/> protected void executeInternal(JobExecutionContext ctx)<br/>   throws JobExecutionException {<br/>  // TODO Auto-generated method stub<br/>  System.out.println("Inside executeInternal.............");<br/>  SchedulerContext schdContext = null;<br/>  try<br/>  {<br/>   schdContext = ctx.getScheduler().getContext();<br/>   <br/>  }catch(SchedulerException e)<br/>  {<br/>   throw new JobExecutionException("Failure accesssing scheduler context ");<br/>  }<br/>  <br/>  ApplicationContext appContext = (ApplicationContext)schdContext.get(App_Key);<br/>  <br/>  String jobBeanName = (String)ctx.getJobDetail()<br/>        .getJobDataMap().get(Job_Key);<br/>  <br/>  //log.info("Starting Job : " +jobBeanName);<br/>  <br/>  JobInterface jobBean  =(JobInterface)appContext.getBean(jobBeanName);<br/>  <br/>  <br/>  try<br/>  {<br/>   jobBean.init(ctx);<br/>   jobBean.execute();<br/>  }finally<br/>  {<br/>   jobBean.destroy();<br/>  }<br/>  <br/> }</p><p>}</p><p>Config File</p><p><br/><?xml version="1.0" encoding="UTF-8"?><br/><beans xmlns="<a class="jive-link-external-small" href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a>"<br/> xmlns:xsi="<a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</a>"<br/> xsi:schemaLocation="<a class="jive-link-external-small" href="http://www.springframework.org/schema/beans">http://www.springframework.org/schema/beans</a> <a class="jive-link-external-small" href="http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">http://www.springframework.org/schema/beans/spring-beans-2.0.xsd</a>"<br/>    ><br/> <!--  This is your job bean<br/>  --><br/> <bean id="removeExpireBean"<br/>  autowire="byName" lazy-init="default" dependency-check="default"><br/>  <!--  Ref to other beans. Add more if needed <br/>  --><br/>  <!--<property name="serviceLocator"><br/>   <ref bean="serviceLocator" /><br/>  </property><br/> --></bean><br/> <!--<br/>  Define the bean that delegates the work to the real job bean<br/> --><br/> <bean name="removalJob"<br/>  lazy-init="default" autowire="default" dependency-check="default"><br/>  <property name="jobClass" value="DelegatingJobBean" /><br/>  <property name="jobDataAsMap"><br/>   <map><br/>    <!--  This specifies the actual job bean name <br/>  --><br/>    <entry key="job.bean.name" value="removeExpireBean" /><br/>    <!--  Any other job data map entries required by your job <br/>  --><br/>    <entry key="sdtl.file.prefix" value="sdtl_" /><br/>   </map><br/>  </property><br/> </bean><br/> <!--  Associate the delegating job bean with a trigger <br/>  --><br/> <bean id="removalTrigger"<br/>  lazy-init="default" autowire="default" dependency-check="default"><br/>  <property name="jobDetail" ref="removalJob" /><br/>  <!--  run every morning at 6:30 AM <br/>  --><br/>  <property name="cronExpression" value="0/10 * * * * ?" /><br/> </bean><br/> <!--  Define the scheduler with the list of triggers <br/>  --><br/> <bean<br/>  lazy-init="default" autowire="default" dependency-check="default"><br/>  <property name="triggers"><br/>   <list><br/>    <ref bean="removalTrigger" /><br/>   </list><br/>  </property><br/>  <!--  Scheduler context key we use this in delegating job bean <br/>  --><br/>  <property name="applicationContextSchedulerContextKey"><br/>   <value>applicationContext</value><br/>  </property><br/> </bean><br/></beans></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Please suggest the deployment structure to be follw to work with this..</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/540953#540953">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in Spring Integration at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2082">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>