Java Code Examples for org.springframework.beans.factory.annotation.InjectionMetadata#inject()

The following examples show how to use org.springframework.beans.factory.annotation.InjectionMetadata#inject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommonAnnotationBeanPostProcessor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) {
	InjectionMetadata metadata = findResourceMetadata(beanName, bean.getClass(), pvs);
	try {
		metadata.inject(bean, beanName, pvs);
	}
	catch (Throwable ex) {
		throw new BeanCreationException(beanName, "Injection of resource dependencies failed", ex);
	}
	return pvs;
}
 
Example 2
Source File: PersistenceAnnotationBeanPostProcessor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) {
	InjectionMetadata metadata = findPersistenceMetadata(beanName, bean.getClass(), pvs);
	try {
		metadata.inject(bean, beanName, pvs);
	}
	catch (Throwable ex) {
		throw new BeanCreationException(beanName, "Injection of persistence dependencies failed", ex);
	}
	return pvs;
}
 
Example 3
Source File: CommonAnnotationBeanPostProcessor.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) {
	InjectionMetadata metadata = findResourceMetadata(beanName, bean.getClass(), pvs);
	try {
		metadata.inject(bean, beanName, pvs);
	}
	catch (Throwable ex) {
		throw new BeanCreationException(beanName, "Injection of resource dependencies failed", ex);
	}
	return pvs;
}
 
Example 4
Source File: PersistenceAnnotationBeanPostProcessor.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) {
	InjectionMetadata metadata = findPersistenceMetadata(beanName, bean.getClass(), pvs);
	try {
		metadata.inject(bean, beanName, pvs);
	}
	catch (Throwable ex) {
		throw new BeanCreationException(beanName, "Injection of persistence dependencies failed", ex);
	}
	return pvs;
}
 
Example 5
Source File: CommonAnnotationBeanPostProcessor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public PropertyValues postProcessPropertyValues(
		PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {

	InjectionMetadata metadata = findResourceMetadata(beanName, bean.getClass(), pvs);
	try {
		metadata.inject(bean, beanName, pvs);
	}
	catch (Throwable ex) {
		throw new BeanCreationException(beanName, "Injection of resource dependencies failed", ex);
	}
	return pvs;
}
 
Example 6
Source File: PersistenceAnnotationBeanPostProcessor.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public PropertyValues postProcessPropertyValues(
		PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {

	InjectionMetadata metadata = findPersistenceMetadata(beanName, bean.getClass(), pvs);
	try {
		metadata.inject(bean, beanName, pvs);
	}
	catch (Throwable ex) {
		throw new BeanCreationException(beanName, "Injection of persistence dependencies failed", ex);
	}
	return pvs;
}
 
Example 7
Source File: CommonAnnotationBeanPostProcessor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public PropertyValues postProcessPropertyValues(
		PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {

	InjectionMetadata metadata = findResourceMetadata(beanName, bean.getClass(), pvs);
	try {
		metadata.inject(bean, beanName, pvs);
	}
	catch (Throwable ex) {
		throw new BeanCreationException(beanName, "Injection of resource dependencies failed", ex);
	}
	return pvs;
}
 
Example 8
Source File: PersistenceAnnotationBeanPostProcessor.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public PropertyValues postProcessPropertyValues(
		PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException {

	InjectionMetadata metadata = findPersistenceMetadata(beanName, bean.getClass(), pvs);
	try {
		metadata.inject(bean, beanName, pvs);
	}
	catch (Throwable ex) {
		throw new BeanCreationException(beanName, "Injection of persistence dependencies failed", ex);
	}
	return pvs;
}
 
Example 9
Source File: ArmeriaBeanPostProcessor.java    From armeria with Apache License 2.0 5 votes vote down vote up
/**
 * Post-processes the given property values before the factory apply them to the given bean.
 */
@Override
public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) {
    final InjectionMetadata metadata = findLocalArmeriaPortMetadata(beanName, bean.getClass(), pvs);
    try {
        metadata.inject(bean, beanName, pvs);
    } catch (Throwable ex) {
        throw new BeanCreationException(beanName, "Injection of resource dependencies failed", ex);
    }
    return pvs;
}
 
Example 10
Source File: CommonAnnotationBeanPostProcessor.java    From brpc-java with Apache License 2.0 4 votes vote down vote up
/**
 * Post-process the given property values before the factory applies them to the given bean. Allows for checking
 * whether all dependencies have been satisfied, for example based on a "Required" annotation on bean property
 * setters.
 * <p>
 * Also allows for replacing the property values to apply, typically through creating a new MutablePropertyValues
 * instance based on the original PropertyValues, adding or removing specific values.
 *
 * @param pvs the property values that the factory is about to apply (never {@code null})
 * @param pds the relevant property descriptors for the target bean (with ignored dependency types - which the
 *            factory handles specifically - already filtered out)
 * @param bean the bean instance created, but whose properties have not yet been set
 * @param beanName the name of the bean
 * @return the actual property values to apply to to the given bean (can be the passed-in PropertyValues instance),
 *         or {@code null} to skip property population
 * @throws BeansException the beans exception
 * @throws org.springframework.beans.BeansException in case of errors
 * @see org.springframework.beans.MutablePropertyValues
 */
public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean,
        String beanName) throws BeansException {
    List<Class<? extends Annotation>> annotations = getCallback().getMethodFieldAnnotation();
    if (getCallback() == null || annotations == null) {
        return pvs;
    }

    InjectionMetadata metadata = findAnnotationMetadata(bean.getClass(), annotations);
    try {
        metadata.inject(bean, beanName, pvs);
    } catch (Throwable ex) {
        throw new BeanCreationException(beanName, "Autowiring of methods failed", ex);
    }

    return pvs;
}