1 package jfun.yan.etc; 2 import jfun.yan.Binder; 3 import jfun.yan.Component; 4 import jfun.yan.Map2; 5 import jfun.yan.Monad; 6 import jfun.yan.Mutation; 7 import jfun.yan.util.Utils; 8 9 16 public class InjectorHelper{ 17 32 public static Component getInjectorComponent(Class injector_itf, Binder binder){ 33 return Utils.asComponent(binder).factory(injector_itf); 34 } 35 36 58 public static Component getProxyComponentReturningInjected( 59 final ClassLoader cloader, final Class itf, 60 Component proxied, final Class injectee_type, Binder binder){ 61 final Component mutation = getInjectorComponent(Mutation.class, binder); 62 final Component injected = Monad.map(proxied, mutation, new Map2(){ 63 public Object map(Object proxied, Object mut){ 64 return InjectingProxy.getInjectingProxy(cloader, itf, 65 proxied, injectee_type, (Mutation)mut); 66 } 67 }); 68 return injected; 69 } 70 94 public static Component getProxyComponentReturningInjected(final Class itf, 95 Component proxied, Class injectee_type, Binder binder){ 96 return getProxyComponentReturningInjected(injectee_type.getClassLoader(), 97 itf, proxied, injectee_type, binder); 98 } 99 } | Popular Tags |