当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurableListableBeanFactory类代码示例

本文整理汇总了Java中org.springframework.beans.factory.config.ConfigurableListableBeanFactory的典型用法代码示例。如果您正苦于以下问题:Java ConfigurableListableBeanFactory类的具体用法?Java ConfigurableListableBeanFactory怎么用?Java ConfigurableListableBeanFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConfigurableListableBeanFactory类属于org.springframework.beans.factory.config包,在下文中一共展示了ConfigurableListableBeanFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initApplicationEventMulticaster

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
/**
 * Initialize the ApplicationEventMulticaster.
 * Uses SimpleApplicationEventMulticaster if none defined in the context.
 * @see org.springframework.context.event.SimpleApplicationEventMulticaster
 */
protected void initApplicationEventMulticaster() {
	ConfigurableListableBeanFactory beanFactory = getBeanFactory();
	if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
		this.applicationEventMulticaster =
				beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
		if (logger.isDebugEnabled()) {
			logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
		}
	}
	else {
		this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
		beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
		if (logger.isDebugEnabled()) {
			logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
					APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
					"': using default [" + this.applicationEventMulticaster + "]");
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:AbstractApplicationContext.java

示例2: doInitialize

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
@Override
protected void doInitialize() throws Exception {
    provider.getProviders().forEach(p -> {
        final FlowDefinitionRegistry duoFlowRegistry = buildDuoFlowRegistry(p);
        applicationContext.getAutowireCapableBeanFactory().initializeBean(duoFlowRegistry, p.getId());
        final ConfigurableListableBeanFactory cfg = (ConfigurableListableBeanFactory) applicationContext.getAutowireCapableBeanFactory();
        cfg.registerSingleton(p.getId(), duoFlowRegistry);
        registerMultifactorProviderAuthenticationWebflow(getLoginFlow(), p.getId(), duoFlowRegistry);
    });

    casProperties.getAuthn().getMfa().getDuo()
            .stream()
            .filter(MultifactorAuthenticationProperties.Duo::isTrustedDeviceEnabled)
            .forEach(duo -> {
                final String id = duo.getId();
                try {
                    LOGGER.debug("Activating multifactor trusted authentication for webflow [{}]", id);
                    final FlowDefinitionRegistry registry = applicationContext.getBean(id, FlowDefinitionRegistry.class);
                    registerMultifactorTrustedAuthentication(registry);
                } catch (final Exception e) {
                    LOGGER.error("Failed to register multifactor trusted authentication for " + id, e);
                }
            });
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:DuoMultifactorWebflowConfigurer.java

示例3: setSerializationId

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
/**
 * If the bean factory is a DefaultListableBeanFactory then it can serialize scoped
 * beans and deserialize them in another context (even in another JVM), as long as the
 * ids of the bean factories match. This method sets up the serialization id to be
 * either the id provided to the scope instance, or if that is null, a hash of all the
 * bean names.
 *
 * @param beanFactory the bean factory to configure
 */
private void setSerializationId(ConfigurableListableBeanFactory beanFactory) {

    if (beanFactory instanceof DefaultListableBeanFactory) {

        String id = this.id;
        if (id == null) {
            List<String> list = new ArrayList<>(
                    Arrays.asList(beanFactory.getBeanDefinitionNames()));
            Collections.sort(list);
            String names = list.toString();
            logger.debug("Generating bean factory id from names: " + names);
            id = UUID.nameUUIDFromBytes(names.getBytes()).toString();
        }

        logger.info("BeanFactory id=" + id);
        ((DefaultListableBeanFactory) beanFactory).setSerializationId(id);

    } else {
        logger.warn("BeanFactory was not a DefaultListableBeanFactory, so RefreshScope beans "
                + "cannot be serialized reliably and passed to a remote JVM.");
    }

}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:33,代码来源:GenericScope.java

示例4: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void postProcessBeanFactory(
    ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
    String[] igniteConfigNames = configurableListableBeanFactory.getBeanNamesForType(IgniteConfiguration.class);
    if (igniteConfigNames.length != 1) {
        throw new IllegalArgumentException("Spring config must contain exactly one ignite configuration!");
    }
    String[] activeStoreConfigNames = configurableListableBeanFactory.getBeanNamesForType(BaseActiveStoreConfiguration.class);
    if (activeStoreConfigNames.length != 1) {
        throw new IllegalArgumentException("Spring config must contain exactly one active store configuration!");
    }
    BeanDefinition igniteConfigDef = configurableListableBeanFactory.getBeanDefinition(igniteConfigNames[0]);
    MutablePropertyValues propertyValues = igniteConfigDef.getPropertyValues();
    if (!propertyValues.contains(USER_ATTRS_PROP_NAME)) {
        propertyValues.add(USER_ATTRS_PROP_NAME, new ManagedMap());
    }
    PropertyValue propertyValue = propertyValues.getPropertyValue(USER_ATTRS_PROP_NAME);
    Map userAttrs = (Map)propertyValue.getValue();
    TypedStringValue key = new TypedStringValue(CONFIG_USER_ATTR);
    RuntimeBeanReference value = new RuntimeBeanReference(beanName);
    userAttrs.put(key, value);
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:24,代码来源:BaseActiveStoreConfiguration.java

示例5: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
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(new Object[] {(BeanDefinitionRegistry) beanFactory, true});
            // add filter
            Class<?> filterClass = ReflectUtils.forName("org.springframework.core.type.filter.AnnotationTypeFilter");
            Object filter = filterClass.getConstructor(Class.class).newInstance(Service.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", new Class<?>[]{String[].class});
            scan.invoke(scanner, new Object[] {packages});
        } catch (Throwable e) {
            // spring 2.0
        }
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:25,代码来源:AnnotationBean.java

示例6: createBean

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
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");
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:22,代码来源:LocDataSourceAutoConfiguration.java

示例7: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

    String[] beanNames = beanFactory.getBeanNamesForAnnotation(Job.class);

    for(String name : beanNames){
        JobDetail jobDetail = buildJobForBeanFactory(beanFactory, name);

        if (jobDetail == null){
            logger.warn("could not load JobDetail for {}", name);
            continue;
        }

        try {
            scheduler.addJob(jobDetail, true);
        } catch (SchedulerException e) {
            throw new BeanInitializationException("SchedulerException when adding job to scheduler", e);
        }
    }
}
 
开发者ID:taboola,项目名称:taboola-cronyx,代码行数:21,代码来源:QuartzJobRegistrarBeanFactoryPostProcessor.java

示例8: createRestTemplateBasicAuth

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
/**
 * register specific RestTemplate in Spring Application Context if needed
 */
private Consumer<Application> createRestTemplateBasicAuth(ConfigurableListableBeanFactory registry) {
	return app -> {

		// Create rest template instance
		RestTemplate restTemplateBasicAuth = defaultRestTemplateConfig.restTemplate(requestFactory, Arrays.asList(defaultRestTemplateConfig.getDefaultAcceptHeader(), MediaType.ALL));

		// Configure it with BASIC auth
		restTemplateBasicAuth.getInterceptors().add(new BasicAuthorizationInterceptor(app.getActuatorUsername(), app.getActuatorPassword()));

		LOGGER.info("Registered RestTemplate with BASIC auth for application with id {}", app.getId());

		// Add bean in Spring application context
		registry.registerSingleton(getRestTemplateBeanName(app), restTemplateBasicAuth);
	};
}
 
开发者ID:vianneyfaivre,项目名称:Persephone,代码行数:19,代码来源:RestTemplateFactory.java

示例9: qualifiedBeanOfType

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
/**
 * Obtain a bean of type {@code T} from the given {@code BeanFactory} declaring a qualifier
 * (e.g. {@code <qualifier>} or {@code @Qualifier}) matching the given qualifier).
 * @param bf 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 NoSuchBeanDefinitionException if no matching bean of type {@code T} found
 */
private static <T> T qualifiedBeanOfType(ConfigurableListableBeanFactory bf, Class<T> beanType, String qualifier) {
	Map<String, T> candidateBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(bf, beanType);
	T matchingBean = null;
	for (String beanName : candidateBeans.keySet()) {
		if (isQualifierMatch(qualifier, beanName, bf)) {
			if (matchingBean != null) {
				throw new NoSuchBeanDefinitionException(qualifier, "No unique " + beanType.getSimpleName() +
						" bean found for qualifier '" + qualifier + "'");
			}
			matchingBean = candidateBeans.get(beanName);
		}
	}
	if (matchingBean != null) {
		return matchingBean;
	}
	else if (bf.containsBean(qualifier)) {
		// Fallback: target bean at least found by bean name - probably a manually registered singleton.
		return bf.getBean(qualifier, beanType);
	}
	else {
		throw new NoSuchBeanDefinitionException(qualifier, "No matching " + beanType.getSimpleName() +
				" bean found for qualifier '" + qualifier + "' - neither qualifier match nor bean name match!");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:34,代码来源:BeanFactoryAnnotationUtils.java

示例10: processProperties

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
@Override
	protected void processProperties(
			ConfigurableListableBeanFactory beanFactoryToProcess,
			Properties props) throws BeansException {
		super.processProperties(beanFactoryToProcess, props);
		
		DWSTORAGETYPE = props.getProperty("dw.storage.type");
		ACCESS_KEY_ID = props.getProperty("dw.yunos.access_keyid");
		SECRET_ACCESS_KEY = props.getProperty("dw.yunos.access_keysecret");
		ENDPOINT = props.getProperty("dw.yunos.endpoint");
//		FILE_BACKET_DOMAIN = props.getProperty("dw.yunos.file_backet_domain");
		STORAGE_URL_PREFIX = props.getProperty("dw.storage.url_prefix");
		
		WENJUANHTML_BACKET = props.getProperty("dw.yunos.wenjuan_html_backet");
		UPLOADFILE_BACKET = props.getProperty("dw.yunos.upload_file_backet");
		UPLOADFILE_JM_BACKET = props.getProperty("dw.yunos.upload_file_jm_backet");
		/*
		ctxPropertiesMap = new HashMap<String, String>();
		for (Object key : props.keySet()) {
			String keyStr = key.toString();
			String value = props.getProperty(keyStr);
			ctxPropertiesMap.put(keyStr, value);
		}
		*/
	}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:26,代码来源:DiaowenProperty.java

示例11: postProcessBeanFactory

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
	LOGGER.debug(() -> "Lookup @Path and @Provider JAX-RS resource in bean factory [" + beanFactory + "]");

	resources = new ArrayList<>();

	for (String name : beanFactory.getBeanDefinitionNames()) {
		try {
			BeanDefinition definition = beanFactory.getBeanDefinition(name);
			if (!definition.isAbstract()) {
				Class<?> beanClass = BeanRegistryUtils.getBeanClass(name, definition, beanFactory, classLoader);
				if (beanClass != null) {
					if (isJaxrsResourceClass(definition, beanClass)) {
						resources.add(new WeakReference<>(beanClass));
						LOGGER.debug(() -> "Found JAX-RS resource class: [" + beanClass.getName() + "]");
					}
				}
			}
		} catch (@SuppressWarnings("unused") NoSuchBeanDefinitionException e) {
			// ignore
		}
	}
}
 
开发者ID:holon-platform,项目名称:holon-jaxrs,代码行数:24,代码来源:JerseyResourcesPostProcessor.java

示例12: isBeanBundleScoped

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
private boolean isBeanBundleScoped() {
	boolean bundleScoped = false;
	// if we do have a bundle scope, use ServiceFactory decoration
	if (targetBeanName != null) {
		if (beanFactory instanceof ConfigurableListableBeanFactory) {
			String beanScope =
					((ConfigurableListableBeanFactory) beanFactory).getMergedBeanDefinition(targetBeanName)
							.getScope();
			bundleScoped = OsgiBundleScope.SCOPE_NAME.equals(beanScope);
		} else
			// if for some reason, the passed in BeanFactory can't be
			// queried for scopes and we do
			// have a bean reference, apply scoped decoration.
			bundleScoped = true;
	}
	return bundleScoped;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:OsgiServiceFactoryBean.java

示例13: getTransitiveDependenciesForBean

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
/**
 * Return all beans depending directly or indirectly (transitively), on the bean identified by the beanName. When
 * dealing with a FactoryBean, the factory itself can be returned or its product. Additional filtering can be
 * executed through the type parameter. If no filtering is required, then null can be passed.
 * 
 * Note that depending on #rawFactoryBeans parameter, the type of the factory or its product can be used when doing
 * the filtering.
 * 
 * @param beanFactory beans bean factory
 * @param beanName root bean name
 * @param rawFactoryBeans consider the factory bean itself or the its product
 * @param type type of the beans returned (null to return all beans)
 * @return bean names
 */
public static String[] getTransitiveDependenciesForBean(ConfigurableListableBeanFactory beanFactory,
		String beanName, boolean rawFactoryBeans, Class<?> type) {
	Assert.notNull(beanFactory);
	Assert.hasText(beanName);

	Assert.isTrue(beanFactory.containsBean(beanName), "no bean by name [" + beanName + "] can be found");

	Set<String> beans = new LinkedHashSet<String>(8);
	// used to break cycles between nested beans
	Set<String> innerBeans = new LinkedHashSet<String>(4);

	getTransitiveBeans(beanFactory, beanName, rawFactoryBeans, beans, innerBeans);

	if (type != null) {
		// filter by type
		for (Iterator<String> iter = beans.iterator(); iter.hasNext();) {
			String bean = iter.next();
			if (!beanFactory.isTypeMatch(bean, type)) {
				iter.remove();
			}
		}
	}

	return beans.toArray(new String[beans.size()]);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:40,代码来源:BeanFactoryUtils.java

示例14: getBeanFactoryClassName

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
/**
 * Get the Factory class name which corresponds to given bean definition.
 * @param definition Bean definition
 * @param beanFactory Bean factory
 * @return Factory class name, or <code>null</code> if not found
 */
private static String getBeanFactoryClassName(BeanDefinition definition,
		ConfigurableListableBeanFactory beanFactory) {
	if (definition instanceof AnnotatedBeanDefinition) {
		return ((AnnotatedBeanDefinition) definition).getMetadata().getClassName();
	} else {
		if (definition.getFactoryBeanName() != null) {
			BeanDefinition fd = beanFactory.getBeanDefinition(definition.getFactoryBeanName());
			if (fd != null) {
				return fd.getBeanClassName();
			}
		} else {
			return definition.getBeanClassName();
		}
	}
	return null;
}
 
开发者ID:holon-platform,项目名称:holon-core,代码行数:23,代码来源:BeanRegistryUtils.java

示例15: setUp

import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; //导入依赖的package包/类
protected void setUp() throws Exception {
	bundleContext = new MockBundleContext();

	context = new GenericApplicationContext();
	context.setClassLoader(getClass().getClassLoader());
	context.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));
	context.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {

		public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
			beanFactory.addPropertyEditorRegistrar(new BlueprintEditorRegistrar());
		}
	});

	reader = new XmlBeanDefinitionReader(context);
	reader.setDocumentLoader(new PublicBlueprintDocumentLoader());
	reader.loadBeanDefinitions(new ClassPathResource(CONFIG, getClass()));
	context.refresh();

	blueprintContainer = new SpringBlueprintContainer(context);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:21,代码来源:LazyExporterTest.java


注:本文中的org.springframework.beans.factory.config.ConfigurableListableBeanFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。