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