Examples of AutowireCapableBeanFactory


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

        if (function instanceof ServletContextAware) {
            ((ServletContextAware) function).setServletContext(servletContext);
        }
        if (function instanceof AbstractFunction) {
            AbstractFunction abstractFunction = (AbstractFunction) function;
            AutowireCapableBeanFactory autowireCapableBeanFactory = null;

            if (abstractFunction.isAutowireByName() || abstractFunction.isAutowireByType()) {
                if (applicationContext instanceof ConfigurableApplicationContext) {
                    ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) applicationContext;
                    autowireCapableBeanFactory = configurableApplicationContext.getBeanFactory();
                } else if (beanFactory instanceof AutowireCapableBeanFactory) {
                    autowireCapableBeanFactory = (AutowireCapableBeanFactory) beanFactory;
                } else if (applicationContext == null && beanFactory == null) {
                    throw new ValangException("Could not autowire function: no application context or bean factory available", line, column);
                } else {
                    throw new ValangException("Could not autowire function: application context or bean factory does not support autowiring", line, column);
                }
            }
            if (abstractFunction.isAutowireByName()) {
                autowireCapableBeanFactory.autowireBeanProperties(function, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
            }
            if (abstractFunction.isAutowireByType()) {
                autowireCapableBeanFactory.autowireBeanProperties(function, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);
            }
            try {
                abstractFunction.init();
            } catch (Exception e) {
                throw new ValangException("Error initializing function", e, line, column);
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

    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

     * @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

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

   
   
    @Override
    protected View loadView(final String viewName, final Locale locale) throws Exception {
       
        final AutowireCapableBeanFactory beanFactory = getApplicationContext().getAutowireCapableBeanFactory();
       
        AbstractThymeleafView view = BeanUtils.instantiateClass(getViewClass());

        if (beanFactory.containsBean(viewName)) {
            final Class<?> viewBeanType = beanFactory.getType(viewName);
            // viewBeanType could be null if bean is abstract (just a set of properties)
            if (viewBeanType != null && AbstractThymeleafView.class.isAssignableFrom(viewBeanType)) {
                view = (AbstractThymeleafView) beanFactory.configureBean(view, viewName);
            } else {
                // The AUTOWIRE_NO mode applies autowiring only through annotations
                beanFactory.autowireBeanProperties(view, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
                // A bean with this name exists, so we apply its properties
                beanFactory.applyBeanPropertyValues(view, viewName);
                // Finally, we let Spring do the remaining initializations (incl. proxifying if needed)
                view = (AbstractThymeleafView) beanFactory.initializeBean(view, viewName);
            }
        } else {
            // The AUTOWIRE_NO mode applies autowiring only through annotations
            beanFactory.autowireBeanProperties(view, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
            // Finally, we let Spring do the remaining initializations (incl. proxifying if needed)
            view = (AbstractThymeleafView) beanFactory.initializeBean(view, viewName);
        }

        view.setTemplateEngine(getTemplateEngine());
        view.setStaticVariables(getStaticVariables());
View Full Code Here

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

        Validate.notNull(this.applicationContext,
                "ApplicationContext has not been initialized in resource resolver. TemplateResolver or " +
                        "ResourceResolver might not have been correctly configured by the Spring Application Context.");

        final AutowireCapableBeanFactory beanFactory = this.applicationContext.getAutowireCapableBeanFactory();
        beanFactory.initializeBean(this.resourceResolver, "springResourceResolver");

    }
View Full Code Here

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

   
   
    @Override
    protected View loadView(final String viewName, final Locale locale) throws Exception {
       
        final AutowireCapableBeanFactory beanFactory = getApplicationContext().getAutowireCapableBeanFactory();
       
        AbstractThymeleafView view = BeanUtils.instantiateClass(getViewClass());

        if (beanFactory.containsBean(viewName)) {
            final Class<?> viewBeanType = beanFactory.getType(viewName);
            // viewBeanType could be null if bean is abstract (just a set of properties)
            if (viewBeanType != null && AbstractThymeleafView.class.isAssignableFrom(viewBeanType)) {
                view = (AbstractThymeleafView) beanFactory.configureBean(view, viewName);
            } else {
                // The AUTOWIRE_NO mode applies autowiring only through annotations
                beanFactory.autowireBeanProperties(view, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
                // A bean with this name exists, so we apply its properties
                beanFactory.applyBeanPropertyValues(view, viewName);
                // Finally, we let Spring do the remaining initializations (incl. proxifying if needed)
                view = (AbstractThymeleafView) beanFactory.initializeBean(view, viewName);
            }
        } else {
            // The AUTOWIRE_NO mode applies autowiring only through annotations
            beanFactory.autowireBeanProperties(view, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
            // Finally, we let Spring do the remaining initializations (incl. proxifying if needed)
            view = (AbstractThymeleafView) beanFactory.initializeBean(view, viewName);
        }

        view.setTemplateEngine(getTemplateEngine());
        view.setStaticVariables(getStaticVariables());
View Full Code Here

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

        Validate.notNull(this.applicationContext,
                "ApplicationContext has not been initialized in resource resolver. TemplateResolver or " +
                        "ResourceResolver might not have been correctly configured by the Spring Application Context.");

        final AutowireCapableBeanFactory beanFactory = this.applicationContext.getAutowireCapableBeanFactory();
        beanFactory.initializeBean(this.resourceResolver, "springResourceResolver");

    }
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
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.