Java Code Examples for org.springframework.beans.factory.config.DependencyDescriptor#getMethodParameter()
The following examples show how to use
org.springframework.beans.factory.config.DependencyDescriptor#getMethodParameter() .
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: QualifierAnnotationAutowireCandidateResolver.java From spring-analysis-note with MIT License | 6 votes |
/** * Determine whether the provided bean definition is an autowire candidate. * <p>To be considered a candidate the bean's <em>autowire-candidate</em> * attribute must not have been set to 'false'. Also, if an annotation on * the field or parameter to be autowired is recognized by this bean factory * as a <em>qualifier</em>, the bean must 'match' against the annotation as * well as any attributes it may contain. The bean definition must contain * the same qualifier or match by meta attributes. A "value" attribute will * fallback to match against the bean name or an alias if a qualifier or * attribute does not match. * @see Qualifier */ @Override public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { boolean match = super.isAutowireCandidate(bdHolder, descriptor); if (match) { match = checkQualifiers(bdHolder, descriptor.getAnnotations()); if (match) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { Method method = methodParam.getMethod(); if (method == null || void.class == method.getReturnType()) { match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations()); } } } } return match; }
Example 2
Source File: QualifierAnnotationAutowireCandidateResolver.java From java-technology-stack with MIT License | 6 votes |
/** * Determine whether the provided bean definition is an autowire candidate. * <p>To be considered a candidate the bean's <em>autowire-candidate</em> * attribute must not have been set to 'false'. Also, if an annotation on * the field or parameter to be autowired is recognized by this bean factory * as a <em>qualifier</em>, the bean must 'match' against the annotation as * well as any attributes it may contain. The bean definition must contain * the same qualifier or match by meta attributes. A "value" attribute will * fallback to match against the bean name or an alias if a qualifier or * attribute does not match. * @see Qualifier */ @Override public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { boolean match = super.isAutowireCandidate(bdHolder, descriptor); if (match) { match = checkQualifiers(bdHolder, descriptor.getAnnotations()); if (match) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { Method method = methodParam.getMethod(); if (method == null || void.class == method.getReturnType()) { match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations()); } } } } return match; }
Example 3
Source File: QualifierAnnotationAutowireCandidateResolver.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Determine whether the provided bean definition is an autowire candidate. * <p>To be considered a candidate the bean's <em>autowire-candidate</em> * attribute must not have been set to 'false'. Also, if an annotation on * the field or parameter to be autowired is recognized by this bean factory * as a <em>qualifier</em>, the bean must 'match' against the annotation as * well as any attributes it may contain. The bean definition must contain * the same qualifier or match by meta attributes. A "value" attribute will * fallback to match against the bean name or an alias if a qualifier or * attribute does not match. * @see Qualifier */ @Override public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { boolean match = super.isAutowireCandidate(bdHolder, descriptor); if (match && descriptor != null) { match = checkQualifiers(bdHolder, descriptor.getAnnotations()); if (match) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { Method method = methodParam.getMethod(); if (method == null || void.class == method.getReturnType()) { match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations()); } } } } return match; }
Example 4
Source File: QualifierAnnotationAutowireCandidateResolver.java From blog_demos with Apache License 2.0 | 6 votes |
/** * Determine whether the provided bean definition is an autowire candidate. * <p>To be considered a candidate the bean's <em>autowire-candidate</em> * attribute must not have been set to 'false'. Also, if an annotation on * the field or parameter to be autowired is recognized by this bean factory * as a <em>qualifier</em>, the bean must 'match' against the annotation as * well as any attributes it may contain. The bean definition must contain * the same qualifier or match by meta attributes. A "value" attribute will * fallback to match against the bean name or an alias if a qualifier or * attribute does not match. * @see Qualifier */ @Override public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { boolean match = super.isAutowireCandidate(bdHolder, descriptor); if (match && descriptor != null) { match = checkQualifiers(bdHolder, descriptor.getAnnotations()); if (match) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { Method method = methodParam.getMethod(); if (method == null || void.class.equals(method.getReturnType())) { match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations()); } } } } return match; }
Example 5
Source File: QualifierAnnotationAutowireCandidateResolver.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Determine whether the provided bean definition is an autowire candidate. * <p>To be considered a candidate the bean's <em>autowire-candidate</em> * attribute must not have been set to 'false'. Also, if an annotation on * the field or parameter to be autowired is recognized by this bean factory * as a <em>qualifier</em>, the bean must 'match' against the annotation as * well as any attributes it may contain. The bean definition must contain * the same qualifier or match by meta attributes. A "value" attribute will * fallback to match against the bean name or an alias if a qualifier or * attribute does not match. * @see Qualifier */ @Override public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) { boolean match = super.isAutowireCandidate(bdHolder, descriptor); if (match && descriptor != null) { match = checkQualifiers(bdHolder, descriptor.getAnnotations()); if (match) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { Method method = methodParam.getMethod(); if (method == null || void.class == method.getReturnType()) { match = checkQualifiers(bdHolder, methodParam.getMethodAnnotations()); } } } } return match; }
Example 6
Source File: CubaDefaultListableBeanFactory.java From cuba with Apache License 2.0 | 6 votes |
@Override public Object resolveDependency(DependencyDescriptor descriptor, String beanName, Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException { Field field = descriptor.getField(); if (field != null && Logger.class == descriptor.getDependencyType()) { return LoggerFactory.getLogger(getDeclaringClass(descriptor)); } if (field != null && Config.class.isAssignableFrom(field.getType())) { return getConfig(field.getType()); } MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null && Config.class.isAssignableFrom(methodParam.getParameterType())) { return getConfig(methodParam.getParameterType()); } return super.resolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter); }
Example 7
Source File: QualifierAnnotationAutowireCandidateResolver.java From spring-analysis-note with MIT License | 5 votes |
/** * Determine whether the given dependency declares a value annotation. * @see Value */ @Override @Nullable public Object getSuggestedValue(DependencyDescriptor descriptor) { Object value = findValue(descriptor.getAnnotations()); if (value == null) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { value = findValue(methodParam.getMethodAnnotations()); } } return value; }
Example 8
Source File: QualifierAnnotationAutowireCandidateResolver.java From java-technology-stack with MIT License | 5 votes |
/** * Determine whether the given dependency declares a value annotation. * @see Value */ @Override @Nullable public Object getSuggestedValue(DependencyDescriptor descriptor) { Object value = findValue(descriptor.getAnnotations()); if (value == null) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { value = findValue(methodParam.getMethodAnnotations()); } } return value; }
Example 9
Source File: QualifierAnnotationAutowireCandidateResolver.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Determine whether the given dependency declares a value annotation. * @see Value */ @Override public Object getSuggestedValue(DependencyDescriptor descriptor) { Object value = findValue(descriptor.getAnnotations()); if (value == null) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { value = findValue(methodParam.getMethodAnnotations()); } } return value; }
Example 10
Source File: QualifierAnnotationAutowireCandidateResolver.java From blog_demos with Apache License 2.0 | 5 votes |
/** * Determine whether the given dependency carries a value annotation. * @see Value */ @Override public Object getSuggestedValue(DependencyDescriptor descriptor) { Object value = findValue(descriptor.getAnnotations()); if (value == null) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { value = findValue(methodParam.getMethodAnnotations()); } } return value; }
Example 11
Source File: QualifierAnnotationAutowireCandidateResolver.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Determine whether the given dependency carries a value annotation. * @see Value */ @Override public Object getSuggestedValue(DependencyDescriptor descriptor) { Object value = findValue(descriptor.getAnnotations()); if (value == null) { MethodParameter methodParam = descriptor.getMethodParameter(); if (methodParam != null) { value = findValue(methodParam.getMethodAnnotations()); } } return value; }
Example 12
Source File: CubaDefaultListableBeanFactory.java From cuba with Apache License 2.0 | 5 votes |
protected Class<?> getDeclaringClass(DependencyDescriptor descriptor) { MethodParameter methodParameter = descriptor.getMethodParameter(); if (methodParameter != null) { return methodParameter.getDeclaringClass(); } Field field = descriptor.getField(); if (field != null) { return field.getDeclaringClass(); } throw new AssertionError("Injection must be into a method parameter or field."); }
Example 13
Source File: StatefulFactory.java From statefulj with Apache License 2.0 | 4 votes |
@Override public Object getSuggestedValue(DependencyDescriptor descriptor) { Object suggested = null; Field field = descriptor.getField(); MethodParameter methodParameter = descriptor.getMethodParameter(); boolean isStatefulFSM = false; String controllerId = null; Type genericFieldType = null; String fieldName = null; org.statefulj.framework.core.annotations.FSM fsmAnnotation = null; // If this is a StatefulFSM, parse out the Annotation and Type information // if (field != null) { if (isStatefulFSM(field)) { fsmAnnotation = field.getAnnotation(org.statefulj.framework.core.annotations.FSM.class); genericFieldType = field.getGenericType(); fieldName = field.getName(); isStatefulFSM = true; } } else if (methodParameter != null) { if (isStatefulFSM(methodParameter)) { fsmAnnotation = methodParameter.getParameterAnnotation(org.statefulj.framework.core.annotations.FSM.class); genericFieldType = methodParameter.getGenericParameterType(); fieldName = methodParameter.getParameterName(); isStatefulFSM = true; } } // If this is a StatefulFSM field, then resolve bean reference // if (isStatefulFSM) { // Determine the controllerId - either explicit or derived // controllerId = getControllerId(fsmAnnotation); if (StringUtils.isEmpty(controllerId)) { // Get the Managed Class // Class<?> managedClass = getManagedClass(fieldName, genericFieldType); // Fetch the Controller from the mapping // controllerId = deriveControllerId(fieldName, managedClass); } ReferenceFactory refFactory = new ReferenceFactoryImpl(controllerId); suggested = appContext.getBean(refFactory.getStatefulFSMId()); } return (suggested != null) ? suggested : super.getSuggestedValue(descriptor); }