• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AopConfigUtils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parseInternal

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
	Mode mode = Mode.valueOf(element.getAttribute("mode").toUpperCase());

	if (Mode.OFF.equals(mode)) {
		return null;
	}

	String dataMapperRef = element.getAttribute("data-mapper-ref");

	BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(CaptureReplayAdvice.class);
	builder.addPropertyValue("mode", mode);
	builder.addPropertyReference("dataMapper", dataMapperRef);

	AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(parserContext.getRegistry());

	return builder.getBeanDefinition();
}
 
开发者ID:codecentric,项目名称:capture-replay-framework,代码行数:19,代码来源:CaptureReplayBeanDefinitionParser.java


示例2: registerBeanDefinitions

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
/**
 * Register, escalate, and configure the AspectJ auto proxy creator based on the value
 * of the @{@link EnableAspectJAutoProxy#proxyTargetClass()} attribute on the importing
 * {@code @Configuration} class.
 */
@Override
public void registerBeanDefinitions(
		AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

	AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry);

	AnnotationAttributes enableAJAutoProxy =
			AnnotationConfigUtils.attributesFor(importingClassMetadata, EnableAspectJAutoProxy.class);
	if (enableAJAutoProxy.getBoolean("proxyTargetClass")) {
		AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:AspectJAutoProxyRegistrar.java


示例3: registerBeanDefinitions

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
/**
 * Register, escalate, and configure the standard auto proxy creator (APC) against the
 * given registry. Works by finding the nearest annotation declared on the importing
 * {@code @Configuration} class that has both {@code mode} and {@code proxyTargetClass}
 * attributes. If {@code mode} is set to {@code PROXY}, the APC is registered; if
 * {@code proxyTargetClass} is set to {@code true}, then the APC is forced to use
 * subclass (CGLIB) proxying.
 * <p>Several {@code @Enable*} annotations expose both {@code mode} and
 * {@code proxyTargetClass} attributes. It is important to note that most of these
 * capabilities end up sharing a {@linkplain AopConfigUtils#AUTO_PROXY_CREATOR_BEAN_NAME
 * single APC}. For this reason, this implementation doesn't "care" exactly which
 * annotation it finds -- as long as it exposes the right {@code mode} and
 * {@code proxyTargetClass} attributes, the APC can be registered and configured all
 * the same.
 */
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
	boolean candidateFound = false;
	Set<String> annoTypes = importingClassMetadata.getAnnotationTypes();
	for (String annoType : annoTypes) {
		AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
		Object mode = candidate.get("mode");
		Object proxyTargetClass = candidate.get("proxyTargetClass");
		if (mode != null && proxyTargetClass != null && mode.getClass().equals(AdviceMode.class) &&
				proxyTargetClass.getClass().equals(Boolean.class)) {
			candidateFound = true;
			if (mode == AdviceMode.PROXY) {
				AopConfigUtils.registerAutoProxyCreatorIfNecessary(registry);
				if ((Boolean) proxyTargetClass) {
					AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
					return;
				}
			}
		}
	}
	if (!candidateFound) {
		String name = getClass().getSimpleName();
		logger.warn(String.format("%s was imported but no annotations were found " +
				"having both 'mode' and 'proxyTargetClass' attributes of type " +
				"AdviceMode and boolean respectively. This means that auto proxy " +
				"creator registration and configuration may not have occured as " +
				"intended, and components may not be proxied as expected. Check to " +
				"ensure that %s has been @Import'ed on the same class where these " +
				"annotations are declared; otherwise remove the import of %s " +
				"altogether.", name, name, name));
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:48,代码来源:AutoProxyRegistrar.java


示例4: testRegisterAspectJAutoProxyCreator

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
@Test
public void testRegisterAspectJAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect number of definitions registered", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("Incorrect APC class",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:AspectJNamespaceHandlerTests.java


示例5: testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
@Test
public void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() throws Exception {
	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals(1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect definition count", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("APC class not switched",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:AspectJNamespaceHandlerTests.java


示例6: testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
@Test
public void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() throws Exception {
	AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals(1, registry.getBeanDefinitionCount());

	AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
	assertEquals("Incorrect definition count", 1, registry.getBeanDefinitionCount());

	BeanDefinition definition = registry.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertEquals("Incorrect APC class",
			AspectJAwareAdvisorAutoProxyCreator.class.getName(), definition.getBeanClassName());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:AspectJNamespaceHandlerTests.java


示例7: registerBeanDefinitions

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
/**
 * Register, escalate, and configure the standard auto proxy creator (APC) against the
 * given registry. Works by finding the nearest annotation declared on the importing
 * {@code @Configuration} class that has both {@code mode} and {@code proxyTargetClass}
 * attributes. If {@code mode} is set to {@code PROXY}, the APC is registered; if
 * {@code proxyTargetClass} is set to {@code true}, then the APC is forced to use
 * subclass (CGLIB) proxying.
 * <p>Several {@code @Enable*} annotations expose both {@code mode} and
 * {@code proxyTargetClass} attributes. It is important to note that most of these
 * capabilities end up sharing a {@linkplain AopConfigUtils#AUTO_PROXY_CREATOR_BEAN_NAME
 * single APC}. For this reason, this implementation doesn't "care" exactly which
 * annotation it finds -- as long as it exposes the right {@code mode} and
 * {@code proxyTargetClass} attributes, the APC can be registered and configured all
 * the same.
 */
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
	boolean candidateFound = false;
	Set<String> annoTypes = importingClassMetadata.getAnnotationTypes();
	for (String annoType : annoTypes) {
		AnnotationAttributes candidate = AnnotationConfigUtils.attributesFor(importingClassMetadata, annoType);
		Object mode = candidate.get("mode");
		Object proxyTargetClass = candidate.get("proxyTargetClass");
		if (mode != null && proxyTargetClass != null && AdviceMode.class == mode.getClass() &&
				Boolean.class == proxyTargetClass.getClass()) {
			candidateFound = true;
			if (mode == AdviceMode.PROXY) {
				AopConfigUtils.registerAutoProxyCreatorIfNecessary(registry);
				if ((Boolean) proxyTargetClass) {
					AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
					return;
				}
			}
		}
	}
	if (!candidateFound) {
		String name = getClass().getSimpleName();
		logger.warn(String.format("%s was imported but no annotations were found " +
				"having both 'mode' and 'proxyTargetClass' attributes of type " +
				"AdviceMode and boolean respectively. This means that auto proxy " +
				"creator registration and configuration may not have occured as " +
				"intended, and components may not be proxied as expected. Check to " +
				"ensure that %s has been @Import'ed on the same class where these " +
				"annotations are declared; otherwise remove the import of %s " +
				"altogether.", name, name, name));
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:48,代码来源:AutoProxyRegistrar.java


示例8: testForceProxyTargetClass

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
@Test
public void testForceProxyTargetClass() {
	ClassPathXmlApplicationContext bf = newContext("aspectsWithCGLIB.xml");

	ProxyConfig pc = (ProxyConfig) bf.getBean(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	assertTrue("should be proxying classes", pc.isProxyTargetClass());
	assertTrue("should expose proxy", pc.isExposeProxy());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:AspectJAutoProxyCreatorTests.java


示例9: registerBeanDefinitions

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
	MultiValueMap<String, Object> attributes = importingClassMetadata.getAllAnnotationAttributes(EnableCaptureReplay.class.getName());

	Mode mode = Mode.valueOf(attributes.getFirst("mode").toString());

	if (!Mode.OFF.equals(mode)) {
		BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(CaptureReplayAdvice.class);
		builder.addPropertyValue("mode", mode);
		builder.addPropertyReference("dataMapper", attributes.getFirst("dataMapper").toString());
		registry.registerBeanDefinition(DEFAULT_CAPTURE_REPLAY_ADVICE_BEAN_ID, builder.getBeanDefinition());

		AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry);
	}
}
 
开发者ID:codecentric,项目名称:capture-replay-framework,代码行数:16,代码来源:CaptureReplayImportBeanDefinitionRegistrar.java


示例10: buildPointcutAndAdvisorBeanDefinition

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
private void buildPointcutAndAdvisorBeanDefinition(String name, List<String> expressionList, ParserContext parserContext, BeanDefinitionRegistry beanDefinitionRegistry) {
	CompositeComponentDefinition compositeComponentDefinition = new CompositeComponentDefinition("mul-transaction-expression", null);
	parserContext.pushContainingComponent(compositeComponentDefinition);

	BeanDefinition aspectJAutoProxyCreatorBeanDefinition = AopConfigUtils.registerAspectJAutoProxyCreatorIfNecessary(beanDefinitionRegistry);
	AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(beanDefinitionRegistry);
	if (aspectJAutoProxyCreatorBeanDefinition != null) {
		BeanComponentDefinition componentDefinition = new BeanComponentDefinition(aspectJAutoProxyCreatorBeanDefinition, AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
		parserContext.registerComponent(componentDefinition);
	}
	for (String expression : expressionList) {
		RootBeanDefinition pointcutDefinition = new RootBeanDefinition(AspectJExpressionPointcut.class);
		pointcutDefinition.setScope(BeanDefinition.SCOPE_PROTOTYPE);
		pointcutDefinition.setSynthetic(true);
		pointcutDefinition.getPropertyValues().add("expression", expression);
		String pointcutBeanName = parserContext.getReaderContext().registerWithGeneratedName(pointcutDefinition);
		parserContext.registerComponent(new PointcutComponentDefinition(pointcutBeanName, pointcutDefinition, expression));

		RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class);
		advisorDefinition.getPropertyValues().add("adviceBeanName", new RuntimeBeanNameReference(name + HIBERNATE_ADVICE_SUFFIX));
		String advisorBeanName = parserContext.getReaderContext().registerWithGeneratedName(advisorDefinition);
		advisorDefinition.getPropertyValues().add("pointcut", new RuntimeBeanReference(pointcutBeanName));
		parserContext.registerComponent(new AdvisorComponentDefinition(advisorBeanName, advisorDefinition));
	}

	parserContext.popAndRegisterContainingComponent();
}
 
开发者ID:xiaolongzuo,项目名称:zxl,代码行数:28,代码来源:MulCommonBaseServiceParser.java


示例11: registerBeanDefinitions

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
/**
 * Register, escalate, and configure the AspectJ auto proxy creator based on the value
 * of the @{@link EnableAspectJAutoProxy#proxyTargetClass()} attribute on the importing
 * {@code @Configuration} class.
 */
public void registerBeanDefinitions(
		AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

	AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary(registry);

	AnnotationAttributes enableAJAutoProxy =
			attributesFor(importingClassMetadata, EnableAspectJAutoProxy.class);
	if (enableAJAutoProxy.getBoolean("proxyTargetClass")) {
		AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:17,代码来源:AspectJAutoProxyRegistrar.java


示例12: registerBeanDefinitions

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
/**
 * Register, escalate, and configure the standard auto proxy creator (APC) against the
 * given registry. Works by finding the nearest annotation declared on the importing
 * {@code @Configuration} class that has both {@code mode} and {@code proxyTargetClass}
 * attributes. If {@code mode} is set to {@code PROXY}, the APC is registered; if
 * {@code proxyTargetClass} is set to {@code true}, then the APC is forced to use
 * subclass (CGLIB) proxying.
 * <p>Several {@code @Enable*} annotations expose both {@code mode} and
 * {@code proxyTargetClass} attributes. It is important to note that most of these
 * capabilities end up sharing a {@linkplain AopConfigUtils#AUTO_PROXY_CREATOR_BEAN_NAME
 * single APC}. For this reason, this implementation doesn't "care" exactly which
 * annotation it finds -- as long as it exposes the right {@code mode} and
 * {@code proxyTargetClass} attributes, the APC can be registered and configured all
 * the same.
 */
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
	boolean candidateFound = false;
	Set<String> annoTypes = importingClassMetadata.getAnnotationTypes();
	for (String annoType : annoTypes) {
		AnnotationAttributes candidate = MetadataUtils.attributesFor(importingClassMetadata, annoType);
		Object mode = candidate.get("mode");
		Object proxyTargetClass = candidate.get("proxyTargetClass");
		if (mode != null && proxyTargetClass != null && mode.getClass().equals(AdviceMode.class) &&
				proxyTargetClass.getClass().equals(Boolean.class)) {
			candidateFound = true;
			if (mode == AdviceMode.PROXY) {
				AopConfigUtils.registerAutoProxyCreatorIfNecessary(registry);
				if ((Boolean) proxyTargetClass) {
					AopConfigUtils.forceAutoProxyCreatorToUseClassProxying(registry);
					return;
				}
			}
		}
	}
	if (!candidateFound) {
		String name = getClass().getSimpleName();
		logger.warn(String.format("%s was imported but no annotations were found " +
				"having both 'mode' and 'proxyTargetClass' attributes of type " +
				"AdviceMode and boolean respectively. This means that auto proxy " +
				"creator registration and configuration may not have occured as " +
				"intended, and components may not be proxied as expected. Check to " +
				"ensure that %s has been @Import'ed on the same class where these " +
				"annotations are declared; otherwise remove the import of %s " +
				"altogether.", name, name, name));
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:47,代码来源:AutoProxyRegistrar.java


示例13: defaultProxyCreatorIsOurOwn

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
/**
 * First, check that the default bean creator (under the hard-coded Spring bean name)
 * is the dummy one we created.
 *
 * @throws Exception
 */
@Test
public void defaultProxyCreatorIsOurOwn() throws Exception
{
	final Object defaultCreator = applicationContext
			.getBean(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	// AopConfigUtils.APS_PRIORITY_LIST mandates a *specific* class name
	// assertTrue("Unexpected proxy creator bean type", ReflectionUtil.instanceOf(
	// defaultCreator, SelectiveAspectJAutoProxyCreator.class));
	assertTrue("Unexpected proxy creator bean type", ReflectionUtil.instanceOf(
			defaultCreator, AnnotationAwareAspectJAutoProxyCreator.class));
}
 
开发者ID:openfurther,项目名称:further-open-core,代码行数:18,代码来源:UTestAspectJAutoproxy.java


示例14: postProcessBeanFactory

import org.springframework.aop.config.AopConfigUtils; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void postProcessBeanFactory(
		ConfigurableListableBeanFactory beanFactory) throws BeansException {
	
	AopConfigUtils.registerAspectJAnnotationAutoProxyCreatorIfNecessary((BeanDefinitionRegistry) beanFactory);
	BeanDefinition bd = beanFactory.getBeanDefinition(AopConfigUtils.AUTO_PROXY_CREATOR_BEAN_NAME);
	bd.getPropertyValues().add("aspectJAdvisorFactory", new DeclareMixinAspectJAdvisorFactory());
}
 
开发者ID:chelu,项目名称:jdal,代码行数:12,代码来源:DeclareMixinAutoProxyCreatorConfigurer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MapTaskStatistics类代码示例发布时间:2022-05-22
下一篇:
Java DefaultFileSet类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap