package jfun.yan.xml.nuts.optional;
import jfun.yan.Binder;
import jfun.yan.Component;
import jfun.yan.xml.nuts.DelegatingNut;
/**
* This Nut class instantiates a proxy object that implements
* a given interface.
* <p>
* Return values of the methods defined in this interface are
* subject to automatic dependency injection.
* </p>
* <p>
* The injection logic is defined by the "binder" attribute that
* references a {@link jfun.yan.Binder} object.
* </p>
* <p>
* @author Ben Yu
* Nov 10, 2005 12:17:26 AM
*/
public class InjectNut extends DelegatingNut {
private Class itf;
private Class injectee;
private Binder injection;
public Class getInjectee() {
checkMandatory("injectee", injectee);
return injectee;
}
public void setInjectee(Class injectee) {
this.injectee = injectee;
}
public Binder getInjection() {
checkMandatory("injection", injection);
return injection;
}
public void setInjection(Binder injection) {
this.injection = injection;
}
public Class getType() {
checkMandatory("type", itf);
return itf;
}
public void setType(Class itf) {
this.itf = itf;
}
public Component eval(){
final Component proxied = getMandatory();
return InjectorNut.helper
.getProxyComponentReturningInjected(getComponentClassLoader(),
itf, proxied, injectee, injection);
}
}