*/
DatabaseUtil.startEmbeddedDatabase();
DatabaseUtil.initializeSessionFactory();
// Build an easy batch engine to read greetings from csv file
EasyBatchEngine easyBatchCsvEngine = new EasyBatchEngineBuilder()
.registerRecordReader(new FlatFileRecordReader(new File(args[0])))
.registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id","name"}))
.registerRecordProcessor(new GreetingDataLoader())
.build();
// Build an easy batch engine to read greetings from xml file
EasyBatchEngine easyBatchXmlEngine = new EasyBatchEngineBuilder()
.registerRecordReader(new XmlRecordReader("greeting", new File(args[1])))
.registerRecordMapper(new XmlRecordMapper<Greeting>(Greeting.class))
.registerRecordProcessor(new GreetingDataLoader())
.build();
//create a 2 threads pool to call Easy Batch engines in parallel
ExecutorService executorService = Executors.newFixedThreadPool(2);
Future<EasyBatchReport> easyBatchReport1 = executorService.submit(easyBatchCsvEngine);
Future<EasyBatchReport> easyBatchReport2 = executorService.submit(easyBatchXmlEngine);
easyBatchReport1.get();
easyBatchReport2.get();
executorService.shutdown();
// Build an easy batch engine to generate JSON products data from the database
EasyBatchEngine easyBatchJsonEngine = new EasyBatchEngineBuilder()
.registerRecordReader(new JdbcRecordReader(DatabaseUtil.getDatabaseConnection(), "select * from greeting"))
.registerRecordMapper(new JdbcRecordMapper<Greeting>(Greeting.class))
.registerRecordProcessor(new GreetingJsonGenerator())
.build();
easyBatchJsonEngine.call();
//close database session factory
DatabaseUtil.closeSessionFactory();
}