sk.stefan.projekt.camel.CamelLayerApp.java Source code

Java tutorial

Introduction

Here is the source code for sk.stefan.projekt.camel.CamelLayerApp.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sk.stefan.projekt.camel;

import org.apache.camel.CamelContext;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import sk.stefan.projekt.activemq.ActivemqApp;
import sk.stefan.projekt.enums.TestCase;

/**
 *
 * @author stefan
 */
public class CamelLayerApp {

    private static final Logger log = Logger.getLogger(CamelLayerApp.class);

    @Autowired
    private CamelContext camContext;

    @Autowired(required = true)
    private ActivemqApp activemqApp;

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

        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
                "classpath:/context/Level2Context.xml");

        CamelLayerApp cl = (CamelLayerApp) ctx.getBean("camelLayer");

        cl.doCamel("World");

    }

    public void doCamel(String msg) {

        try {
            camContext.start();

            activemqApp.doSecondTest(msg);
            Thread.sleep(10000);

            camContext.stop();
        } catch (Exception ex) {
            log.error(ex);
        }
    }

    //    *********************
    //    GETTERS AND SETTERS:
    //    *********************

    public ActivemqApp getActivemqApp() {
        return activemqApp;
    }

    public void setActivemqApp(ActivemqApp activemqApp) {
        this.activemqApp = activemqApp;
    }

    public CamelContext getCamContext() {
        return camContext;
    }

    public void setCamContext(CamelContext context) {
        this.camContext = context;
    }
}