1 8 14 package jfun.yan; 15 16 17 23 final class BeanBinder<T> 24 implements ComponentBinder<T,T>{ 25 private final PropertiesInjector injector; 26 private final String name; 27 28 BeanBinder(String name, PropertiesInjector injector) { 29 this.injector = injector; 30 this.name = name; 31 } 32 public Creator<T> bind(final T r){ 33 return new Creator<T>(){ 34 public T create(Dependency dep){ 35 injector.injectProperties(r, dep); 36 return r; 37 } 38 public Class verify(Dependency dep){ 39 final Class t = r==null?null:r.getClass(); 40 injector.verifyProperties(t, dep); 41 return t; 42 } 43 public Class getType(){ 44 return r.getClass(); 45 } 46 public boolean isConcrete(){ 47 return true; 48 } 49 public boolean isSingleton(){ 50 return false; 51 } 52 }; 53 } 54 public Verifiable verify(final Class t){ 55 return new Verifiable(){ 56 public Class verify(Dependency dep){ 57 injector.verifyProperties(t, dep); 58 return t; 59 } 60 }; 61 } 62 public Class bindType(Class t){ 63 return void.class; 64 } 65 public String toString(){ 66 return name; 67 } 68 } 69 | Popular Tags |