package test;
import dependency_injection.I_Vehicle;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import dependency_injection.Car;
import dependency_injection.Bike;


public class LoginAction {

	private String email, password, message;
	private String test;
	private int abc;
	
	public String getTest() {
		return test;
	}

	public void setTest(String test) {
		this.test = test;
	}

	public int getAbc() {
		return abc;
	}


	public void setAbc(int abc) {
		this.abc = abc;
	}

	public Admin getAd() {
		return ad;
	}

	public void setAd(Admin ad) {
		this.ad = ad;
	}
	Admin ad = new Admin();
	public String execute() throws Exception{
	
		message = ad.getUser(email, password);
		System.out.println("Message is: "+message);
		
		//dependency injection test
		//I_Vehicle vlc = new Car();
		//vlc.run();
		
		 ApplicationContext appContext = new ClassPathXmlApplicationContext("classpath: applicationContext.xml");
      
	     I_Vehicle vcle = (I_Vehicle) appContext.getBean("car");
	     vcle.run();
		
		if(message.startsWith("Sorry")) return "FAILURE"; 
		return "SUCCESS";
	}
	
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
}
