use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-framework by spring-projects.
the class MyPostProcessor method postProcessBeanFactory.
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
AbstractBeanDefinition bd = (AbstractBeanDefinition) beanFactory.getBeanDefinition("someDependency");
bd.setDescription("post processed by MyPostProcessor");
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project spring-security-oauth by spring-projects.
the class ProviderBeanDefinitionParser method parseInternal.
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
String tokenServicesRef = element.getAttribute("token-services-ref");
String serializerRef = element.getAttribute("serialization-service-ref");
if (!StringUtils.hasText(tokenServicesRef)) {
tokenServicesRef = "oauth2TokenServices";
BeanDefinitionBuilder tokenServices = BeanDefinitionBuilder.rootBeanDefinition(DefaultTokenServices.class);
AbstractBeanDefinition tokenStore = BeanDefinitionBuilder.rootBeanDefinition(InMemoryTokenStore.class).getBeanDefinition();
tokenServices.addPropertyValue("tokenStore", tokenStore);
parserContext.getRegistry().registerBeanDefinition(tokenServicesRef, tokenServices.getBeanDefinition());
}
return parseEndpointAndReturnFilter(element, parserContext, tokenServicesRef, serializerRef);
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project grails-core by grails.
the class GenericBeanFactoryAccessor method findAnnotationOnBean.
/**
* Find a {@link Annotation} of <code>annotationType</code> on the specified
* bean, traversing its interfaces and super classes if no annotation can be
* found on the given class itself, as well as checking its raw bean class
* if not found on the exposed bean reference (e.g. in case of a proxy).
* @param beanName the name of the bean to look for annotations on
* @param annotationType the annotation class to look for
* @return the annotation of the given type found, or <code>null</code>
* @see org.springframework.core.annotation.AnnotationUtils#findAnnotation(Class, Class)
*/
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType) {
Class<?> handlerType = beanFactory.getType(beanName);
A ann = AnnotationUtils.findAnnotation(handlerType, annotationType);
if (ann == null && beanFactory instanceof ConfigurableBeanFactory && beanFactory.containsBeanDefinition(beanName)) {
ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
BeanDefinition bd = cbf.getMergedBeanDefinition(beanName);
if (bd instanceof AbstractBeanDefinition) {
AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
if (abd.hasBeanClass()) {
Class<?> beanClass = abd.getBeanClass();
ann = AnnotationUtils.findAnnotation(beanClass, annotationType);
}
}
}
return ann;
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project ignite by apache.
the class GridFactorySelfTest method getTestApplicationContext.
/**
* Gets test Spring application context with single {@link StringBuilder} bean
* with name "myBean" and value "Test string".
*
* @return Spring application context.
*/
private ApplicationContext getTestApplicationContext() {
AbstractBeanDefinition def = new GenericBeanDefinition();
def.setBeanClass(StringBuilder.class);
ConstructorArgumentValues args = new ConstructorArgumentValues();
args.addGenericArgumentValue("Test string");
def.setConstructorArgumentValues(args);
GenericApplicationContext ctx = new GenericApplicationContext();
ctx.registerBeanDefinition("myBean", def);
return ctx;
}
use of org.springframework.beans.factory.support.AbstractBeanDefinition in project elastic-job by dangdangdotcom.
the class AbstractJobBeanDefinitionParser method parseInternal.
@Override
protected AbstractBeanDefinition parseInternal(final Element element, final ParserContext parserContext) {
BeanDefinitionBuilder factory = BeanDefinitionBuilder.rootBeanDefinition(SpringJobScheduler.class);
factory.setInitMethodName("init");
factory.setDestroyMethodName("shutdown");
if ("".equals(element.getAttribute(CLASS_ATTRIBUTE))) {
factory.addConstructorArgValue(null);
} else {
factory.addConstructorArgValue(BeanDefinitionBuilder.rootBeanDefinition(element.getAttribute(CLASS_ATTRIBUTE)).getBeanDefinition());
}
factory.addConstructorArgReference(element.getAttribute(REGISTRY_CENTER_REF_ATTRIBUTE));
factory.addConstructorArgValue(createLiteJobConfiguration(element));
BeanDefinition jobEventConfig = createJobEventConfig(element);
if (null != jobEventConfig) {
factory.addConstructorArgValue(jobEventConfig);
}
factory.addConstructorArgValue(createJobListeners(element));
return factory.getBeanDefinition();
}
Aggregations