當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。