package com.yichao.woo.spring.di.method.replacement; import org.springframework.context.support.GenericXmlApplicationContext; import org.springframework.util.StopWatch; public class ReplacementDemo { public static void main(String[] args) { GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.load("classpath:replacement.xml"); ctx.refresh(); ReplacementTarget replacementTarget = (ReplacementTarget) ctx.getBean("replacementTarget"); ReplacementTarget standardTarget = (ReplacementTarget) ctx.getBean("replacementTarget2"); displayInfo(replacementTarget); displayInfo(standardTarget); } private static void displayInfo(ReplacementTarget target) { System.out.println(target.formatMessage("Hello World!")); StopWatch stopWatch = new StopWatch(); stopWatch.start("perfTest"); for (int x = 0; x < 1000000; x++) { String out = target.formatMessage("foo"); } stopWatch.stop(); System.out.println("1000000 invocations took: " + stopWatch.getTotalTimeMillis() + " ms"); } }