November 27th, 2011, 11:43 PM
Cronjob for a executing a single method of Java class
Am a new bie to Java, Currently we are running a daily cronjob of executing a class (a struts2 web application project) which sends an email to two different team @ a specific time. The class includes two methods, one for sending email to sales team, and other for sending email to business team of the list of created keywords on the site that day. The requirement is to send an email to sales team @ a different time, and to business team to other team. So, can i write cron jobs by specifying the method name, so that only that specific method will be executed @ that time.
A cron job cannot execute a single method within a Java class file because it's not designed for this. Cron jobs simply execute a command at a given time or interval with any additional parameters specified in the command line. I guess based on this, you could create a separate driver class which executes the single method, or otherwise you could create some form of parameter input which has a condition to run the single method.
I'm no Java expert, but I'm pretty sure that's the way to go.