Examples of EasyBatchEngineBuilder


Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

public class Launcher {

    public static void main(String[] args) throws Exception {

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new CliRecordReader())
                .registerRecordFilter(new StartsWithStringRecordFilter("#"))
                .registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id", "name"}))
                .registerRecordProcessor(new GreetingProcessor())
                .build();
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

        DelimitedRecordMapper<Product> productMapper = new DelimitedRecordMapper<Product>(Product.class);
        productMapper.setDelimiter("|");
        productMapper.setQualifier("\"");

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from products-jsr303.csv
                .registerRecordMapper(productMapper)
                .registerRecordValidator(new BeanValidationRecordValidator<Product>())
                .registerRecordProcessor(new ProductProcessor())
                .build();
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

        System.out.println(COMMENT_SEPARATOR);
        System.out.println("Running a single Easy Batch instance");
        System.out.println(COMMENT_SEPARATOR);
        long singleInstanceStartTime = System.nanoTime();
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        EasyBatchReport easyBatchReport = easyBatchEngine.call();
        System.out.println(easyBatchReport);

        long singleInstanceEndTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - singleInstanceStartTime);

        System.out.println(COMMENT_SEPARATOR);
        System.out.println("Running two Easy Batch instances in parallel");
        System.out.println(COMMENT_SEPARATOR);
        long parallelInstancesStartTime = System.nanoTime();

        // To avoid any thread-safety issues,
        // we will create 2 engines with separate instances of record readers and processors

        // Build an easy batch engine1
        EasyBatchEngine easyBatchEngine1 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
                .registerRecordFilter(new RecordNumberGreaterThanRecordFilter(5)) // filter records 6-10
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        // Build an easy batch engine2
        EasyBatchEngine easyBatchEngine2 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages.txt
                .registerRecordFilter(new RecordNumberLowerThanRecordFilter(6)) // filter records 1-5
                .registerRecordProcessor(new MessageEncrypter())
                .build();
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

public class Launcher {

    public static void main(String[] args) throws Exception {

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0])))
                .registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id", "name"}))
                .registerRecordValidator(new BeanValidationRecordValidator<Greeting>())
                .registerRecordProcessor(new GreetingProcessor())
                .build();
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

        // To avoid any thread-safety issues,
        // we will create 2 engines with separate instances of record readers and processors

        // Build an easy batch engine1
        EasyBatchEngine easyBatchEngine1 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from secret-messages-part1.txt
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        // Build an easy batch engine2
        EasyBatchEngine easyBatchEngine2 = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[1]))) //read data from secret-messages-part2.txt
                .registerRecordProcessor(new MessageEncrypter())
                .build();

        //create a 2 threads pool to call Easy Batch engines in parallel
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

         */
        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();

View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

        productMapper.setDelimiter("|");
        productMapper.setQualifier("\"");
        productMapper.registerTypeConverter(Origin.class, new OriginTypeConverter());

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new FlatFileRecordReader(new File(args[0]))) //read data from products.csv
                .registerRecordMapper(productMapper)
                .registerRecordProcessor(new ProductProcessor())
                .build();
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

    private RecordProcessor recordProcessor;

    @Override
    public Object getObject() throws Exception {
        EasyBatchEngineBuilder easyBatchEngineBuilder = new EasyBatchEngineBuilder();
        if (recordReader != null) {
            easyBatchEngineBuilder.registerRecordReader(recordReader);
        }
        if (recordFilter != null) {
            easyBatchEngineBuilder.registerRecordFilter(recordFilter);
        }
        if (recordMapper != null) {
            easyBatchEngineBuilder.registerRecordMapper(recordMapper);
        }
        if (recordValidator != null) {
            easyBatchEngineBuilder.registerRecordValidator(recordValidator);
        }
        if (recordProcessor != null) {
            easyBatchEngineBuilder.registerRecordProcessor(recordProcessor);
        }
        return easyBatchEngineBuilder.build();
    }
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

public class Launcher {

    public static void main(String[] args) throws Exception {

        // Build an easy batch engine
        EasyBatchEngine easyBatchEngine = new EasyBatchEngineBuilder()
                .registerRecordReader(new XmlRecordReader("greeting", new File(args[0])))
                .registerRecordMapper(new XmlRecordMapper<Greeting>(Greeting.class, new File(args[1])))
                .registerRecordProcessor(new GreetingProcessor())
                .build();
View Full Code Here

Examples of org.easybatch.core.impl.EasyBatchEngineBuilder

        JMSUtil.stopBroker();

    }

    public static EasyBatchEngine buildEasyBatchEngine(int id) {
        return new EasyBatchEngineBuilder()
                .registerRecordReader(new GreetingJmsReader(id))
                .registerRecordMapper(new DelimitedRecordMapper<Greeting>(Greeting.class, new String[]{"id","name"}))
                .registerRecordProcessor(new GreetingSlowProcessor())
                .build();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.