Java Code Examples for org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor

Following code examples demonstrate how to use org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisorfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisorand various code implementation of this class.

	public PointcutAdvisor loggingAdvisor() {
		AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
		String expression = "!execution(* com.batches."+ System.getProperty(Constants.BATCH_NAME.getValue())+".config.*.*(..)) && execution (* com.batches."+ System.getProperty(Constants.BATCH_NAME.getValue())+"..*.*(..))";
		advisor.setExpression(expression);
		advisor.setAdvice(new LoggingAspect());
		return advisor;
	} 


    public AspectJExpressionPointcutAdvisor bclOracleCloseConnectionAdvice() {
        AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
        advisor.setExpression("execution (* java.sql.Connection.close(..))");
        advisor.setAdvice((MethodBeforeAdvice) (method, args, target) -> {
            if (method.getName().equals("close")) {
                log.info("Doing oracle vpd cleanup thing.");
                final PreparedStatement stmt = (Connection.class.cast(target)).prepareStatement("call PKG_VPD_CTX.CLEAR_CLIENT_IDENTIFIER()");
                stmt.execute();
                stmt.close();
            }
        });

        return advisor;
    } 

    public AspectJExpressionPointcutAdvisor loggerAopPointcutAdvisor() {
        AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
        advisor.setExpression(pointcut);
        advisor.setAdvice(loggerAdvice);
        return advisor;
    } 

    public AspectJExpressionPointcutAdvisor aspectJExpressionPointcutAdvisor(){
        AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
        advisor.setExpression("execution(* com.power.spring.lesson8.xmlLikedTransaction.service.*.*(..)) ");
        advisor.setAdvice(transactionInterceptor());
        return advisor;
    } 

    public AspectJExpressionPointcutAdvisor pointcutAdvisor(TransactionInterceptor transactionInterceptor){
        AspectJExpressionPointcutAdvisor pointcutAdvisor = new AspectJExpressionPointcutAdvisor();
        pointcutAdvisor.setAdvice(transactionInterceptor); 
        pointcutAdvisor.setExpression("execution(* com.spring.service..*Impl.*(..))");
        return pointcutAdvisor;
    } 

  private void createObject() {
    this.advisor = new AspectJExpressionPointcutAdvisor();
    advisor.setExpression("@annotation(" + ModuleRedefinition.class.getName() + ")");

    ModuleRedefinitionAspectAdvice advice = new ModuleRedefinitionAspectAdvice(moduleContextManager,
        moduleContextService);
    advisor.setAdvice(advice);
  } 

    public Advisor advisor(){
        AspectJExpressionPointcutAdvisor pointcutAdvisor = new AspectJExpressionPointcutAdvisor();
        pointcutAdvisor.setAdvice(new SystemLogInterceptor());
        pointcutAdvisor.setExpression("@annotation(com.liveeasy.log.annotation.SystemLog)");
        return pointcutAdvisor;
    } 

    public AspectJExpressionPointcutAdvisor actuatorsPointcutAdvisor(){
        AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
        advisor.setExpression("execution (* net.easysmarthouse.provider.device.actuator.ActuatorsModule.changeState(..)))");
        advisor.setAdvice(new ActuatorModuleLoggingInterceptor());
        return advisor;
    } 

    public AspectJExpressionPointcutAdvisor signalingPointcutAdvisor(){
        AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
        advisor.setExpression("execution (* net.easysmarthouse.provider.device.alarm.SignalingModule.setEnabled(..)))");
        advisor.setAdvice(new SignalingModuleLoggingInterceptor());
        return advisor;
    } 

    public AspectJExpressionPointcutAdvisor triggersPointcutAdvisor(){
        AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor();
        advisor.setExpression("execution (* net.easysmarthouse.provider.device.trigger.TriggerModule.setEnabled(..)))");
        advisor.setAdvice(new TriggerModuleLoggingInterceptor());
        return advisor;
    } 

Advertisement
Javadoc
Spring AOP Advisor that can be used for any AspectJ pointcut expression. @author Rob Harrop @since 2

.0

Read More
Advertisement