List of usage examples for org.springframework.beans.factory.config DependencyDescriptor DependencyDescriptor
public DependencyDescriptor(Field field, boolean required)
From source file:org.jdal.aop.config.SerializableAnnotationBeanPostProcessor.java
protected DependencyDescriptor getDependencyDescriptor(AnnotatedElement ae) { return new DependencyDescriptor((Field) ae, false); }
From source file:org.glassfish.jersey.server.spring.AutowiredInjectResolver.java
private DependencyDescriptor createSpringDependencyDescriptor(final Injectee injectee) { AnnotatedElement annotatedElement = injectee.getParent(); if (annotatedElement.getClass().isAssignableFrom(Field.class)) { return new DependencyDescriptor((Field) annotatedElement, !injectee.isOptional()); } else if (annotatedElement.getClass().isAssignableFrom(Method.class)) { return new DependencyDescriptor(new MethodParameter((Method) annotatedElement, injectee.getPosition()), !injectee.isOptional()); } else/* www . j av a 2 s . c om*/ return new DependencyDescriptor( new MethodParameter((Constructor) annotatedElement, injectee.getPosition()), !injectee.isOptional()); }
From source file:nl.jeslee.jersey.server.spring.AutowiredInjectResolver.java
private DependencyDescriptor createSpringDependencyDescriptor(final Injectee injectee) { AnnotatedElement annotatedElement = injectee.getParent(); if (annotatedElement.getClass().isAssignableFrom(Field.class)) { return new DependencyDescriptor((Field) annotatedElement, !injectee.isOptional()); } else {//w ww . j ava 2 s. c o m return new DependencyDescriptor( new MethodParameter((Constructor) annotatedElement, injectee.getPosition()), !injectee.isOptional()); } }
From source file:org.springframework.beans.factory.support.ConstructorResolver.java
/** * Template method for resolving the specified argument which is supposed to be autowired. *///from www . j a v a 2s.c om @Nullable protected Object resolveAutowiredArgument(MethodParameter param, String beanName, @Nullable Set<String> autowiredBeanNames, TypeConverter typeConverter, boolean fallback) { Class<?> paramType = param.getParameterType(); if (InjectionPoint.class.isAssignableFrom(paramType)) { InjectionPoint injectionPoint = currentInjectionPoint.get(); if (injectionPoint == null) { throw new IllegalStateException("No current InjectionPoint available for " + param); } return injectionPoint; } try { return this.beanFactory.resolveDependency(new DependencyDescriptor(param, true), beanName, autowiredBeanNames, typeConverter); } catch (NoUniqueBeanDefinitionException ex) { throw ex; } catch (NoSuchBeanDefinitionException ex) { if (fallback) { // Single constructor or factory method -> let's return an empty array/collection // for e.g. a vararg or a non-null List/Set/Map parameter. if (paramType.isArray()) { return Array.newInstance(paramType.getComponentType(), 0); } else if (CollectionFactory.isApproximableCollectionType(paramType)) { return CollectionFactory.createCollection(paramType, 0); } else if (CollectionFactory.isApproximableMapType(paramType)) { return CollectionFactory.createMap(paramType, 0); } } throw ex; } }