Java Code Examples for org.springframework.core.annotation.AnnotationAttributes#containsKey()
The following examples show how to use
org.springframework.core.annotation.AnnotationAttributes#containsKey() .
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: DurableClientConfiguration.java From spring-boot-data-geode with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("all") public void setImportMetadata(AnnotationMetadata importMetadata) { if (isAnnotationPresent(importMetadata)) { AnnotationAttributes enableDurableClientAttributes = getAnnotationAttributes(importMetadata); this.durableClientId = enableDurableClientAttributes.containsKey("id") ? enableDurableClientAttributes.getString("id") : null; this.durableClientTimeout = enableDurableClientAttributes.containsKey("timeout") ? enableDurableClientAttributes.getNumber("timeout") : DEFAULT_DURABLE_CLIENT_TIMEOUT; this.keepAlive = enableDurableClientAttributes.containsKey("keepAlive") ? enableDurableClientAttributes.getBoolean("keepAlive") : DEFAULT_KEEP_ALIVE; this.readyForEvents = enableDurableClientAttributes.containsKey("readyForEvents") ? enableDurableClientAttributes.getBoolean("readyForEvents") : DEFAULT_READY_FOR_EVENTS; } }
Example 2
Source File: BladeFeignClientsRegistrar.java From blade-tool with GNU Lesser General Public License v3.0 | 4 votes |
private void registerFeignClients(AnnotationMetadata metadata, BeanDefinitionRegistry registry) { List<String> feignClients = SpringFactoriesLoader.loadFactoryNames(getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader()); // 如果 spring.factories 里为空 if (feignClients.isEmpty()) { return; } for (String className : feignClients) { try { Class<?> clazz = beanClassLoader.loadClass(className); AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(clazz, FeignClient.class); if (attributes == null) { continue; } // 如果已经存在该 bean,支持原生的 Feign if (registry.containsBeanDefinition(className)) { continue; } registerClientConfiguration(registry, getClientName(attributes), attributes.get("configuration")); validate(attributes); BeanDefinitionBuilder definition = BeanDefinitionBuilder.genericBeanDefinition(FeignClientFactoryBean.class); definition.addPropertyValue("url", getUrl(attributes)); definition.addPropertyValue("path", getPath(attributes)); String name = getName(attributes); definition.addPropertyValue("name", name); // 兼容最新版本的 spring-cloud-openfeign,尚未发布 StringBuilder aliasBuilder = new StringBuilder(18); if (attributes.containsKey("contextId")) { String contextId = getContextId(attributes); aliasBuilder.append(contextId); definition.addPropertyValue("contextId", contextId); } else { aliasBuilder.append(name); } definition.addPropertyValue("type", className); definition.addPropertyValue("decode404", attributes.get("decode404")); definition.addPropertyValue("fallback", attributes.get("fallback")); definition.addPropertyValue("fallbackFactory", attributes.get("fallbackFactory")); definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); AbstractBeanDefinition beanDefinition = definition.getBeanDefinition(); // alias String alias = aliasBuilder.append("FeignClient").toString(); // has a default, won't be null boolean primary = (Boolean)attributes.get("primary"); beanDefinition.setPrimary(primary); String qualifier = getQualifier(attributes); if (StringUtils.hasText(qualifier)) { alias = qualifier; } BeanDefinitionHolder holder = new BeanDefinitionHolder(beanDefinition, className, new String[] { alias }); BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry); } catch (ClassNotFoundException e) { e.printStackTrace(); } } }
Example 3
Source File: AutowiredAnnotationBeanPostProcessor.java From spring-analysis-note with MIT License | 2 votes |
/** * Determine if the annotated field or method requires its dependency. * <p>A 'required' dependency means that autowiring should fail when no beans * are found. Otherwise, the autowiring process will simply bypass the field * or method when no beans are found. * @param ann the Autowired annotation * @return whether the annotation indicates that a dependency is required * @deprecated since 5.2, in favor of {@link #determineRequiredStatus(MergedAnnotation)} */ @Deprecated protected boolean determineRequiredStatus(AnnotationAttributes ann) { return (!ann.containsKey(this.requiredParameterName) || this.requiredParameterValue == ann.getBoolean(this.requiredParameterName)); }
Example 4
Source File: AutowiredAnnotationBeanPostProcessor.java From java-technology-stack with MIT License | 2 votes |
/** * Determine if the annotated field or method requires its dependency. * <p>A 'required' dependency means that autowiring should fail when no beans * are found. Otherwise, the autowiring process will simply bypass the field * or method when no beans are found. * @param ann the Autowired annotation * @return whether the annotation indicates that a dependency is required */ protected boolean determineRequiredStatus(AnnotationAttributes ann) { return (!ann.containsKey(this.requiredParameterName) || this.requiredParameterValue == ann.getBoolean(this.requiredParameterName)); }
Example 5
Source File: AutowiredAnnotationBeanPostProcessor.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Determine if the annotated field or method requires its dependency. * <p>A 'required' dependency means that autowiring should fail when no beans * are found. Otherwise, the autowiring process will simply bypass the field * or method when no beans are found. * @param ann the Autowired annotation * @return whether the annotation indicates that a dependency is required */ protected boolean determineRequiredStatus(AnnotationAttributes ann) { return (!ann.containsKey(this.requiredParameterName) || this.requiredParameterValue == ann.getBoolean(this.requiredParameterName)); }
Example 6
Source File: AutowiredAnnotationBeanPostProcessor.java From blog_demos with Apache License 2.0 | 2 votes |
/** * Determine if the annotated field or method requires its dependency. * <p>A 'required' dependency means that autowiring should fail when no beans * are found. Otherwise, the autowiring process will simply bypass the field * or method when no beans are found. * @param annotation the Autowired annotation * @return whether the annotation indicates that a dependency is required */ protected boolean determineRequiredStatus(AnnotationAttributes annotation) { return (!annotation.containsKey(this.requiredParameterName) || this.requiredParameterValue == annotation.getBoolean(this.requiredParameterName)); }
Example 7
Source File: AutowiredAnnotationBeanPostProcessor.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Determine if the annotated field or method requires its dependency. * <p>A 'required' dependency means that autowiring should fail when no beans * are found. Otherwise, the autowiring process will simply bypass the field * or method when no beans are found. * @param ann the Autowired annotation * @return whether the annotation indicates that a dependency is required */ protected boolean determineRequiredStatus(AnnotationAttributes ann) { return (!ann.containsKey(this.requiredParameterName) || this.requiredParameterValue == ann.getBoolean(this.requiredParameterName)); }