use of org.springframework.beans.factory.config.BeanDefinitionHolder in project mule by mulesoft.
the class DefaultListableBeanFactory method isAutowireCandidate.
/**
* Determine whether the specified bean definition qualifies as an autowire candidate, to be injected into other beans which
* declare a dependency of matching type.
*
* @param beanName the name of the bean definition to check
* @param mbd the merged bean definition to check
* @param descriptor the descriptor of the dependency to resolve
* @param resolver the AutowireCandidateResolver to use for the actual resolution algorithm
* @return whether the bean should be considered as autowire candidate
*/
protected boolean isAutowireCandidate(String beanName, RootBeanDefinition mbd, DependencyDescriptor descriptor, AutowireCandidateResolver resolver) {
String beanDefinitionName = BeanFactoryUtils.transformedBeanName(beanName);
resolveBeanClass(mbd, beanDefinitionName);
if (mbd.isFactoryMethodUnique) {
boolean resolve;
synchronized (mbd.constructorArgumentLock) {
resolve = (mbd.resolvedConstructorOrFactoryMethod == null);
}
if (resolve) {
new ConstructorResolver(this).resolveFactoryMethodIfPossible(mbd);
}
}
return resolver.isAutowireCandidate(new BeanDefinitionHolder(mbd, beanName, getAliases(beanDefinitionName)), descriptor);
}
use of org.springframework.beans.factory.config.BeanDefinitionHolder in project camunda-bpm-platform by camunda.
the class StateHandlerAnnotationBeanFactoryPostProcessor method configureDefaultActivitiRegistry.
private void configureDefaultActivitiRegistry(String registryBeanName, BeanDefinitionRegistry registry) {
if (!beanAlreadyConfigured(registry, registryBeanName, ActivitiStateHandlerRegistry.class)) {
String registryName = ActivitiStateHandlerRegistry.class.getName();
log.info("registering a " + registryName + " instance under bean name " + ActivitiContextUtils.ACTIVITI_REGISTRY_BEAN_NAME + ".");
RootBeanDefinition rootBeanDefinition = new RootBeanDefinition();
rootBeanDefinition.setBeanClassName(registryName);
rootBeanDefinition.getPropertyValues().addPropertyValue("processEngine", this.processEngine);
BeanDefinitionHolder holder = new BeanDefinitionHolder(rootBeanDefinition, registryBeanName);
BeanDefinitionReaderUtils.registerBeanDefinition(holder, registry);
}
}
use of org.springframework.beans.factory.config.BeanDefinitionHolder in project service-proxy by membrane.
the class AbstractParser method handleChildElement.
protected void handleChildElement(Element ele, ParserContext parserContext, BeanDefinitionBuilder builder) {
BeanDefinitionParserDelegate delegate = parserContext.getDelegate();
try {
Object o = delegate.parsePropertySubElement(ele, builder.getBeanDefinition());
String clazz = null;
if (o instanceof BeanDefinitionHolder) {
clazz = ((BeanDefinitionHolder) o).getBeanDefinition().getBeanClassName();
} else if (o instanceof RuntimeBeanReference) {
clazz = parserContext.getRegistry().getBeanDefinition(((RuntimeBeanReference) o).getBeanName()).getBeanClassName();
} else if (o instanceof RuntimeBeanNameReference) {
clazz = parserContext.getRegistry().getBeanDefinition(((RuntimeBeanNameReference) o).getBeanName()).getBeanClassName();
} else {
parserContext.getReaderContext().error("Don't know how to get bean class from " + o.getClass(), ele);
}
handleChildObject(ele, parserContext, builder, Class.forName(clazz), o);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
use of org.springframework.beans.factory.config.BeanDefinitionHolder in project sandbox by irof.
the class AhogeScanner method doScan.
@Override
protected Set<BeanDefinitionHolder> doScan(String... basePackages) {
Set<BeanDefinitionHolder> beanDefinitionHolders = super.doScan(basePackages);
for (BeanDefinitionHolder holder : beanDefinitionHolders) {
// インタフェースのままだとBean生成できないので定義を上書きする
// コンストラクタ引数にインタフェース(ex.Fuga)を与えるようにして、
// BeanClassを FactoryBean の AhogeFactory にすげ替える。
// これで Spring が AhogeFactory を使ってインスタンスを作ってくれるようになる。
GenericBeanDefinition definition = (GenericBeanDefinition) holder.getBeanDefinition();
definition.getConstructorArgumentValues().addGenericArgumentValue(definition.getBeanClassName());
definition.setBeanClass(AhogeFactory.class);
}
return beanDefinitionHolders;
}
use of org.springframework.beans.factory.config.BeanDefinitionHolder in project pinpoint by naver.
the class ClassPathDefinitionScannerDoScanInterceptor method after.
@Override
public void after(Object target, Object[] args, Object result, Throwable throwable) {
if (result == null || throwable != null || !(result instanceof Set)) {
return;
}
try {
final Set<Object> set = (Set<Object>) result;
for (Object o : set) {
if (o instanceof BeanDefinitionHolder) {
final BeanDefinitionHolder beanDefinitionHolder = (BeanDefinitionHolder) o;
if (filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, beanDefinitionHolder.getBeanName(), beanDefinitionHolder.getBeanDefinition())) {
final String className = beanDefinitionHolder.getBeanDefinition().getBeanClassName();
this.instrumentor.transform(this.classLoader, className, this.transformer);
this.filter.addTransformed(className);
}
}
}
} catch (Throwable t) {
if (logger.isWarnEnabled()) {
logger.warn("AFTER. Caused:{}", t.getMessage(), t);
}
}
}
Aggregations