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


Java ScopeMetadataResolver类代码示例

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


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

示例1: createContext

import org.springframework.context.annotation.ScopeMetadataResolver; //导入依赖的package包/类
private ApplicationContext createContext(final ScopedProxyMode scopedProxyMode) {
	GenericWebApplicationContext context = new GenericWebApplicationContext();
	ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
	scanner.setIncludeAnnotationConfig(false);
	scanner.setScopeMetadataResolver(new ScopeMetadataResolver() {
		@Override
		public ScopeMetadata resolveScopeMetadata(BeanDefinition definition) {
			ScopeMetadata metadata = new ScopeMetadata();
			if (definition instanceof AnnotatedBeanDefinition) {
				AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;
				for (String type : annDef.getMetadata().getAnnotationTypes()) {
					if (type.equals(javax.inject.Singleton.class.getName())) {
						metadata.setScopeName(BeanDefinition.SCOPE_SINGLETON);
						break;
					}
					else if (annDef.getMetadata().getMetaAnnotationTypes(type).contains(javax.inject.Scope.class.getName())) {
						metadata.setScopeName(type.substring(type.length() - 13, type.length() - 6).toLowerCase());
						metadata.setScopedProxyMode(scopedProxyMode);
						break;
					}
					else if (type.startsWith("javax.inject")) {
						metadata.setScopeName(BeanDefinition.SCOPE_PROTOTYPE);
					}
				}
			}
			return metadata;
		}
	});

	// Scan twice in order to find errors in the bean definition compatibility check.
	scanner.scan(getClass().getPackage().getName());
	scanner.scan(getClass().getPackage().getName());

	context.registerAlias("classPathBeanDefinitionScannerJsr330ScopeIntegrationTests.SessionScopedTestBean", "session");
	context.refresh();
	return context;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:38,代码来源:ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests.java

示例2: setScopeMetadataResolver

import org.springframework.context.annotation.ScopeMetadataResolver; //导入依赖的package包/类
/**
 * Set a custom {@link ScopeMetadataResolver} for use with {@link AnnotatedBeanDefinitionReader}
 * and/or {@link ClassPathBeanDefinitionScanner}.
 * <p>Default is an {@link org.springframework.context.annotation.AnnotationScopeMetadataResolver}.
 * @see AnnotatedBeanDefinitionReader#setScopeMetadataResolver
 * @see ClassPathBeanDefinitionScanner#setScopeMetadataResolver
 */
public void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver) {
	this.scopeMetadataResolver = scopeMetadataResolver;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:AnnotationConfigWebApplicationContext.java

示例3: getScopeMetadataResolver

import org.springframework.context.annotation.ScopeMetadataResolver; //导入依赖的package包/类
/**
 * Return the custom {@link ScopeMetadataResolver} for use with {@link AnnotatedBeanDefinitionReader}
 * and/or {@link ClassPathBeanDefinitionScanner}, if any.
 */
protected ScopeMetadataResolver getScopeMetadataResolver() {
	return this.scopeMetadataResolver;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:8,代码来源:AnnotationConfigWebApplicationContext.java

示例4: setScopeMetadataResolver

import org.springframework.context.annotation.ScopeMetadataResolver; //导入依赖的package包/类
/**
 * Set the {@link ScopeMetadataResolver} to use for detected bean classes.
 * <p>
 * The default is an {@link AnnotationScopeMetadataResolver}.
 * <p>
 * Any call to this method must occur prior to calls to {@link #register(Class...)}
 * and/or {@link #scan(String...)}.
 * @param scopeMetadataResolver the scope metadata resolver
 */
public void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver) {
	this.reader.setScopeMetadataResolver(scopeMetadataResolver);
	this.scanner.setScopeMetadataResolver(scopeMetadataResolver);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:AnnotationConfigEmbeddedWebApplicationContext.java

示例5: setScopeMetadataResolver

import org.springframework.context.annotation.ScopeMetadataResolver; //导入依赖的package包/类
/**
 * Set a custom {@link ScopeMetadataResolver} for use with {@link AnnotatedBeanDefinitionReader}
 * and/or {@link ClassPathBeanDefinitionScanner}.
 * <p>Default is an {@link org.springframework.context.annotation.AnnotationScopeMetadataResolver}.
 * @see AnnotatedBeanDefinitionReader#setScopeMetadataResolver
 * @see ClassPathBeanDefinitionScanner#setScopeMetadataResolver
 */
public void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver) {
    this.scopeMetadataResolver = scopeMetadataResolver;
}
 
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:11,代码来源:AnnotationConfigWebApplicationContext.java

示例6: getScopeMetadataResolver

import org.springframework.context.annotation.ScopeMetadataResolver; //导入依赖的package包/类
/**
 * Return the custom {@link ScopeMetadataResolver} for use with {@link AnnotatedBeanDefinitionReader}
 * and/or {@link ClassPathBeanDefinitionScanner}, if any.
 */
protected ScopeMetadataResolver getScopeMetadataResolver() {
    return this.scopeMetadataResolver;
}
 
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:8,代码来源:AnnotationConfigWebApplicationContext.java

示例7: setScopeMetadataResolver

import org.springframework.context.annotation.ScopeMetadataResolver; //导入依赖的package包/类
/**
 * Set the {@link org.springframework.context.annotation.ScopeMetadataResolver} to use for detected bean classes.
 * <p>The default is an {@link org.springframework.context.annotation.AnnotationScopeMetadataResolver}.
 * <p>Any call to this method must occur prior to calls to {@link #register(Class...)}
 * and/or {@link #scan(String...)}.
 */
public void setScopeMetadataResolver(ScopeMetadataResolver scopeMetadataResolver) {
	this.reader.setScopeMetadataResolver(scopeMetadataResolver);
	this.scanner.setScopeMetadataResolver(scopeMetadataResolver);
}
 
开发者ID:elasticsoftwarefoundation,项目名称:elasticactors,代码行数:11,代码来源:AnnotationConfigApplicationContext.java


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