com.mtech.easyexchange.manager.factory.OrderManagerFactory.java Source code

Java tutorial

Introduction

Here is the source code for com.mtech.easyexchange.manager.factory.OrderManagerFactory.java

Source

/*
 * This file is part of EasyExchange.
 *
 * (c) 2014 - Machiel Molenaar <machiel@machiel.me>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

package com.mtech.easyexchange.manager.factory;

import com.mtech.easyexchange.SessionFactoryProvider;
import com.mtech.easyexchange.dao.impl.OrderDao;
import com.mtech.easyexchange.manager.balance.IBalanceManager;
import com.mtech.easyexchange.manager.order.IOrderManager;
import com.mtech.easyexchange.manager.order.OrderManager;
import com.mtech.easyexchange.manager.order.notifier.IOrderChangedNotifier;
import com.mtech.easyexchange.manager.order.notifier.OrderChangedNotifier;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

public class OrderManagerFactory {

    public static IOrderManager createOrderManager() {

        IBalanceManager bm = BalanceManagerFactory.createBalanceManager();
        Session session = SessionFactoryProvider.getCurrentSession();

        ConnectionFactory cf = new CachingConnectionFactory("127.0.0.1");

        RabbitTemplate rabbitTemplate = new RabbitTemplate(cf);

        IOrderChangedNotifier changeNotifier = new OrderChangedNotifier(rabbitTemplate);

        return new OrderManager(new OrderDao(session), bm, changeNotifier);
    }

}