简体   繁体   中英

Java class contain the business logic of batch job

I have a big xml file that I want to get transferred from c: drive to d: drive at particular time period.

I want to design a Java class to perform a batch job . This would means that the java class will act like a batch job and it will pick the xml file from c: drive and will send it to d: drive at particular time.I want the other time setting and file location specifications to be done in xml file and the rest java class would contain the buisness logic.

Please advise how to achieve this , and also please let me know any of frameworks like Spring or Spring Integration, Spring Batch that might provide any help..!

I am more interested in spring batch!!

I would recommend using your OS scheduler to achieve this. Put your business logic in the Java code any way you want but on windows schedule it with the windows scheduler, on unix use cron.

If you absolutely need Java to be the scheduler as well, look into Quartz .

---- Using Windows Scheduler ----

First, create a batch file to kick off your java code:

myjavarunner.bat:

java -classpath <myclasspath> com.silly.project.ClassWithMainMethod <arguments>

This is not strictly necessary, but when working with java, it is often much easier. Then, create a scheduled task. Click the start button -> Control Panel -> Administrative Tools -> Task Scheduler. Click the Action menu -> Create Task. Fill out all the forms and let er rip.

一个简单的开始就是使用Timer安排定期作业,并使用TimerTask来实现业务逻辑。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM