Package com.xebia.lottery.domain.commandhandlers

Source Code of com.xebia.lottery.domain.commandhandlers.CreateCustomerCommandHandler

package com.xebia.lottery.domain.commandhandlers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.xebia.cqrs.bus.AbstractHandler;
import com.xebia.cqrs.domain.Repository;
import com.xebia.lottery.commands.CreateCustomerCommand;
import com.xebia.lottery.domain.aggregates.Customer;
import com.xebia.lottery.domain.aggregates.CustomerFactory;

@Component
public class CreateCustomerCommandHandler extends AbstractHandler<CreateCustomerCommand> {

    @Autowired
    private Repository repository;
   
    @Autowired
    private CustomerFactory customerFactory;
   
    public CreateCustomerCommandHandler() {
        super(CreateCustomerCommand.class);
    }

    public void handleMessage(CreateCustomerCommand message) {
        Customer customer = customerFactory.create(message.getCustomerId(), message.getInfo(), message.getInitialAccountBalance());
        repository.add(customer);
    }

}
TOP

Related Classes of com.xebia.lottery.domain.commandhandlers.CreateCustomerCommandHandler

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.