Package org.springframework.beans.factory.config

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


    }

    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

  @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

  @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

    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

  @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

            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

    }

    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

        }
        Map<String, ?> beansFound = applicationContext.getBeansOfType(parameterType);
        if (beansFound.isEmpty()) {
            return null;
        } else if (beansFound.size() > 1) {
            final AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
            if (beanFactory instanceof ConfigurableListableBeanFactory) {
                for (Map.Entry<String, ?> bean : beansFound.entrySet()) {
                    final ConfigurableListableBeanFactory clBeanFactory = (ConfigurableListableBeanFactory) beanFactory;
                    if (clBeanFactory.containsBeanDefinition(bean.getKey())
                            && clBeanFactory.getBeanDefinition(bean.getKey()).isPrimary()) {
View Full Code Here

     * @param testCase           the test case for which the beans will be injected
     */
    private void injectDependencies(ApplicationContext applicationContext, Object testCase) {

        // retrieves the bean factory
        AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
        // injects all the members
        beanFactory.autowireBeanProperties(testCase, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
        // initialize the bean
        beanFactory.initializeBean(testCase, testCase.getClass().getName());
    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.AutowireCapableBeanFactory

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.