本文整理了Java中org.springframework.beans.factory.config.BeanDefinition.getAttribute()
方法的一些代码示例,展示了BeanDefinition.getAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BeanDefinition.getAttribute()
方法的具体详情如下:
包路径:org.springframework.beans.factory.config.BeanDefinition
类名称:BeanDefinition
方法名:getAttribute
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine the order for the given configuration class bean definition,
* as set by {@link #checkConfigurationClassCandidate}.
* @param beanDef the bean definition to check
* @return the {@link Order @Order} annotation value on the configuration class,
* or {@link Ordered#LOWEST_PRECEDENCE} if none declared
* @since 4.2
*/
public static int getOrder(BeanDefinition beanDef) {
Integer order = (Integer) beanDef.getAttribute(ORDER_ATTRIBUTE);
return (order != null ? order : Ordered.LOWEST_PRECEDENCE);
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine whether the given bean definition indicates a full {@code @Configuration}
* class, through checking {@link #checkConfigurationClassCandidate}'s metadata marker.
*/
public static boolean isFullConfigurationClass(BeanDefinition beanDef) {
return CONFIGURATION_CLASS_FULL.equals(beanDef.getAttribute(CONFIGURATION_CLASS_ATTRIBUTE));
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine whether the given bean definition indicates a lite {@code @Configuration}
* class, through checking {@link #checkConfigurationClassCandidate}'s metadata marker.
*/
public static boolean isLiteConfigurationClass(BeanDefinition beanDef) {
return CONFIGURATION_CLASS_LITE.equals(beanDef.getAttribute(CONFIGURATION_CLASS_ATTRIBUTE));
}
代码示例来源:origin: org.springframework/spring-context
/**
* Determine the order for the given configuration class bean definition,
* as set by {@link #checkConfigurationClassCandidate}.
* @param beanDef the bean definition to check
* @return the {@link Order @Order} annotation value on the configuration class,
* or {@link Ordered#LOWEST_PRECEDENCE} if none declared
* @since 4.2
*/
public static int getOrder(BeanDefinition beanDef) {
Integer order = (Integer) beanDef.getAttribute(ORDER_ATTRIBUTE);
return (order != null ? order : Ordered.LOWEST_PRECEDENCE);
}
代码示例来源:origin: org.springframework/spring-context
/**
* Determine whether the given bean definition indicates a full {@code @Configuration}
* class, through checking {@link #checkConfigurationClassCandidate}'s metadata marker.
*/
public static boolean isFullConfigurationClass(BeanDefinition beanDef) {
return CONFIGURATION_CLASS_FULL.equals(beanDef.getAttribute(CONFIGURATION_CLASS_ATTRIBUTE));
}
代码示例来源:origin: org.springframework/spring-context
/**
* Determine whether the given bean definition indicates a lite {@code @Configuration}
* class, through checking {@link #checkConfigurationClassCandidate}'s metadata marker.
*/
public static boolean isLiteConfigurationClass(BeanDefinition beanDef) {
return CONFIGURATION_CLASS_LITE.equals(beanDef.getAttribute(CONFIGURATION_CLASS_ATTRIBUTE));
}
代码示例来源:origin: spring-projects/spring-framework
protected boolean resolveProxyTargetClass(BeanDefinition beanDefinition) {
boolean proxyTargetClass = this.defaultProxyTargetClass;
Object attributeValue = beanDefinition.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
if (attributeValue instanceof Boolean) {
proxyTargetClass = (Boolean) attributeValue;
}
else if (attributeValue instanceof String) {
proxyTargetClass = Boolean.valueOf((String) attributeValue);
}
else if (attributeValue != null) {
throw new BeanDefinitionStoreException("Invalid proxy target class attribute [" +
PROXY_TARGET_CLASS_ATTRIBUTE + "] with value '" + attributeValue +
"': needs to be of type Boolean or String");
}
return proxyTargetClass;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine whether the given bean should be proxied with its target
* class rather than its interfaces. Checks the
* {@link #PRESERVE_TARGET_CLASS_ATTRIBUTE "preserveTargetClass" attribute}
* of the corresponding bean definition.
* @param beanFactory the containing ConfigurableListableBeanFactory
* @param beanName the name of the bean
* @return whether the given bean should be proxied with its target class
*/
public static boolean shouldProxyTargetClass(
ConfigurableListableBeanFactory beanFactory, @Nullable String beanName) {
if (beanName != null && beanFactory.containsBeanDefinition(beanName)) {
BeanDefinition bd = beanFactory.getBeanDefinition(beanName);
return Boolean.TRUE.equals(bd.getAttribute(PRESERVE_TARGET_CLASS_ATTRIBUTE));
}
return false;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Get the refresh check delay for the given {@link ScriptFactory} {@link BeanDefinition}.
* If the {@link BeanDefinition} has a
* {@link org.springframework.core.AttributeAccessor metadata attribute}
* under the key {@link #REFRESH_CHECK_DELAY_ATTRIBUTE} which is a valid {@link Number}
* type, then this value is used. Otherwise, the {@link #defaultRefreshCheckDelay}
* value is used.
* @param beanDefinition the BeanDefinition to check
* @return the refresh check delay
*/
protected long resolveRefreshCheckDelay(BeanDefinition beanDefinition) {
long refreshCheckDelay = this.defaultRefreshCheckDelay;
Object attributeValue = beanDefinition.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
if (attributeValue instanceof Number) {
refreshCheckDelay = ((Number) attributeValue).longValue();
}
else if (attributeValue instanceof String) {
refreshCheckDelay = Long.parseLong((String) attributeValue);
}
else if (attributeValue != null) {
throw new BeanDefinitionStoreException("Invalid refresh check delay attribute [" +
REFRESH_CHECK_DELAY_ATTRIBUTE + "] with value '" + attributeValue +
"': needs to be of type Number or String");
}
return refreshCheckDelay;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Check whether the given bean definition is not subject to the annotation-based
* required property check as performed by this post-processor.
* <p>The default implementations check for the presence of the
* {@link #SKIP_REQUIRED_CHECK_ATTRIBUTE} attribute in the bean definition, if any.
* It also suggests skipping in case of a bean definition with a "factory-bean"
* reference set, assuming that instance-based factories pre-populate the bean.
* @param beanFactory the BeanFactory to check against
* @param beanName the name of the bean to check against
* @return {@code true} to skip the bean; {@code false} to process it
*/
protected boolean shouldSkip(@Nullable ConfigurableListableBeanFactory beanFactory, String beanName) {
if (beanFactory == null || !beanFactory.containsBeanDefinition(beanName)) {
return false;
}
BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
if (beanDefinition.getFactoryBeanName() != null) {
return true;
}
Object value = beanDefinition.getAttribute(SKIP_REQUIRED_CHECK_ATTRIBUTE);
return (value != null && (Boolean.TRUE.equals(value) || Boolean.valueOf(value.toString())));
}
代码示例来源:origin: org.springframework/spring-context
protected boolean resolveProxyTargetClass(BeanDefinition beanDefinition) {
boolean proxyTargetClass = this.defaultProxyTargetClass;
Object attributeValue = beanDefinition.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE);
if (attributeValue instanceof Boolean) {
proxyTargetClass = (Boolean) attributeValue;
}
else if (attributeValue instanceof String) {
proxyTargetClass = Boolean.valueOf((String) attributeValue);
}
else if (attributeValue != null) {
throw new BeanDefinitionStoreException("Invalid proxy target class attribute [" +
PROXY_TARGET_CLASS_ATTRIBUTE + "] with value '" + attributeValue +
"': needs to be of type Boolean or String");
}
return proxyTargetClass;
}
代码示例来源:origin: spring-projects/spring-batch
/**
* @param beanName a bean definition name
* @param attributeName the name of the property
* @param beanFactory a {@link BeanFactory}
* @return The value for the attribute of the bean. Search parent hierarchy
* if necessary. Return null if none is found.
*/
public static Object getAttribute(String beanName, String attributeName, ConfigurableListableBeanFactory beanFactory) {
return beanFactory.getMergedBeanDefinition(beanName).getAttribute(attributeName);
}
}
代码示例来源:origin: org.springframework/spring-context
/**
* Get the refresh check delay for the given {@link ScriptFactory} {@link BeanDefinition}.
* If the {@link BeanDefinition} has a
* {@link org.springframework.core.AttributeAccessor metadata attribute}
* under the key {@link #REFRESH_CHECK_DELAY_ATTRIBUTE} which is a valid {@link Number}
* type, then this value is used. Otherwise, the {@link #defaultRefreshCheckDelay}
* value is used.
* @param beanDefinition the BeanDefinition to check
* @return the refresh check delay
*/
protected long resolveRefreshCheckDelay(BeanDefinition beanDefinition) {
long refreshCheckDelay = this.defaultRefreshCheckDelay;
Object attributeValue = beanDefinition.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE);
if (attributeValue instanceof Number) {
refreshCheckDelay = ((Number) attributeValue).longValue();
}
else if (attributeValue instanceof String) {
refreshCheckDelay = Long.parseLong((String) attributeValue);
}
else if (attributeValue != null) {
throw new BeanDefinitionStoreException("Invalid refresh check delay attribute [" +
REFRESH_CHECK_DELAY_ATTRIBUTE + "] with value '" + attributeValue +
"': needs to be of type Number or String");
}
return refreshCheckDelay;
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Determine the original target class for the specified bean, if possible,
* otherwise falling back to a regular {@code getType} lookup.
* @param beanFactory the containing ConfigurableListableBeanFactory
* @param beanName the name of the bean
* @return the original target class as stored in the bean definition, if any
* @since 4.2.3
* @see org.springframework.beans.factory.BeanFactory#getType(String)
*/
@Nullable
public static Class<?> determineTargetClass(
ConfigurableListableBeanFactory beanFactory, @Nullable String beanName) {
if (beanName == null) {
return null;
}
if (beanFactory.containsBeanDefinition(beanName)) {
BeanDefinition bd = beanFactory.getMergedBeanDefinition(beanName);
Class<?> targetClass = (Class<?>) bd.getAttribute(ORIGINAL_TARGET_CLASS_ATTRIBUTE);
if (targetClass != null) {
return targetClass;
}
}
return beanFactory.getType(beanName);
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void metadataIsInherited() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("testBean2");
assertEquals("Metadata not inherited", "bar", beanDefinition.getAttribute("foo"));
assertEquals("Child metdata not attached", "123", beanDefinition.getAttribute("abc"));
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public boolean isAutowireCandidate(BeanDefinitionHolder bdHolder, DependencyDescriptor descriptor) {
if (!bdHolder.getBeanDefinition().isAutowireCandidate()) {
return false;
}
if (!bdHolder.getBeanName().matches("[a-z-]+")) {
return false;
}
if (bdHolder.getBeanDefinition().getAttribute("priority").equals("1")) {
return true;
}
return false;
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void testDecorationViaAttribute() throws Exception {
BeanDefinition beanDefinition = this.beanFactory.getBeanDefinition("decorateWithAttribute");
assertEquals("foo", beanDefinition.getAttribute("objectName"));
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void metadataAttachment() throws Exception {
BeanDefinition beanDefinition1 = this.beanFactory.getMergedBeanDefinition("testBean1");
assertEquals("bar", beanDefinition1.getAttribute("foo"));
}
代码示例来源:origin: spring-projects/spring-framework
getRegistry().getBeanDefinition(name).getAttribute(GroovyBeanDefinitionWrapper.class.getName());
if (beanDefinition != null) {
return new GroovyRuntimeBeanReference(name, beanDefinition, false);
代码示例来源:origin: spring-projects/spring-framework
scriptedObjectBeanName, scriptFactory, scriptSource, isFactoryBean);
boolean proxyTargetClass = resolveProxyTargetClass(bd);
String language = (String) bd.getAttribute(LANGUAGE_ATTRIBUTE);
if (proxyTargetClass && (language == null || !language.equals("groovy"))) {
throw new BeanDefinitionValidationException(
内容来源于网络,如有侵权,请联系作者删除!