use of org.apache.cxf.configuration.spring.BusWiringType in project cxf by apache.
the class BusWiringBeanFactoryPostProcessor method postProcessBeanFactory.
public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) throws BeansException {
Object inject = bus;
if (inject == null) {
inject = getBusForName(Bus.DEFAULT_BUS_ID, factory, true, null);
} else {
if (!factory.containsBeanDefinition(Bus.DEFAULT_BUS_ID) && !factory.containsSingleton(Bus.DEFAULT_BUS_ID)) {
factory.registerSingleton(Bus.DEFAULT_BUS_ID, bus);
}
}
for (String beanName : factory.getBeanDefinitionNames()) {
BeanDefinition beanDefinition = factory.getBeanDefinition(beanName);
BusWiringType type = (BusWiringType) beanDefinition.getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE);
if (type == null) {
continue;
}
String busname = (String) beanDefinition.getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_NAME);
String create = (String) beanDefinition.getAttribute(AbstractBeanDefinitionParser.WIRE_BUS_CREATE);
Object inj = inject;
if (busname != null) {
if (bus != null) {
continue;
}
inj = getBusForName(busname, factory, create != null, create);
}
beanDefinition.removeAttribute(AbstractBeanDefinitionParser.WIRE_BUS_NAME);
beanDefinition.removeAttribute(AbstractBeanDefinitionParser.WIRE_BUS_ATTRIBUTE);
beanDefinition.removeAttribute(AbstractBeanDefinitionParser.WIRE_BUS_CREATE);
if (create == null) {
if (BusWiringType.PROPERTY == type) {
beanDefinition.getPropertyValues().addPropertyValue("bus", inj);
} else if (BusWiringType.CONSTRUCTOR == type) {
ConstructorArgumentValues constructorArgs = beanDefinition.getConstructorArgumentValues();
insertConstructorArg(constructorArgs, inj);
}
}
}
}
Aggregations