summaryrefslogtreecommitdiff
path: root/spring-framework/24-aop-aspectj-annotations2/src/main/java/com/example/spring/aop/BankApp.java
blob: 6ad43cf4442adef7fcc61dcdff912e9008f3be4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package com.example.spring.aop;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class BankApp {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {
				"classpath:META-INF/spring/applicationContext.xml",});
		
		Account acc = ctx.getBean("account", Account.class);
		
		acc.printDetails(); // 250
		acc.withdraw(10);
		acc.printDetails(); // 240
		acc.deposit(20);
		acc.printDetails(); // 260
		
//		System.out.println("An exception should occur here if attempted to withdraw a large amount.");
//		acc.withdraw(1200); // Uncommented, this should throw an exception
//		acc.printDetails(); // 260
		
		ctx.close();
	}

}