Package org.nutz.integration.dwr

Source Code of org.nutz.integration.dwr.NutCreator

package org.nutz.integration.dwr;

import org.directwebremoting.create.AbstractCreator;
import org.directwebremoting.util.LocalUtil;
import org.directwebremoting.util.Messages;
import org.nutz.ioc.Ioc;
import org.nutz.lang.Lang;
import org.nutz.mvc.Mvcs;

@SuppressWarnings("rawtypes")
public class NutCreator extends AbstractCreator {
 
  private Class clazz;
  private String beanName;
  private Ioc ioc;

  public Class getType() {
    if (clazz != null)
      return clazz;
    try {
      return getInstance().getClass();
    } catch (Throwable e) {
      throw Lang.wrapThrow(e);
    }
  }

  @SuppressWarnings("unchecked")
  public Object getInstance() throws InstantiationException {
    Ioc ioc = this.ioc;
    if (ioc == null)
      ioc = Mvcs.getIoc();
    if (beanName != null)
      return ioc.get(clazz, beanName);
    return ioc.get(clazz);
  }

  public void setClass(String classname) {
    try {
      this.clazz = LocalUtil.classForName(classname);
    } catch (ClassNotFoundException ex) {
      throw new IllegalArgumentException(Messages.getString( "Creator.ClassNotFound", classname));
    }
  }

}
TOP

Related Classes of org.nutz.integration.dwr.NutCreator

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.