1 6 7 package org.jfox.ioc.factory; 8 9 import org.jfox.ioc.Component; 10 import org.jfox.ioc.ComponentName; 11 import org.jfox.ioc.Registry; 12 import org.jfox.ioc.depend.Dependency; 13 import org.jfox.ioc.exception.ComponentException; 14 15 16 22 23 public abstract class ComponentFactory { 24 25 30 public abstract Component makeComponent() throws ComponentException; 31 32 36 public abstract ComponentName getComponentName(); 37 38 41 public abstract Class getImplementation(); 42 43 46 public abstract Dependency[] getParameters(); 47 48 51 public abstract Registry getRegistry(); 52 53 58 public abstract void setRegistry(Registry registry); 59 60 66 protected Object [] resolveParameters(Dependency[] params) throws ComponentException { 67 if(params == null || params.length == 0) { 68 return new Object []{}; 69 } 70 else { 71 Object [] objs = new Object [params.length]; 72 for(int i = 0; i < params.length; i++) { 73 objs[i] = params[i].resolveValue(getRegistry()); 74 } 75 return objs; 76 } 77 } 78 79 84 protected Class [] getParameterTypes(Dependency[] params) { 85 if(params == null) { 86 return new Class []{}; 87 } 88 else { 89 Class [] types = new Class [params.length]; 90 for(int i = 0; i < params.length; i++) { 91 types[i] = params[i].getType(); 92 } 93 return types; 94 } 95 } 96 97 } | Popular Tags |