org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor Java Examples
The following examples show how to use
org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigBeanDefinitionParser.java From spring-analysis-note with MIT License | 6 votes |
/** * Create a {@link RootBeanDefinition} for the advisor described in the supplied. Does <strong>not</strong> * parse any associated '{@code pointcut}' or '{@code pointcut-ref}' attributes. */ private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) { RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); advisorDefinition.setSource(parserContext.extractSource(advisorElement)); String adviceRef = advisorElement.getAttribute(ADVICE_REF); if (!StringUtils.hasText(adviceRef)) { parserContext.getReaderContext().error( "'advice-ref' attribute contains empty value.", advisorElement, this.parseState.snapshot()); } else { advisorDefinition.getPropertyValues().add( ADVICE_BEAN_NAME, new RuntimeBeanNameReference(adviceRef)); } if (advisorElement.hasAttribute(ORDER_PROPERTY)) { advisorDefinition.getPropertyValues().add( ORDER_PROPERTY, advisorElement.getAttribute(ORDER_PROPERTY)); } return advisorDefinition; }
Example #2
Source File: ConfigBeanDefinitionParser.java From java-technology-stack with MIT License | 6 votes |
/** * Create a {@link RootBeanDefinition} for the advisor described in the supplied. Does <strong>not</strong> * parse any associated '{@code pointcut}' or '{@code pointcut-ref}' attributes. */ private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) { RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); advisorDefinition.setSource(parserContext.extractSource(advisorElement)); String adviceRef = advisorElement.getAttribute(ADVICE_REF); if (!StringUtils.hasText(adviceRef)) { parserContext.getReaderContext().error( "'advice-ref' attribute contains empty value.", advisorElement, this.parseState.snapshot()); } else { advisorDefinition.getPropertyValues().add( ADVICE_BEAN_NAME, new RuntimeBeanNameReference(adviceRef)); } if (advisorElement.hasAttribute(ORDER_PROPERTY)) { advisorDefinition.getPropertyValues().add( ORDER_PROPERTY, advisorElement.getAttribute(ORDER_PROPERTY)); } return advisorDefinition; }
Example #3
Source File: HttpRequestParamsValidateManager.java From common-project with Apache License 2.0 | 6 votes |
/** * 设置注册bean动态AOP信息 * * @param configs * @param beanFactory */ private void setAopInfo(List<String> configs, ConfigurableListableBeanFactory beanFactory) { if (beanFactory instanceof BeanDefinitionRegistry) { BeanDefinitionRegistry beanDefinitionRegistry = (BeanDefinitionRegistry) beanFactory; for (String config : configs) { //增强器 RootBeanDefinition advisor = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); advisor.getPropertyValues().addPropertyValue("adviceBeanName", new RuntimeBeanReference("httpParamsValidateAdvisor").getBeanName()); //切点类 RootBeanDefinition pointCut = new RootBeanDefinition(AspectJExpressionPointcut.class); pointCut.setScope(BeanDefinition.SCOPE_PROTOTYPE); pointCut.setSynthetic(true); pointCut.getPropertyValues().addPropertyValue("expression", config); advisor.getPropertyValues().addPropertyValue("pointcut", pointCut); //注册到spring容器 String beanName = BeanDefinitionReaderUtils.generateBeanName(advisor, beanDefinitionRegistry, false); beanDefinitionRegistry.registerBeanDefinition(beanName, advisor); } } }
Example #4
Source File: ConfigBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create a {@link RootBeanDefinition} for the advisor described in the supplied. Does <strong>not</strong> * parse any associated '{@code pointcut}' or '{@code pointcut-ref}' attributes. */ private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) { RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); advisorDefinition.setSource(parserContext.extractSource(advisorElement)); String adviceRef = advisorElement.getAttribute(ADVICE_REF); if (!StringUtils.hasText(adviceRef)) { parserContext.getReaderContext().error( "'advice-ref' attribute contains empty value.", advisorElement, this.parseState.snapshot()); } else { advisorDefinition.getPropertyValues().add( ADVICE_BEAN_NAME, new RuntimeBeanNameReference(adviceRef)); } if (advisorElement.hasAttribute(ORDER_PROPERTY)) { advisorDefinition.getPropertyValues().add( ORDER_PROPERTY, advisorElement.getAttribute(ORDER_PROPERTY)); } return advisorDefinition; }
Example #5
Source File: ConfigBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Create a {@link RootBeanDefinition} for the advisor described in the supplied. Does <strong>not</strong> * parse any associated '{@code pointcut}' or '{@code pointcut-ref}' attributes. */ private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) { RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); advisorDefinition.setSource(parserContext.extractSource(advisorElement)); String adviceRef = advisorElement.getAttribute(ADVICE_REF); if (!StringUtils.hasText(adviceRef)) { parserContext.getReaderContext().error( "'advice-ref' attribute contains empty value.", advisorElement, this.parseState.snapshot()); } else { advisorDefinition.getPropertyValues().add( ADVICE_BEAN_NAME, new RuntimeBeanNameReference(adviceRef)); } if (advisorElement.hasAttribute(ORDER_PROPERTY)) { advisorDefinition.getPropertyValues().add( ORDER_PROPERTY, advisorElement.getAttribute(ORDER_PROPERTY)); } return advisorDefinition; }
Example #6
Source File: SpringUtil.java From learnjavabug with MIT License | 5 votes |
public static Object makeBeanFactoryTriggerBFPA(String name, BeanFactory bf) throws Exception { DefaultBeanFactoryPointcutAdvisor pcadv = new DefaultBeanFactoryPointcutAdvisor(); pcadv.setBeanFactory(bf); pcadv.setAdviceBeanName(name); return JDKUtil.makeMap(pcadv, new DefaultBeanFactoryPointcutAdvisor()); }
Example #7
Source File: MulCommonBaseServiceParser.java From zxl with Apache License 2.0 | 5 votes |
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(); }
Example #8
Source File: SpringUtil.java From marshalsec with MIT License | 4 votes |
public static Object makeBeanFactoryTriggerBFPA ( UtilFactory uf, String name, BeanFactory bf ) throws Exception { DefaultBeanFactoryPointcutAdvisor pcadv = new DefaultBeanFactoryPointcutAdvisor(); pcadv.setBeanFactory(bf); pcadv.setAdviceBeanName(name); return uf.makeEqualsTrigger(pcadv, new DefaultBeanFactoryPointcutAdvisor()); }