I'm struggling with how to get access to the properties file from a quartz
job bean. I'm creating a pdf report that will then be emailed. I want to
get access to the properties file to tell me where to write the file along
with other information. Here is my quartz job code. Thanks in advance.
package com.paybridgeusa.jobs;
public class SendEmail extends QuartzJobBean {
public void executeInternal(JobExecutionContext context) throws
JobExecutionException {
try {
// get all tpas
TPAUsersDAO usersDAO = (TPAUsersDAO)
getApplicationContext(context).getBean("TPAUsersDAO");
List<Tpausers> users = usersDAO.getAll();
for (Tpausers user : users) {
String emailAddressTo = user.getEmail();
}
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
}
}
private static final String APPLICATION_CONTEXT_KEY =
"applicationContext";
public ApplicationContext getApplicationContext(JobExecutionContext
context) throws Exception {
ApplicationContext applicationContext = null;
applicationContext = (ApplicationContext)
context.getScheduler().getContext().get(APPLICATION_CONTEXT_KEY);
if (applicationContext == null) {
throw new JobExecutionException("No application context
available in
scheduler context for key \"" + APPLICATION_CONTEXT_KEY + "\"");
}
return applicationContext;
}
}
application context xml
<!-- QUARTZ BEANS -->
<!-- SEND TERMINATION EMAILS JOB -->
<bean name="sendTermsEmail"
class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass"
value="com.paybridgeusa.jobs.SendTermsEmail"/>
<property name="name" value="sendTermsEmail"/>
</bean>
<bean id="cronTriggerSendTermsEmail"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="sendTermsEmail"/>
<!-- run every 1 minutes -->
<property name="cronExpression" value="0 0/1 * * * ?"/>
</bean>
<!-- END SEND TERMINATION EMAILS JOB -->
<bean
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTriggerSendTermsEmail" />
</list>
</property>
<property name="applicationContextSchedulerContextKey">
<value>applicationContext</value>
</property>
</bean>
<!-- END QUARTZ BEANS -->
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/quartz-job-bean-access-to-properties-file-tp2320367p2320367.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]