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


Java BeanDefinition类代码示例

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


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

示例1: should_ignore_existing_spies_when_searching_for_bean_by_class

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
@Test
public void should_ignore_existing_spies_when_searching_for_bean_by_class() {
	//given
	final String spyName = "spy";
	final DoubleRegistry doubleRegistry = new DoubleRegistry(
			emptyList(),
			singletonList(doubleDefinition(String.class, spyName)));
	final ApplicationContext appCtx = buildAppContext(Stream.of(
			bean(spyName, spyName + " - bean")
	));
	final BeanDefinitionFinder definitionFinder = new BeanDefinitionFinder(appCtx, doubleRegistry);

	//when
	final Optional<BeanDefinition> definition = definitionFinder.tryToFindBeanDefinition("any bean name", String.class);

	//then
	assertFalse(definition.isPresent());
}
 
开发者ID:pchudzik,项目名称:springmock,代码行数:19,代码来源:BeanDefinitionFinderTest.java

示例2: getBeanProperties

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
static List<BeanProperty> getBeanProperties(BeanDefinition definition) {
	List<BeanProperty> temp;

	List<PropertyValue> pvs = definition.getPropertyValues().getPropertyValueList();

	if (pvs.isEmpty()) {
		return Collections.<BeanProperty> emptyList();
	} else {
		temp = new ArrayList<BeanProperty>(pvs.size());
	}

	for (PropertyValue propertyValue : pvs) {
		temp.add(new SimpleBeanProperty(propertyValue));
	}

	return Collections.unmodifiableList(temp);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:MetadataUtils.java

示例3: registerBeanDefinitions

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
    provider.addIncludeFilter(new AnnotationTypeFilter(Consumer.class));
    provider.addIncludeFilter(new AssignableTypeFilter(IConsumer.class));
    Set<BeanDefinition> beanDefinitionSet = provider.findCandidateComponents("spring.study.componentprovider.bean");

    for(BeanDefinition beanDefinition : beanDefinitionSet) {
        String beanName = beanNameGenerator.generateBeanName(beanDefinition, registry);
        if(!registry.containsBeanDefinition(beanName)) {
            registry.registerBeanDefinition(beanName, beanDefinition);
            registry.registerBeanDefinition("11", beanDefinition);
        }
    }

}
 
开发者ID:fangjian0423,项目名称:springboot-analysis,代码行数:17,代码来源:ConsumerRegistrar.java

示例4: findParentDefinition

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
private BeanDefinition findParentDefinition(String parentName, BeanDefinitionRegistry registry)
{   
    if (registry != null) 
    {
        if (registry.containsBeanDefinition(parentName)) 
        {
            return registry.getBeanDefinition(parentName);
        } 
        else if (registry instanceof HierarchicalBeanFactory) 
        {
            // Try to get parent definition from the parent BeanFactory. This could return null
            BeanFactory parentBeanFactory = ((HierarchicalBeanFactory)registry).getParentBeanFactory();
            return findParentDefinition(parentName, (BeanDefinitionRegistry)parentBeanFactory);
        } 
    }
    
    // we've exhausted all possibilities        
    return null;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:DwrNamespaceHandler.java

示例5: fileMenu

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public Menu fileMenu() {
    Menu file = new Menu(localeService.getMessage("ui.menu.file"));
    file.setMnemonicParsing(false);

    MenuItem connect = new MenuItem(localeService.getMessage("ui.menu.file.connect"));
    connect.setMnemonicParsing(false);
    connect.setOnAction(event -> newConnectionBox(getMainView().getPrimaryStage(),
            (data) -> getMainController().loadTables(data)));

    MenuItem manager = new MenuItem(localeService.getMessage("ui.menu.file.manager"));
    manager.setMnemonicParsing(false);
    manager.setOnAction(event -> connectionManager());
    file.getItems().addAll(connect, manager);
    return file;
}
 
开发者ID:Kindrat,项目名称:cassandra-client,代码行数:18,代码来源:CassandraClientUIConfiguration.java

示例6: registerBeanDefinitions

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

	if (beanFactory instanceof ListableBeanFactory) {

		String[] dataSourceBeanNames = ((ListableBeanFactory) beanFactory).getBeanNamesForType(DataSource.class,
				false, true);
		if (dataSourceBeanNames != null) {
			for (String dataSourceBeanName : dataSourceBeanNames) {
				BeanDefinition bd = registry.getBeanDefinition(dataSourceBeanName);
				if (bd instanceof DataContextBoundBeanDefinition) {
					DataSourceRegistrar.registerDataSourceTransactionManager(registry, dataSourceBeanName,
							((DataContextBoundBeanDefinition) bd).getDataContextId().orElse(null),
							PrimaryMode.AUTO);
				}
			}
		}

	}

}
 
