package com.example.fp; import java.util.List; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class FinancialPlannerApp { /** * @param args */ public static void main(String[] args) { AbstractApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {"classpath:META-INF/spring/applicationContext.xml"}); // Register a shutdown hook with the JVM runtime, closing this context on JVM shutdown unless it has already been closed at that time. // Delegates to doClose() for the actual closing procedure. // This will trigger the destroy-method of the DataSource in our application (for example, in case of unexpected JVM shutdown). ctx.registerShutdownHook(); UserManager userManager = ctx.getBean("userManager", UserManager.class); // Create an account System.out.println("Creating users..."); userManager.create(new User("Kamal", "Kamal Wickramanayake", "abc123", true)); userManager.create(new User("Rajith", "Rajith Virajana", "abc123", true)); userManager.create(new User("Uththama", "Uththama Yapa", "abc123", true)); List users = userManager.findAll(); for (User user : users) { System.out.println(user); } User newUser = new User("Kamal2", "Kamal Wickramanayake", "abc123", true); System.out.println(newUser); userManager.create(newUser); System.out.println(newUser); ctx.close(); } }