1 6 7 package org.jfox.ioc.sample; 8 9 import java.lang.reflect.Method ; 10 11 import org.jfox.ioc.Component; 12 import org.jfox.ioc.ComponentContext; 13 import org.jfox.ioc.ext.InterceptableComponent; 14 15 18 19 public class SampleComponentA implements Component, InterceptableComponent, SampleComponent { 20 private String name = "Hello,World"; 21 22 public SampleComponentA() { 23 } 24 25 public SampleComponentA(String name) { 26 this.name = name; 27 } 28 29 public String getName() { 30 return name; 31 } 32 33 public void setName(String name) { 34 this.name = name; 35 } 36 37 public void setComponent(Component tc) { 38 39 } 40 41 public void preInvoke(Method method, Object [] params) { 42 if(!method.getName().equals("toString")){ 43 System.out.println("Intercepter: preInvoke "+ this.getClass().getName() + "." + method.getName()); 44 } 45 } 46 47 public Object postInvoke(Method method, Object result) { 48 if(!method.getName().equals("toString")){ 49 System.out.println("Intercepter: postInvoke " + this.getClass().getName() + "." + method.getName()); 50 } 51 return result; 52 } 53 54 public void setComponentContext(ComponentContext ctx) { 55 56 } 57 58 public Component afterInstantiate(Component component) { 59 System.out.println("Intercepter: Component " + this.getClass().getName() + " instantiated."); 60 return component; 61 } 62 63 64 public static void main(String [] args) { 65 66 } 67 } 68 69 | Popular Tags |