开发者ID:holon-platform,项目名称:holon-jdbc,代码行数:22,代码来源:DataSourcesTransactionManagerAutoConfigurationRegistrar.java

示例7: cronyxQuartzConverterPairs

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
public static <T> List<Pair<Class, T>> cronyxQuartzConverterPairs(Class<T> tClass) {

        List<Pair<Class, T>> results = new ArrayList<>();

        ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
        provider.addIncludeFilter(new AssignableTypeFilter(tClass));

        Set<BeanDefinition> components = provider.findCandidateComponents(PACKAGE);
        for (BeanDefinition component : components) {
            try {
                Class cls = Class.forName(component.getBeanClassName());
                Class<?> typeArgument = GenericTypeResolver.resolveTypeArgument(cls, tClass);
                results.add(new ImmutablePair<>(typeArgument, (T) cls.newInstance()));

            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
                throw new CronyxException("Could not instantiate cronyxToQuartzConverters", e);
            }
        }
        return results;
    }
 
开发者ID:taboola,项目名称:taboola-cronyx,代码行数:21,代码来源:ConfigUtil.java

示例8: buildDefaultBeanName

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
@Override
protected String buildDefaultBeanName(BeanDefinition definition) {
    if(this.packageDepth < 1){
        return super.buildDefaultBeanName(definition);
    }

    String fullName = definition.getBeanClassName(); //e.g.: com.mobanker.tkj.api.action.UserAction
    char delimiter = dotReplacement > 0 ? dotReplacement : DEFAULT_DOT_REPLACEMENT;
    String[] names = fullName.split("\\.");
    StringBuilder beanName = new StringBuilder("");

    //add package name
    if(names.length > 1){
        for(int i = 0; i < this.packageDepth; i++){
            String name = names[names.length - 2 - i];
            beanName.insert(0, delimiter);
            beanName.insert(0, name);
        }
    }

    //add Class name
    beanName.append(names[names.length - 1]);

    return beanName.toString();
}
 
开发者ID:zjtx2017,项目名称:ocmall,代码行数:26,代码来源:FullPackageBeanNameGenerator.java

示例9: findAnnotationOnBean

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
/**
 * Find a {@link Annotation} of {@code annotationType} on the specified
 * bean, traversing its interfaces and super classes if no annotation can be
 * found on the given class itself, as well as checking its raw bean class
 * if not found on the exposed bean reference (e.g. in case of a proxy).
 */
