Package org.eweb4j.ioc.config.bean

Examples of org.eweb4j.ioc.config.bean.Injection


                                SingleBeanCache.add(beanID, t);

                                // 遍历每个bean的注入配置
                                for (Iterator<Injection> it = iocBean.getInject().iterator(); it
                                                .hasNext();) {
                                        Injection inj = it.next();
                                        String ref = inj.getRef();
                                        if (ref != null && !"".equals(ref)) {
                                                // 如果ref不为空,说明注入的是对象类型,后面需要进入递归
                                                String name = inj.getName();
                                                if (name != null && !"".equals(name)) {
                                                        // 如果属性名字不为空,说明使用的是setter注入方式
                                                        // 使用setter注入的时候,需要提供一个无参构造方法
                                                        if (t == null)
                                                                t = clazz.newInstance();

                                                        ReflectUtil ru = new ReflectUtil(t);
                                                        Method m = ru.getSetter(name);
                                                        if (m != null)
                                                                m.invoke(t, getBean(ref));

                                                } else {
                                                        // 如果属性名字为空,说明使用的是构造器注入方式
                                                        // 使用构造器注入的时候,需要按照构造器参数列表顺序实例化
                                                        t = (T) getBean(ref);
                                                        argList.add(t.getClass());
                                                        initargList.add(t);
                                                }
                                        } else {
                                                // 注入基本类型
                                                String type = inj.getType();
                                                String value = inj.getValue();
                                                if (value == null) {
                                                        value = "";
                                                }
                                                String name = inj.getName();
                                                if (name != null && !"".equals(name)) {
                                                        // 如果属性名字不为空,说明使用的是setter注入方式
                                                        // 使用setter注入的时候,需要提供一个无参构造方法
                                                        if (t == null)
                                                                t = clazz.newInstance();
View Full Code Here


        SingleBeanCache.add(beanID, t);

        // 遍历每个bean的注入配置
        for (Iterator<Injection> it = iocBean.getInject().iterator(); it
            .hasNext();) {
          Injection inj = it.next();
          String ref = inj.getRef();
          if (ref != null && !"".equals(ref)) {
            // 如果ref不为空,说明注入的是对象类型,后面需要进入递归
            String name = inj.getName();
            if (name != null && !"".equals(name)) {
              // 如果属性名字不为空,说明使用的是setter注入方式
              // 使用setter注入的时候,需要提供一个无参构造方法
              if (t == null)
                t = clazz.newInstance();
             
              ReflectUtil ru = new ReflectUtil(t);
              Method m = ru.getSetter(name);
              if (m != null)
                m.invoke(t, getBean(ref));
             
            } else {
              // 如果属性名字为空,说明使用的是构造器注入方式
              // 使用构造器注入的时候,需要按照构造器参数列表顺序实例化
              t = (T)getBean(ref);
              argList.add(t.getClass());
              initargList.add(t);
            }
          } else {
            // 注入基本类型
            String type = inj.getType();
            String value = inj.getValue();
            if (value == null) {
              value = "";
            }
            String name = inj.getName();
            if (name != null && !"".equals(name)) {
              // 如果属性名字不为空,说明使用的是setter注入方式
              // 使用setter注入的时候,需要提供一个无参构造方法
              if (t == null)
                t = clazz.newInstance();
View Full Code Here

public class IOCConfigBeanCreator {
  public static IOCConfigBean getIOCBean(){
    IOCConfigBean iocBean = null;
    iocBean = new IOCConfigBean();
    List<Injection> list = new ArrayList<Injection>();
    Injection depen = new Injection();
    list.add(depen);
    iocBean.setInject(list);
    return iocBean;
  }
View Full Code Here

TOP

Related Classes of org.eweb4j.ioc.config.bean.Injection

Copyright © 2018 www.massapicom. 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.