org.springframework.beans.factory.config.ConfigurableListableBeanFactory Java Examples
The following examples show how to use
org.springframework.beans.factory.config.ConfigurableListableBeanFactory.
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: ConfigClientTestConfiguration.java From rabbitmq-mock with Apache License 2.0 | 6 votes |
@Override public void initialize(ConfigurableApplicationContext configurableApplicationContext) { RestTemplate configServerClient = new RestTemplate(); MockRestServiceServer mockConfigServer = MockRestServiceServer.bindTo(configServerClient).build(); configServerClient.getInterceptors().add(0, new LoggingHttpInterceptor()); // {@code putIfAbsent} here is important as we do not want to override values when context is refreshed ConfigServerValues configServerValues = new ConfigServerValues(mockConfigServer) .putIfAbsent(ConfigClient.USER_ROLE_KEY, "admin"); ConfigurableListableBeanFactory beanFactory = configurableApplicationContext.getBeanFactory(); try { beanFactory .getBean(ConfigServicePropertySourceLocator.class) .setRestTemplate(configServerClient); beanFactory.registerSingleton("configServerClient", configServerClient); beanFactory.registerSingleton("mockConfigServer", mockConfigServer); beanFactory.registerSingleton("configServerValues", configServerValues); } catch (NoSuchBeanDefinitionException e) { // too soon, ConfigServicePropertySourceLocator is not defined } }
Example #2
Source File: SpeedUpSpringProcessor.java From es with Apache License 2.0 | 6 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if(!(beanFactory instanceof DefaultListableBeanFactory)) { log.error("if speed up spring, bean factory must be type of DefaultListableBeanFactory"); return; } DefaultListableBeanFactory listableBeanFactory = (DefaultListableBeanFactory) beanFactory; for(String beanName : listableBeanFactory.getBeanDefinitionNames()) { BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName); //如果匹配模式 就移除掉 if(needRemove(beanName, beanDefinition)) { listableBeanFactory.removeBeanDefinition(beanName); continue; } //否则设置为lazy if(needLazyInit(beanName)) { beanDefinition.setLazyInit(true); } } }
Example #3
Source File: CreateTablePostProcessor.java From zxl with Apache License 2.0 | 6 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { Set<Class<?>> classes = ReflectUtil.findAllClasses(applicationContext.getClassLoader(), hbaseDomainPackages); for (Class<?> clazz : classes) { if (!HBaseUtil.isTable(clazz)) { continue; } List<String> columnFamiliesList = new ArrayList<String>(); for (Field field : ReflectUtil.getAllFields(clazz)) { if (HBaseUtil.isFamily(field)) { columnFamiliesList.add(field.getName()); } } Object timeToLiveBean = applicationContext.getBean("timeToLive"); Integer timeToLive = TIME_TO_LIVE; if (timeToLiveBean != null) { timeToLive = Integer.valueOf(timeToLiveBean.toString()); } HBaseFactory.createTable(clazz.getSimpleName(), ArrayUtil.listToArray(columnFamiliesList), timeToLive); } }
Example #4
Source File: DefaultListableBeanFactory.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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 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, DependencyDescriptor descriptor, AutowireCandidateResolver resolver) throws NoSuchBeanDefinitionException { String beanDefinitionName = BeanFactoryUtils.transformedBeanName(beanName); if (containsBeanDefinition(beanDefinitionName)) { return isAutowireCandidate(beanName, getMergedLocalBeanDefinition(beanDefinitionName), descriptor, resolver); } else if (containsSingleton(beanName)) { return isAutowireCandidate(beanName, new RootBeanDefinition(getType(beanName)), descriptor, resolver); } BeanFactory parent = getParentBeanFactory(); if (parent instanceof DefaultListableBeanFactory) { // No bean definition found in this factory -> delegate to parent. return ((DefaultListableBeanFactory) parent).isAutowireCandidate(beanName, descriptor, resolver); } else if (parent instanceof ConfigurableListableBeanFactory) { // If no DefaultListableBeanFactory, can't pass the resolver along. return ((ConfigurableListableBeanFactory) parent).isAutowireCandidate(beanName, descriptor); } else { return true; } }
Example #5
Source File: AnnotationBean.java From dubbo3 with Apache License 2.0 | 6 votes |
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (annotationPackage == null || annotationPackage.length() == 0) { return; } if (beanFactory instanceof BeanDefinitionRegistry) { try { // init scanner Class<?> scannerClass = ReflectUtils.forName("org.springframework.context.annotation.ClassPathBeanDefinitionScanner"); Object scanner = scannerClass.getConstructor(new Class<?>[] {BeanDefinitionRegistry.class, boolean.class}).newInstance(beanFactory, true); // add filter Class<?> filterClass = ReflectUtils.forName("org.springframework.core.type.filter.AnnotationTypeFilter"); Object filter = filterClass.getConstructor(Class.class).newInstance(DubboService.class); Method addIncludeFilter = scannerClass.getMethod("addIncludeFilter", ReflectUtils.forName("org.springframework.core.type.filter.TypeFilter")); addIncludeFilter.invoke(scanner, filter); // scan packages String[] packages = Constants.COMMA_SPLIT_PATTERN.split(annotationPackage); Method scan = scannerClass.getMethod("scan", String[].class); scan.invoke(scanner, new Object[] {packages}); } catch (Throwable e) { // spring 2.0 } } }
Example #6
Source File: DefaultListableBeanFactory.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
@Override public boolean isAutowireCandidate(String beanName, DependencyDescriptor descriptor) throws NoSuchBeanDefinitionException { // Consider FactoryBeans as autowiring candidates. boolean isFactoryBean = (descriptor != null && descriptor.getDependencyType() != null && FactoryBean.class.isAssignableFrom(descriptor.getDependencyType())); if (isFactoryBean) { beanName = BeanFactoryUtils.transformedBeanName(beanName); } if (containsBeanDefinition(beanName)) { return isAutowireCandidate(beanName, getMergedLocalBeanDefinition(beanName), descriptor); } else if (containsSingleton(beanName)) { return isAutowireCandidate(beanName, new RootBeanDefinition(getType(beanName)), descriptor); } else if (getParentBeanFactory() instanceof ConfigurableListableBeanFactory) { // No bean definition found in this factory -> delegate to parent. return ((ConfigurableListableBeanFactory) getParentBeanFactory()).isAutowireCandidate(beanName, descriptor); } else { return true; } }
Example #7
Source File: WebApplicationContextUtils.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Register web-specific scopes ("request", "session", "globalSession", "application") * with the given BeanFactory, as used by the WebApplicationContext. * @param beanFactory the BeanFactory to configure * @param sc the ServletContext that we're running within */ public static void registerWebApplicationScopes(ConfigurableListableBeanFactory beanFactory, ServletContext sc) { beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope()); beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false)); beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true)); if (sc != null) { ServletContextScope appScope = new ServletContextScope(sc); beanFactory.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope); // Register as ServletContext attribute, for ContextCleanupListener to detect it. sc.setAttribute(ServletContextScope.class.getName(), appScope); } beanFactory.registerResolvableDependency(ServletRequest.class, new RequestObjectFactory()); beanFactory.registerResolvableDependency(ServletResponse.class, new ResponseObjectFactory()); beanFactory.registerResolvableDependency(HttpSession.class, new SessionObjectFactory()); beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory()); if (jsfPresent) { FacesDependencyRegistrar.registerFacesDependencies(beanFactory); } }
Example #8
Source File: ConfigurationClassPostProcessor.java From java-technology-stack with MIT License | 6 votes |
/** * Prepare the Configuration classes for servicing bean requests at runtime * by replacing them with CGLIB-enhanced subclasses. */ @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { int factoryId = System.identityHashCode(beanFactory); if (this.factoriesPostProcessed.contains(factoryId)) { throw new IllegalStateException( "postProcessBeanFactory already called on this post-processor against " + beanFactory); } this.factoriesPostProcessed.add(factoryId); if (!this.registriesPostProcessed.contains(factoryId)) { // BeanDefinitionRegistryPostProcessor hook apparently not supported... // Simply call processConfigurationClasses lazily at this point then. processConfigBeanDefinitions((BeanDefinitionRegistry) beanFactory); } enhanceConfigurationClasses(beanFactory); beanFactory.addBeanPostProcessor(new ImportAwareBeanPostProcessor(beanFactory)); }
Example #9
Source File: LocDataSourceAutoConfiguration.java From loc-framework with MIT License | 6 votes |
private void createBean(ConfigurableListableBeanFactory configurableListableBeanFactory, String prefixName, JdbcProperties jdbcProperties) { String jdbcUrl = jdbcProperties.getJdbcUrl(); checkArgument(!Strings.isNullOrEmpty(jdbcUrl), prefixName + " url is null or empty"); log.info("prefixName is {}, jdbc properties is {}", prefixName, jdbcProperties); HikariDataSource hikariDataSource = createHikariDataSource(jdbcProperties); DataSourceSpy dataSource = new DataSourceSpy(hikariDataSource); DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource); AnnotationTransactionAspect.aspectOf().setTransactionManager(transactionManager); JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); register(configurableListableBeanFactory, dataSource, prefixName + "DataSource", prefixName + "Ds"); register(configurableListableBeanFactory, jdbcTemplate, prefixName + "JdbcTemplate", prefixName + "Jt"); register(configurableListableBeanFactory, transactionManager, prefixName + "TransactionManager", prefixName + "Tx"); }
Example #10
Source File: DubboAutoConfiguration.java From spring-boot-starter-dubbo with Apache License 2.0 | 6 votes |
private void registerConsumer(ConsumerConfig consumer, ConfigurableListableBeanFactory beanFactory) { if (consumer != null) { String beanName = consumer.getId(); if (StringUtils.isEmpty(beanName)) { beanName = "consumerConfig"; } String filter = consumer.getFilter(); if (StringUtils.isEmpty(filter)) { filter = "regerConsumerFilter"; } else { filter = filter.trim() + ",regerConsumerFilter"; } logger.debug("添加consumerFilter后的Filter, {}", filter); consumer.setFilter(filter); beanFactory.registerSingleton(beanName, consumer); } else { logger.debug("dubbo 没有配置默认的消费者参数"); } }
Example #11
Source File: WebApplicationContextUtils.java From spring4-understanding with Apache License 2.0 | 6 votes |
public static void registerFacesDependencies(ConfigurableListableBeanFactory beanFactory) { beanFactory.registerResolvableDependency(FacesContext.class, new ObjectFactory<FacesContext>() { @Override public FacesContext getObject() { return FacesContext.getCurrentInstance(); } @Override public String toString() { return "Current JSF FacesContext"; } }); beanFactory.registerResolvableDependency(ExternalContext.class, new ObjectFactory<ExternalContext>() { @Override public ExternalContext getObject() { return FacesContext.getCurrentInstance().getExternalContext(); } @Override public String toString() { return "Current JSF ExternalContext"; } }); }
Example #12
Source File: SingletonTests.java From spring-cloud-function with Apache License 2.0 | 6 votes |
@Bean public static BeanDefinitionRegistryPostProcessor processor() { return new BeanDefinitionRegistryPostProcessor() { @Override public void postProcessBeanFactory( ConfigurableListableBeanFactory beanFactory) throws BeansException { } @Override public void postProcessBeanDefinitionRegistry( BeanDefinitionRegistry registry) throws BeansException { // Simulates what happens when you add a compiled function RootBeanDefinition beanDefinition = new RootBeanDefinition( MySupplier.class); registry.registerBeanDefinition("words", beanDefinition); } }; }
Example #13
Source File: AbstractCloudServiceConnectorFactory.java From spring-cloud-connectors with Apache License 2.0 | 6 votes |
@Override public void afterPropertiesSet() throws Exception { ConfigurableListableBeanFactory beanFactory = (ConfigurableListableBeanFactory) getBeanFactory(); if (cloud == null) { if (beanFactory.getBeansOfType(CloudFactory.class).isEmpty()) { beanFactory.registerSingleton(CLOUD_FACTORY_BEAN_NAME, new CloudFactory()); } CloudFactory cloudFactory = beanFactory.getBeansOfType(CloudFactory.class).values().iterator().next(); cloud = cloudFactory.getCloud(); } if (!StringUtils.hasText(serviceId)) { List<? extends ServiceInfo> infos = cloud.getServiceInfos(serviceConnectorType); if (infos.size() != 1) { throw new CloudException("Expected 1 service matching " + serviceConnectorType.getName() + " type, but found " + infos.size()); } serviceId = infos.get(0).getId(); } super.afterPropertiesSet(); }
Example #14
Source File: BeanFactoryAnnotationUtils.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Obtain a bean of type {@code T} from the given {@code BeanFactory} declaring a * qualifier (e.g. via {@code <qualifier>} or {@code @Qualifier}) matching the given * qualifier, or having a bean name matching the given qualifier. * @param beanFactory the BeanFactory to get the target bean from * @param beanType the type of bean to retrieve * @param qualifier the qualifier for selecting between multiple bean matches * @return the matching bean of type {@code T} (never {@code null}) * @throws NoUniqueBeanDefinitionException if multiple matching beans of type {@code T} found * @throws NoSuchBeanDefinitionException if no matching bean of type {@code T} found * @throws BeansException if the bean could not be created * @see BeanFactory#getBean(Class) */ public static <T> T qualifiedBeanOfType(BeanFactory beanFactory, Class<T> beanType, String qualifier) throws BeansException { Assert.notNull(beanFactory, "BeanFactory must not be null"); if (beanFactory instanceof ConfigurableListableBeanFactory) { // Full qualifier matching supported. return qualifiedBeanOfType((ConfigurableListableBeanFactory) beanFactory, beanType, qualifier); } else if (beanFactory.containsBean(qualifier)) { // Fallback: target bean at least found by bean name. return beanFactory.getBean(qualifier, beanType); } else { throw new NoSuchBeanDefinitionException(qualifier, "No matching " + beanType.getSimpleName() + " bean found for bean name '" + qualifier + "'! (Note: Qualifier matching not supported because given " + "BeanFactory does not implement ConfigurableListableBeanFactory.)"); } }
Example #15
Source File: AbstractAdvisorAutoProxyCreator.java From java-technology-stack with MIT License | 5 votes |
@Override public void setBeanFactory(BeanFactory beanFactory) { super.setBeanFactory(beanFactory); if (!(beanFactory instanceof ConfigurableListableBeanFactory)) { throw new IllegalArgumentException( "AdvisorAutoProxyCreator requires a ConfigurableListableBeanFactory: " + beanFactory); } initBeanFactory((ConfigurableListableBeanFactory) beanFactory); }
Example #16
Source File: DefaultRiptideConfigurerTest.java From riptide with MIT License | 5 votes |
@Test void shouldBeanDefinitionIfSingleBeanRegisteredForType() { final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(SingleTracerConfiguration.class); context.refresh(); final ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); final DefaultRiptideConfigurer configurer = new DefaultRiptideConfigurer(beanFactory, null); final BeanReference bd = configurer.getBeanRef(Tracer.class, "tracer"); assertThat(bd.getBeanName()).isEqualTo("opentracingTracer"); }
Example #17
Source File: AbstractRefreshableApplicationContext.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public final ConfigurableListableBeanFactory getBeanFactory() { synchronized (this.beanFactoryMonitor) { if (this.beanFactory == null) { throw new IllegalStateException("BeanFactory not initialized or already closed - " + "call 'refresh' before accessing beans via the ApplicationContext"); } return this.beanFactory; } }
Example #18
Source File: PostProcessorRegistrationDelegate.java From lams with GNU General Public License v2.0 | 5 votes |
private static void sortPostProcessors(List<?> postProcessors, ConfigurableListableBeanFactory beanFactory) { Comparator<Object> comparatorToUse = null; if (beanFactory instanceof DefaultListableBeanFactory) { comparatorToUse = ((DefaultListableBeanFactory) beanFactory).getDependencyComparator(); } if (comparatorToUse == null) { comparatorToUse = OrderComparator.INSTANCE; } Collections.sort(postProcessors, comparatorToUse); }
Example #19
Source File: MockReplacer.java From jdal with Apache License 2.0 | 5 votes |
/** * implements {@link BeanFactoryPostProcessor#postProcessBeanFactory(ConfigurableListableBeanFactory)} * @param factory the BeanFactory to postprocess * @throws BeansException if fail */ public void postProcessBeanFactory(ConfigurableListableBeanFactory factory) throws BeansException { for (String name : replacedBeans.keySet()) { Object bean = replacedBeans.get(name); log.debug("Replacing Bean " + name + " with instance of class " + bean.getClass()); factory.registerSingleton(name, bean); } }
Example #20
Source File: SHA256SAMLBootstrap.java From sakai with Educational Community License v2.0 | 5 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { super.postProcessBeanFactory(beanFactory); BasicSecurityConfiguration config = (BasicSecurityConfiguration) Configuration.getGlobalSecurityConfiguration(); config.registerSignatureAlgorithmURI("RSA", SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); config.setSignatureReferenceDigestMethod(SignatureConstants.ALGO_ID_DIGEST_SHA256); }
Example #21
Source File: AbstractAutoProxyCreator.java From java-technology-stack with MIT License | 5 votes |
/** * Create an AOP proxy for the given bean. * @param beanClass the class of the bean * @param beanName the name of the bean * @param specificInterceptors the set of interceptors that is * specific to this bean (may be empty, but not null) * @param targetSource the TargetSource for the proxy, * already pre-configured to access the bean * @return the AOP proxy for the bean * @see #buildAdvisors */ protected Object createProxy(Class<?> beanClass, @Nullable String beanName, @Nullable Object[] specificInterceptors, TargetSource targetSource) { if (this.beanFactory instanceof ConfigurableListableBeanFactory) { AutoProxyUtils.exposeTargetClass((ConfigurableListableBeanFactory) this.beanFactory, beanName, beanClass); } ProxyFactory proxyFactory = new ProxyFactory(); proxyFactory.copyFrom(this); if (!proxyFactory.isProxyTargetClass()) { if (shouldProxyTargetClass(beanClass, beanName)) { proxyFactory.setProxyTargetClass(true); } else { evaluateProxyInterfaces(beanClass, proxyFactory); } } Advisor[] advisors = buildAdvisors(beanName, specificInterceptors); proxyFactory.addAdvisors(advisors); proxyFactory.setTargetSource(targetSource); customizeProxyFactory(proxyFactory); proxyFactory.setFrozen(this.freezeProxy); if (advisorsPreFiltered()) { proxyFactory.setPreFiltered(true); } return proxyFactory.getProxy(getProxyClassLoader()); }
Example #22
Source File: CompositeUtils.java From spring-cloud-config with Apache License 2.0 | 5 votes |
/** * Given a type of EnvironmentRepository (git, svn, native, etc...) returns the name * of the factory bean. See {@link #getCompositeTypeList(Environment)} * @param type type of a repository * @param beanFactory Spring Bean Factory * @return name of the factory bean */ public static String getFactoryName(String type, ConfigurableListableBeanFactory beanFactory) { String[] factoryNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors( beanFactory, EnvironmentRepositoryFactory.class, true, false); return Arrays.stream(factoryNames).filter(n -> n.startsWith(type)).findFirst() .orElse(null); }
Example #23
Source File: AutoJsonRpcServiceImplExporter.java From jsonrpc4j with MIT License | 5 votes |
@SuppressWarnings("Convert2streamapi") private static void collectFromParentBeans(ConfigurableListableBeanFactory beanFactory, Map<String, String> serviceBeanNames) { BeanFactory parentBeanFactory = beanFactory.getParentBeanFactory(); if (parentBeanFactory != null && ConfigurableListableBeanFactory.class.isInstance(parentBeanFactory)) { for (Entry<String, String> entry : findServiceBeanDefinitions((ConfigurableListableBeanFactory) parentBeanFactory).entrySet()) { if (isNotDuplicateService(serviceBeanNames, entry.getKey(), entry.getValue())) { serviceBeanNames.put(entry.getKey(), entry.getValue()); } } } }
Example #24
Source File: TurboClientStarter.java From turbo-rpc with Apache License 2.0 | 5 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; try { ClientConfig clientConfig = ClientConfig.parse("turbo-client.conf"); turboClient = new TurboClient(clientConfig); } catch (com.typesafe.config.ConfigException configException) { if (logger.isErrorEnabled()) { logger.error("turbo-client.conf 格式错误,无法开启TurboClient!", configException); } throw configException; } catch (Exception e) { if (logger.isErrorEnabled()) { logger.error("类路径中找不到 turbo-client.conf,无法开启TurboClient!", e); } throw e; } Collection<Class<?>> turboClassList = extractTurboServiceClassList(beanFactory); for (Class<?> turboClass : turboClassList) { registerTurboService(turboClass); } }
Example #25
Source File: OnSearchPathLocatorPresent.java From spring-cloud-config with Apache License 2.0 | 5 votes |
@Override public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); List<String> types = CompositeUtils .getCompositeTypeList(context.getEnvironment()); // get EnvironmentRepository types from registered factories List<Class<? extends EnvironmentRepository>> repositoryTypes = new ArrayList<>(); for (String type : types) { String factoryName = CompositeUtils.getFactoryName(type, beanFactory); Type[] actualTypeArguments = CompositeUtils .getEnvironmentRepositoryFactoryTypeParams(beanFactory, factoryName); Class<? extends EnvironmentRepository> repositoryType; repositoryType = (Class<? extends EnvironmentRepository>) actualTypeArguments[0]; repositoryTypes.add(repositoryType); } boolean required = metadata .isAnnotated(ConditionalOnSearchPathLocator.class.getName()); boolean foundSearchPathLocator = repositoryTypes.stream() .anyMatch(SearchPathLocator.class::isAssignableFrom); if (required && !foundSearchPathLocator) { return ConditionOutcome.noMatch( ConditionMessage.forCondition(ConditionalOnSearchPathLocator.class) .notAvailable(SearchPathLocator.class.getTypeName())); } if (!required && foundSearchPathLocator) { return ConditionOutcome.noMatch(ConditionMessage .forCondition(ConditionalOnMissingSearchPathLocator.class) .available(SearchPathLocator.class.getTypeName())); } return ConditionOutcome.match(); }
Example #26
Source File: MyBeanFactoryPostProcessor.java From spring-tutorial with Creative Commons Attribution Share Alike 4.0 International | 5 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { System.out.println("[BeanFactoryPostProcessor] BeanFactoryPostProcessor call postProcessBeanFactory"); String[] beanNamesForType = beanFactory.getBeanNamesForType(Person.class); for (String name : beanNamesForType) { BeanDefinition bd = beanFactory.getBeanDefinition(name); bd.getPropertyValues().addPropertyValue("phone", "110"); } }
Example #27
Source File: OverridablePropertyPlaceholderConfigurer.java From attic-rave with Apache License 2.0 | 5 votes |
@Override protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException { super.processProperties(beanFactoryToProcess, props); // load the application properties into a map that is exposed via public getter resolvedProps = new HashMap<String, String>(); for (Object key : props.keySet()) { String keyStr = key.toString(); resolvedProps.put(keyStr, resolvePlaceholder(keyStr, props, SYSTEM_PROPERTIES_MODE_OVERRIDE)); } }
Example #28
Source File: MangoDaoScanner.java From mango with Apache License 2.0 | 5 votes |
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { DefaultListableBeanFactory dlbf = (DefaultListableBeanFactory) beanFactory; for (Class<?> daoClass : findMangoDaoClasses()) { GenericBeanDefinition bf = new GenericBeanDefinition(); bf.setBeanClassName(daoClass.getName()); MutablePropertyValues pvs = bf.getPropertyValues(); pvs.addPropertyValue("daoClass", daoClass); bf.setBeanClass(factoryBeanClass); bf.setPropertyValues(pvs); bf.setLazyInit(false); dlbf.registerBeanDefinition(daoClass.getName(), bf); } }
Example #29
Source File: DictionaryBeanFactoryPostProcessor.java From rice with Educational Community License v2.0 | 5 votes |
/** * Constructs a new processor for the given data dictionary and bean factory * * @param dataDictionary data dictionary instance that contains the bean factory * @param beanFactory bean factory to process */ public DictionaryBeanFactoryPostProcessor(DataDictionary dataDictionary, ConfigurableListableBeanFactory beanFactory) { this.dataDictionary = dataDictionary; this.beanFactory = beanFactory; this.beanProcessors = new ArrayList<DictionaryBeanProcessor>(); this.beanProcessors.add(new MessageBeanProcessor(dataDictionary, beanFactory)); }
Example #30
Source File: ModuleContextCustomizerFactory.java From moduliths with Apache License 2.0 | 5 votes |
@Override public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) { ModuleTestExecution testExecution = execution.get(); logModules(testExecution); ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); beanFactory.registerSingleton(BEAN_NAME, testExecution); DefaultPublishedEvents events = new DefaultPublishedEvents(); beanFactory.registerSingleton(events.getClass().getName(), events); context.addApplicationListener(events); }