@Override
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
		throws NoSuchBeanDefinitionException{

	A ann = null;
	Class<?> beanType = getType(beanName);
	if (beanType != null) {
		ann = AnnotationUtils.findAnnotation(beanType, annotationType);
	}
	if (ann == null && containsBeanDefinition(beanName)) {
		BeanDefinition bd = getMergedBeanDefinition(beanName);
		if (bd instanceof AbstractBeanDefinition) {
			AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
			if (abd.hasBeanClass()) {
				ann = AnnotationUtils.findAnnotation(abd.getBeanClass(), annotationType);
			}
		}
	}
	return ann;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:DefaultListableBeanFactory.java

示例10: testCompileExtendedServices

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
@Test
public void testCompileExtendedServices() throws Exception
{
    ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
    provider.addIncludeFilter(new AssignableTypeFilter(Extensible.class));

    Set<BeanDefinition> components = provider.findCandidateComponents("org/alfresco/*");
    Set<Class<? extends Extensible>> extensibles = new HashSet<>();
    for (BeanDefinition component : components)
    {
        @SuppressWarnings("unchecked")
        Class<? extends Extensible> extensibleClass = (Class<? extends Extensible>) Class.forName(component
                    .getBeanClassName());
        extensibles.add(extensibleClass);

    }
    compile(extensibles);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:AJExtensionsCompileTest.java

示例11: configureBean

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
@Override
public Object configureBean(Object existingBean, String beanName) throws BeansException {
	markBeanAsCreated(beanName);
	BeanDefinition mbd = getMergedBeanDefinition(beanName);
	RootBeanDefinition bd = null;
	if (mbd instanceof RootBeanDefinition) {
		RootBeanDefinition rbd = (RootBeanDefinition) mbd;
		bd = (rbd.isPrototype() ? rbd : rbd.cloneBeanDefinition());
	}
	if (!mbd.isPrototype()) {
		if (bd == null) {
			bd = new RootBeanDefinition(mbd);
		}
		bd.setScope(BeanDefinition.SCOPE_PROTOTYPE);
		bd.allowCaching = ClassUtils.isCacheSafe(ClassUtils.getUserClass(existingBean), getBeanClassLoader());
	}
	BeanWrapper bw = new BeanWrapperImpl(existingBean);
	initBeanWrapper(bw);
	populateBean(beanName, bd, bw);
	return initializeBean(beanName, existingBean, bd);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:AbstractAutowireCapableBeanFactory.java

示例12: buildDefaultBeanName

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
@Override
protected String buildDefaultBeanName(BeanDefinition definition) {
	if(this.packageDepth < 1){
		return super.buildDefaultBeanName(definition);
	}
	
	String fullName = definition.getBeanClassName(); //e.g.: com.tasfe.tkj.api.action.UserAction
	char delimiter = dotReplacement > 0 ? dotReplacement : DEFAULT_DOT_REPLACEMENT;
	String[] names = fullName.split("\\.");
	StringBuilder beanName = new StringBuilder("");

	//add package name
	if(names.length > 1){
		for(int i = 0; i < this.packageDepth; i++){
			String name = names[names.length - 2 - i];
			beanName.insert(0, delimiter);
			beanName.insert(0, name);
		}
	}
	
	//add Class name
	beanName.append(names[names.length - 1]);
	
	return beanName.toString();
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:26,代码来源:FullPackageBeanNameGenerator.java

示例13: findInnerBeanDefinitionsAndBeanReferences

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
private void findInnerBeanDefinitionsAndBeanReferences(BeanDefinition beanDefinition) {
	List<BeanDefinition> innerBeans = new ArrayList<BeanDefinition>();
	List<BeanReference> references = new ArrayList<BeanReference>();
	PropertyValues propertyValues = beanDefinition.getPropertyValues();
	for (int i = 0; i < propertyValues.getPropertyValues().length; i++) {
		PropertyValue propertyValue = propertyValues.getPropertyValues()[i];
		Object value = propertyValue.getValue();
		if (value instanceof BeanDefinitionHolder) {
			innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition());
		}
		else if (value instanceof BeanDefinition) {
			innerBeans.add((BeanDefinition) value);
		}
		else if (value instanceof BeanReference) {
			references.add((BeanReference) value);
		}
	}
	this.innerBeanDefinitions = innerBeans.toArray(new BeanDefinition[innerBeans.size()]);
	this.beanReferences = references.toArray(new BeanReference[references.size()]);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:BeanComponentDefinition.java

示例14: parse

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
    RootBeanDefinition beanDefinition = new RootBeanDefinition();
    beanDefinition.setBeanClass(beanClass);
    beanDefinition.setLazyInit(false);

    String key = element.getAttribute("key");
    String value = element.getAttribute("value");
    String hide = element.getAttribute("hide");
    if(CommonUtils.isTrue(hide)){
        JSFContext.putGlobalVal(Constants.HIDE_KEY_PREFIX + key, value);
    } else {
        JSFContext.putGlobalVal(key, value);
    }

    beanDefinition.getPropertyValues().addPropertyValue("key", key);
    beanDefinition.getPropertyValues().addPropertyValue("value", value);
    beanDefinition.getPropertyValues().addPropertyValue("hide", Boolean.valueOf(hide));

    return beanDefinition;
}
 
开发者ID:tiglabs,项目名称:jsf-sdk,代码行数:22,代码来源:JSFParameterDefinitionParser.java

示例15: addIncludePatterns

import org.springframework.beans.factory.config.BeanDefinition; //导入依赖的package包/类
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) {
	ManagedList<TypedStringValue> includePatterns = new ManagedList<TypedStringValue>();
	NodeList childNodes = element.getChildNodes();
	for (int i = 0; i < childNodes.getLength(); i++) {
		Node node = childNodes.item(i);
		if (node instanceof Element) {
			Element includeElement = (Element) node;
			TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name"));
			valueHolder.setSource(parserContext.extractSource(includeElement));
			includePatterns.add(valueHolder);
		}
	}
	if (!includePatterns.isEmpty()) {
		includePatterns.setSource(parserContext.extractSource(element));
		beanDef.getPropertyValues().add("includePatterns", includePatterns);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:AspectJAutoProxyBeanDefinitionParser.java


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