Java Code Examples for org.springframework.beans.factory.support.GenericBeanDefinition#setDependsOn()
The following examples show how to use
org.springframework.beans.factory.support.GenericBeanDefinition#setDependsOn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodelessScannerRegistrar.java From sca-best-practice with Apache License 2.0 | 6 votes |
private void registerController(Map<String, CodelessEntityMetadata> codelessEntityMetadataMap, BeanDefinitionRegistry registry) { GenericBeanDefinition handlerMappingBd = new GenericBeanDefinition(); handlerMappingBd.setBeanClass(CodelessAutoGenerateHandlerMapping.class); handlerMappingBd.getPropertyValues().addPropertyValue("codelessEntityMetadataMap", codelessEntityMetadataMap); registry.registerBeanDefinition("codelessAutoGenerateHandlerMapping", handlerMappingBd); GenericBeanDefinition controllerProxyBd = new GenericBeanDefinition(); controllerProxyBd.setBeanClass(CodelessControllerProxy.class); controllerProxyBd.getPropertyValues().addPropertyValue("codelessEntityMetadataMap", codelessEntityMetadataMap); registry.registerBeanDefinition("codelessControllerProxy", controllerProxyBd); GenericBeanDefinition serviceProxyBd = new GenericBeanDefinition(); serviceProxyBd.setBeanClass(CodelessServiceProxy.class); serviceProxyBd.setDependsOn("codelessDao"); registry.registerBeanDefinition("codelessServiceProxy", serviceProxyBd); GenericBeanDefinition daoProxyBd = new GenericBeanDefinition(); daoProxyBd.setBeanClass(CodelessDaoProxy.class); registry.registerBeanDefinition("codelessDaoProxy", daoProxyBd); GenericBeanDefinition daoFactoryBd = new GenericBeanDefinition(); daoFactoryBd.setBeanClass(CodelessDaoFactoryBean.class); registry.registerBeanDefinition("codelessDao", daoFactoryBd); }
Example 2
Source File: EmbeddedCassandraContextCustomizer.java From embedded-cassandra with Apache License 2.0 | 5 votes |
private static void registerCassandraConnectionBeanDefinition(ConfigurableApplicationContext context, BeanDefinitionRegistry registry) { GenericBeanDefinition bd = new GenericBeanDefinition(); bd.setBeanClass(CassandraConnection.class); bd.setDestroyMethodName("close"); bd.setLazyInit(true); bd.setDependsOn(Cassandra.class.getName()); bd.setScope(BeanDefinition.SCOPE_SINGLETON); bd.setInstanceSupplier(new CassandraConnectionSupplier(context)); registry.registerBeanDefinition(CassandraConnection.class.getName(), bd); }
Example 3
Source File: SpringBootAnnotationResolver.java From brpc-java with Apache License 2.0 | 4 votes |
/** * Creates the rpc proxy factory bean. * * @return the rpc proxy factory bean */ private RpcProxyFactoryBean createRpcProxyFactoryBean(RpcProxy rpcProxy, DefaultListableBeanFactory beanFactory, Class serviceInterface) { GenericBeanDefinition beanDef = new GenericBeanDefinition(); beanDef.setBeanClass(RpcProxyFactoryBean.class); beanDef.setDependsOn("brpcApplicationContextUtils"); MutablePropertyValues values = new MutablePropertyValues(); BrpcConfig brpcConfig = getServiceConfig(beanFactory, serviceInterface); for (Field field : RpcClientOptions.class.getDeclaredFields()) { try { if (field.getType().equals(Logger.class)) { // ignore properties of org.slf4j.Logger class continue; } field.setAccessible(true); values.addPropertyValue(field.getName(), field.get(brpcConfig.getClient())); } catch (Exception ex) { log.warn("field not exist:", ex); } } values.addPropertyValue("serviceInterface", serviceInterface); values.addPropertyValue("serviceId", rpcProxy.name()); if (brpcConfig.getNaming() != null) { values.addPropertyValue("namingServiceUrl", brpcConfig.getNaming().getNamingServiceUrl()); values.addPropertyValue("group", brpcConfig.getNaming().getGroup()); values.addPropertyValue("version", brpcConfig.getNaming().getVersion()); values.addPropertyValue("ignoreFailOfNamingService", brpcConfig.getNaming().isIgnoreFailOfNamingService()); } // interceptor String interceptorNames = brpcConfig.getClient().getInterceptorBeanNames(); if (!StringUtils.isBlank(interceptorNames)) { List<Interceptor> customInterceptors = new ArrayList<>(); String[] interceptorNameArray = interceptorNames.split(","); for (String interceptorBeanName : interceptorNameArray) { Interceptor interceptor = beanFactory.getBean(interceptorBeanName, Interceptor.class); customInterceptors.add(interceptor); } values.addPropertyValue("interceptors", Arrays.asList(customInterceptors)); } beanDef.setPropertyValues(values); String serviceInterfaceBeanName = serviceInterface.getSimpleName(); beanFactory.registerBeanDefinition(serviceInterfaceBeanName, beanDef); return beanFactory.getBean("&" + serviceInterfaceBeanName, RpcProxyFactoryBean.class); }