1 package jfun.yan; 2 3 import jfun.yan.util.Utils; 4 5 12 public abstract class SimpleComponent<T> extends Component<T> { 13 private final Class type; 14 15 public SimpleComponent(Class type) { 16 this.type = type; 17 } 18 19 public Class getType() { 20 return type; 21 } 22 public boolean isConcrete(){ 23 return true; 24 } 25 public T create(Dependency dep){ 26 try{ 27 return create(); 28 } 29 catch(Throwable e){ 30 final YanException ye = Utils.wrapInstantiationException(e); 31 ye.push(this); 32 throw ye; 33 } 34 } 35 36 public Class verify(Dependency dep){ 37 return type; 38 } 39 44 public abstract T create()throws Throwable ; 45 public String toString(){ 46 return ""+type; 47 } 48 public boolean isSingleton(){ 49 return false; 50 } 51 } 52 | Popular Tags |