Examples of AutowireCapableBeanFactory


Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

    }

    public Object createTool() throws Exception {
        Object tool = fc.newInstance();

        AutowireCapableBeanFactory factory = beanFactory.getAutowireCapableBeanFactory();

        if (autowire) {
            factory.autowireBeanProperties(tool, AbstractBeanDefinition.AUTOWIRE_NO, false);
        }

        factory.initializeBean(tool, getBeanName());

        return tool;
    }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

    }

    public Object createTool() throws Exception {
        Object tool = fc.newInstance();

        AutowireCapableBeanFactory factory = beanFactory.getAutowireCapableBeanFactory();

        if (autowire) {
            factory.autowireBeanProperties(tool, AbstractBeanDefinition.AUTOWIRE_NO, false);
        }

        factory.initializeBean(tool, getBeanName());

        return tool;
    }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

  @SuppressWarnings("unchecked")
  public void sessionDidActivate(final HttpSessionEvent event) {
    HttpSession session = event.getSession();
    ServletContext servletContext = session.getServletContext();
    WebApplicationContext webAppContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    AutowireCapableBeanFactory autowireFactory = webAppContext.getAutowireCapableBeanFactory();

    Enumeration<String> names = session.getAttributeNames();
    while (names.hasMoreElements()) {
      String name = names.nextElement();

      if (webAppContext.containsBean(name)) {
        Object bean = session.getAttribute(name);

        bean = autowireFactory.configureBean(bean, name);
        session.setAttribute(name, bean);
      }
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

  @Override
  public void sessionDidActivate(final HttpSessionEvent event) {
    HttpSession session = event.getSession();
    ServletContext servletContext = session.getServletContext();
    WebApplicationContext webAppContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    AutowireCapableBeanFactory autowireFactory = webAppContext.getAutowireCapableBeanFactory();

    Enumeration<String> names = session.getAttributeNames();
    while (names.hasMoreElements()) {
      String name = names.nextElement();

      if (webAppContext.containsBean(name)) {
        Object bean = session.getAttribute(name);

        bean = autowireFactory.configureBean(bean, name);
        session.setAttribute(name, bean);
      }
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

    private void initWildcardDefinitionMap() {
        if (null != appContexts) {
            for (ApplicationContext appContext : appContexts) {
                for (String n : appContext.getBeanDefinitionNames()) {
                    if (isWildcardBeanName(n)) {
                        AutowireCapableBeanFactory bf = appContext.getAutowireCapableBeanFactory();
                        BeanDefinitionRegistry bdr = (BeanDefinitionRegistry) bf;
                        BeanDefinition bd = bdr.getBeanDefinition(n);
                        String className = bd.getBeanClassName();
                        if (null != className) {
                            String orig = n;
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

  @SuppressWarnings("unchecked")
  public void sessionDidActivate(final HttpSessionEvent event) {
    HttpSession session = event.getSession();
    ServletContext servletContext = session.getServletContext();
    WebApplicationContext webAppContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    AutowireCapableBeanFactory autowireFactory = webAppContext.getAutowireCapableBeanFactory();

    Enumeration<String> names = session.getAttributeNames();
    while (names.hasMoreElements()) {
      String name = names.nextElement();

      if (webAppContext.containsBean(name)) {
        Object bean = session.getAttribute(name);

        bean = autowireFactory.configureBean(bean, name);
        session.setAttribute(name, bean);
      }
    }
  }
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

            if (!applicationContextHolder.isApplicationContextLoaded()) {
                applicationContextHolder.loadApplicationContext();
            }

            TestNGCitrusTestBuilder builder = (TestNGCitrusTestBuilder) testBuilderClass.getConstructor(new Class[]{}).newInstance();
            AutowireCapableBeanFactory beanFactory = applicationContextHolder.getApplicationContext().getAutowireCapableBeanFactory();
            beanFactory.autowireBeanProperties(builder, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
            beanFactory.initializeBean(builder, testBuilderClass.getName());

            for (Method method : ReflectionUtils.getAllDeclaredMethods(testBuilderClass)) {
                CitrusTest citrusTestAnnotation = method.getAnnotation(CitrusTest.class);
                if (citrusTestAnnotation != null) {
                    if (StringUtils.hasText(methodName)) {
View Full Code Here

Examples of org.springframework.beans.factory.config.AutowireCapableBeanFactory

    }

    private Object findAutowireCandidateOfType(Class<?> beanType) {
        String[] candidates = applicationContext.getBeanNamesForType(beanType);
        String primary = null;
        AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
        if (beanFactory instanceof ConfigurableListableBeanFactory) {
            for (String bean : candidates) {
                final ConfigurableListableBeanFactory clBeanFactory = (ConfigurableListableBeanFactory) beanFactory;
                if (clBeanFactory.containsBeanDefinition(bean) && clBeanFactory.getBeanDefinition(bean).isPrimary()) {
                    if (primary != null) {
View Full Code Here

Examples of us.codecraft.tinyioc.beans.factory.AutowireCapableBeanFactory

public class ClassPathXmlApplicationContext extends AbstractApplicationContext {

  private String configLocation;

  public ClassPathXmlApplicationContext(String configLocation) throws Exception {
    this(configLocation, new AutowireCapableBeanFactory());
  }
View Full Code Here

Examples of us.codecraft.tinyioc.beans.factory.AutowireCapableBeanFactory

        // 1.读取配置
        XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(new ResourceLoader());
        xmlBeanDefinitionReader.loadBeanDefinitions("tinyioc.xml");

        // 2.初始化BeanFactory并注册bean
        AbstractBeanFactory beanFactory = new AutowireCapableBeanFactory();
        for (Map.Entry<String, BeanDefinition> beanDefinitionEntry : xmlBeanDefinitionReader.getRegistry().entrySet()) {
            beanFactory.registerBeanDefinition(beanDefinitionEntry.getKey(), beanDefinitionEntry.getValue());
        }

        // 3.获取bean
        HelloWorldService helloWorldService = (HelloWorldService) beanFactory.getBean("helloWorldService");
        helloWorldService.helloWorld();
    }
View Full Code Here
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.