use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project spring-data-mongodb by spring-projects.
the class MappingMongoConverterParserIntegrationTests method assertStrategyReferenceSetFor.
private static void assertStrategyReferenceSetFor(String beanId) {
BeanDefinitionRegistry factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(new ClassPathResource("namespace/converter-custom-fieldnamingstrategy.xml"));
BeanDefinition definition = reader.getRegistry().getBeanDefinition(beanId.concat(".mongoMappingContext"));
BeanReference value = (BeanReference) definition.getPropertyValues().getPropertyValue("fieldNamingStrategy").getValue();
assertThat(value.getBeanName(), is("customFieldNamingStrategy"));
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project cxf by apache.
the class ConfigurerImpl method initWildcardDefinitionMap.
private void initWildcardDefinitionMap() {
if (null != appContexts) {
for (ApplicationContext appContext : appContexts) {
for (String n : appContext.getBeanDefinitionNames()) {
if (isWildcardBeanName(n)) {
AutowireCapableBeanFactory bf = appContext.getAutowireCapableBeanFactory();
BeanDefinitionRegistry bdr = (BeanDefinitionRegistry) bf;
BeanDefinition bd = bdr.getBeanDefinition(n);
String className = bd.getBeanClassName();
if (null != className) {
String orig = n;
if (n.charAt(0) == '*') {
// old wildcard
n = "." + n.replaceAll("\\.", "\\.");
}
try {
Matcher matcher = Pattern.compile(n).matcher("");
List<MatcherHolder> m = wildCardBeanDefinitions.get(className);
if (m == null) {
m = new ArrayList<>();
wildCardBeanDefinitions.put(className, m);
}
MatcherHolder holder = new MatcherHolder(orig, matcher);
m.add(holder);
} catch (PatternSyntaxException npe) {
// not a valid patter, we'll ignore
}
} else {
LogUtils.log(LOG, Level.WARNING, "WILDCARD_BEAN_ID_WITH_NO_CLASS_MSG", n);
}
}
}
}
}
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project cuba by cuba-platform.
the class RemoteServicesBeanCreator method postProcessBeanFactory.
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
log.info("Configuring remote services");
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
ApplicationContext coreContext = context.getParent();
Map<String, Object> services = coreContext.getBeansWithAnnotation(Service.class);
for (Map.Entry<String, Object> entry : services.entrySet()) {
String serviceName = entry.getKey();
Object service = entry.getValue();
List<Class> serviceInterfaces = new ArrayList<>();
List<Class> interfaces = ClassUtils.getAllInterfaces(service.getClass());
for (Class intf : interfaces) {
if (intf.getName().endsWith("Service"))
serviceInterfaces.add(intf);
}
String intfName = null;
if (serviceInterfaces.size() == 0) {
log.error("Bean " + serviceName + " has @Service annotation but no interfaces named '*Service'. Ignoring it.");
} else if (serviceInterfaces.size() > 1) {
intfName = findLowestSubclassName(serviceInterfaces);
if (intfName == null)
log.error("Bean " + serviceName + " has @Service annotation and more than one interface named '*Service', " + "but these interfaces are not from the same hierarchy. Ignoring it.");
} else {
intfName = serviceInterfaces.get(0).getName();
}
if (intfName != null) {
BeanDefinition definition = new RootBeanDefinition(HttpServiceExporter.class);
MutablePropertyValues propertyValues = definition.getPropertyValues();
propertyValues.add("service", service);
propertyValues.add("serviceInterface", intfName);
registry.registerBeanDefinition("/" + serviceName, definition);
log.debug("Bean " + serviceName + " configured for export via HTTP");
}
}
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project cuba by cuba-platform.
the class WebRemoteProxyBeanCreator method postProcessBeanFactory.
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
String useLocal = AppContext.getProperty("cuba.useLocalServiceInvocation");
if (Boolean.valueOf(useLocal)) {
log.info("Configuring proxy beans for local service invocations: " + services.keySet());
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
for (Map.Entry<String, String> entry : services.entrySet()) {
String name = entry.getKey();
String serviceInterface = entry.getValue();
BeanDefinition definition = new RootBeanDefinition(LocalServiceProxy.class);
MutablePropertyValues propertyValues = definition.getPropertyValues();
propertyValues.add("serviceName", name);
propertyValues.add("serviceInterface", serviceInterface);
registry.registerBeanDefinition(name, definition);
log.debug("Configured proxy bean " + name + " of type " + serviceInterface);
}
processSubstitutions(beanFactory);
} else {
super.postProcessBeanFactory(beanFactory);
}
}
use of org.springframework.beans.factory.support.BeanDefinitionRegistry in project loc-framework by lord-of-code.
the class LocElasticJobAutoConfiguration method createSpringJobScheduler.
private void createSpringJobScheduler(String name, List<Object> argList) {
ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) applicationContext;
BeanDefinitionRegistry beanDefinitionRegistry = (BeanDefinitionRegistry) configurableApplicationContext.getBeanFactory();
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(SpringJobScheduler.class);
builder.setInitMethodName("init");
for (Object arg : argList) {
builder.addConstructorArgValue(arg);
}
beanDefinitionRegistry.registerBeanDefinition(name, builder.getBeanDefinition());
log.info("spring bean name {} register success ", name);
}
Aggregations