Example usage for org.springframework.beans.factory.annotation AutowiredAnnotationBeanPostProcessor processInjection

List of usage examples for org.springframework.beans.factory.annotation AutowiredAnnotationBeanPostProcessor processInjection

Introduction

In this page you can find the example usage for org.springframework.beans.factory.annotation AutowiredAnnotationBeanPostProcessor processInjection.

Prototype

public void processInjection(Object bean) throws BeanCreationException 

Source Link

Document

'Native' processing method for direct calls with an arbitrary target instance, resolving all of its fields and methods which are annotated with @Autowired .

Usage

From source file:com.kurento.kmf.spring.KurentoApplicationContextUtils.java

public static void processInjectionBasedOnApplicationContext(Object bean,
        AnnotationConfigApplicationContext appContext) {
    Assert.notNull(appContext,/*from  ww w  .j a v  a 2s. c  o m*/
            "Cannot process bean injection. Reason the specified ApplicationContext is null");
    Assert.notNull(bean, "Cannot process bean injection into null bean reference");
    AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
    bpp.setBeanFactory(appContext.getAutowireCapableBeanFactory());
    bpp.processInjection(bean);
}

From source file:com.kurento.kmf.spring.KurentoApplicationContextUtils.java

public static void processInjectionBasedOnKurentoApplicationContext(Object bean) {
    Assert.notNull(kurentoApplicationContextInternalReference,
            "Cannot process bean injection. Reason Kurento ApplicationContext has not been initialized");
    Assert.notNull(bean, "Cannot process bean injection into null bean reference");
    AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
    bpp.setBeanFactory(kurentoApplicationContextInternalReference.getAutowireCapableBeanFactory());
    bpp.processInjection(bean);
}

From source file:grails.plugin.viewmodels.constructor.Autowirer.java

public void autowire(Object instance) {
    AutowireCapableBeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory();
    beanFactory.autowireBeanProperties(instance, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    beanFactory.initializeBean(instance, instance.getClass().getName());

    AutowiredAnnotationBeanPostProcessor annotationProcessor = (AutowiredAnnotationBeanPostProcessor) beanFactory
            .createBean(AutowiredAnnotationBeanPostProcessor.class, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME,
                    false);/*from w w  w. jav  a  2 s.  co  m*/

    annotationProcessor.processInjection(instance);

    if (instance instanceof ApplicationContextAware) {
        ((ApplicationContextAware) instance).setApplicationContext(applicationContext);
    }
}

From source file:me.tfeng.toolbox.spring.ApplicationManager.java

public void processInjection(Object bean) {
    AutowiredAnnotationBeanPostProcessor beanPostProcessor = new AutowiredAnnotationBeanPostProcessor();
    beanPostProcessor.setBeanFactory(getApplicationContext().getBeanFactory());
    beanPostProcessor.processInjection(bean);
}

From source file:org.neovera.jdiablo.environment.SpringEnvironment.java

private void injectBeans(Object object) {
    AutowiredAnnotationBeanPostProcessor proc = _context.getBean(AutowiredAnnotationBeanPostProcessor.class);
    if (proc == null) {
        throw new RuntimeException("Could not find an autowired annotation bean post processor of type {} "
                + AutowiredAnnotationBeanPostProcessor.class.getName());
    } else {//ww w  .jav  a 2  s  .  c om
        proc.processInjection(object);
    }
}

From source file:org.codehaus.enunciate.modules.rest.RESTResourceExporter.java

@Override
protected void initApplicationContext() throws BeansException {
    super.initApplicationContext();

    if (resource == null) {
        throw new ApplicationContextException("A REST resource must be provided.");
    }/*  w  w  w.jav  a2s  .c om*/

    if (contentTypeSupport == null) {
        throw new ApplicationContextException("No content type support was supplied.");
    }

    if (this.multipartRequestHandler == null) {
        this.multipartRequestHandler = new DefaultMultipartRequestHandler();
        Map beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(getApplicationContext(),
                AutowiredAnnotationBeanPostProcessor.class);
        if (!beans.isEmpty()) {
            AutowiredAnnotationBeanPostProcessor processor = (AutowiredAnnotationBeanPostProcessor) beans
                    .values().iterator().next();
            processor.processInjection(this.multipartRequestHandler);
        }
    }
}

From source file:org.springframework.web.context.support.SpringBeanAutowiringSupport.java

/**
 * Process {@code @Autowired} injection for the given target object,
 * based on the current web application context.
 * <p>Intended for use as a delegate.
 * @param target the target object to process
 * @see org.springframework.web.context.ContextLoader#getCurrentWebApplicationContext()
 *//*from ww w .  j  a  v a 2 s  . com*/
public static void processInjectionBasedOnCurrentContext(Object target) {
    Assert.notNull(target, "Target object must not be null");
    WebApplicationContext cc = ContextLoader.getCurrentWebApplicationContext();
    if (cc != null) {
        AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
        bpp.setBeanFactory(cc.getAutowireCapableBeanFactory());
        bpp.processInjection(target);
    } else {
        if (logger.isDebugEnabled()) {
            logger.debug("Current WebApplicationContext is not available for processing of "
                    + ClassUtils.getShortName(target.getClass()) + ": "
                    + "Make sure this class gets constructed in a Spring web application. Proceeding without injection.");
        }
    }
}

From source file:org.springframework.web.context.support.SpringBeanAutowiringSupport.java

/**
 * Process {@code @Autowired} injection for the given target object,
 * based on the current root web application context as stored in the ServletContext.
 * <p>Intended for use as a delegate.
 * @param target the target object to process
 * @param servletContext the ServletContext to find the Spring web application context in
 * @see WebApplicationContextUtils#getWebApplicationContext(javax.servlet.ServletContext)
 *///from  w ww.  j  a  v a 2  s .  c om
public static void processInjectionBasedOnServletContext(Object target, ServletContext servletContext) {
    Assert.notNull(target, "Target object must not be null");
    WebApplicationContext cc = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
    bpp.setBeanFactory(cc.getAutowireCapableBeanFactory());
    bpp.processInjection(target);
}