File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <project name =" Reflections" default =" dist" basedir =" ." >
2+ <description >
3+ Reflections build file
4+ </description >
5+ <!-- set global properties for this build -->
6+ <property name =" src" location =" src" />
7+ <property name =" build" location =" bin" />
8+ <property name =" dist" location =" dist" />
9+
10+ <target name =" init" >
11+ <!-- Create the time stamp -->
12+ <tstamp />
13+ <!-- Create the build directory structure used by compile -->
14+ <mkdir dir =" ${ build } " />
15+ </target >
16+
17+ <target name =" compile" depends =" init"
18+ description =" compile the source " >
19+ <!-- Compile the java code from ${src} into ${build} -->
20+ <javac srcdir =" ${ src } " destdir =" ${ build } " />
21+ </target >
22+
23+ <target name =" clean"
24+ description =" clean up" >
25+ <!-- Delete the ${build} and ${dist} directory trees -->
26+ <delete dir =" ${ build } " />
27+ <delete dir =" ${ dist } " />
28+ </target >
29+ </project >
Original file line number Diff line number Diff line change @@ -11,18 +11,21 @@ public class MethodInterceptor {
1111
1212 public static void main (String [] args ) throws Exception {
1313 DiFactory diFactory = new DiFactory (MethodInterceptor .class .getResource ("/di.txt" ));
14- DataService dataService = getInterceptor (diFactory .getBean ("dataService" ));
14+ DataService dataService = ( DataService ) getInterceptor (diFactory .getBean ("dataService" ));
1515 dataService .loadData ();
1616 }
1717
1818
1919 @ SuppressWarnings ("unchecked" )
2020 private static <T > T getInterceptor (final T type ) {
21+
2122 InvocationHandler handler = new InvocationHandler () {
2223 @ Override
2324 public Object invoke (Object proxy , Method method , Object [] args ) throws Throwable {
2425 System .out .println (">> Before executing target method : " + method .getName ());
26+
2527 Object result = method .invoke (type , args );
28+
2629 System .out .println ("\n \t Data from target : " + result );
2730 System .out .println ("\n >> After executing target method : " + method .getName ());
2831 return result ;
Original file line number Diff line number Diff line change @@ -18,5 +18,9 @@ public String loadData() throws Exception {
1818 }
1919 return builder .toString ();
2020 }
21+
22+ public String loadDataFromSomeOtherMeans () {
23+ return "asasas" ;
24+ }
2125
2226}
Original file line number Diff line number Diff line change 1- # dataService,com.sach.reflections.service.impl.InMemoryDataService
2- dataService,com.sach.reflections.service.impl.FileDataService
1+ dataService,com.sach.reflections.service.impl.InMemoryDataService
2+ # dataService,com.sach.reflections.service.impl.FileDataService
You can’t perform that action at this time.
0 commit comments