Package jfun.yan.xml.nuts.optional

Source Code of jfun.yan.xml.nuts.optional.InjectNut

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);
  }
}
TOP

Related Classes of jfun.yan.xml.nuts.optional.InjectNut

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.