0 Replies Latest reply: Aug 13, 2013 10:10 AM by vikram04g RSS

    AOP JoinPoint not getting executed

    vikram04g

      The spring configuration that I have is

      <beans xmlns="http://www.springframework.org/schema/beans"

        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"

        xsi:schemaLocation="http://www.springframework.org/schema/beans

        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

        http://www.springframework.org/schema/aop

        http://www.springframework.org/schema/aop/spring-aop-3.1.xsd ">

       

       

        <aop:aspectj-autoproxy />

       

       

        <bean id="addCarrierService" class="com.service.AddCarrierService" />

       

       

        <!-- Aspect -->

        <bean id="authorizeBeforeAspect" class="com.custom.AuthorizeBeforeAspect" />

       

       

        <aop:config>

       

       

        <aop:aspect id="aspectLoggging" ref="authorizeBeforeAspect">

       

       

        <!-- @Before -->

        <aop:pointcut id="pointCutBefore" expression="execution(* com.service.*.*(..))" />

       

       

        <aop:before method="secureBefore" pointcut-ref="pointCutBefore" />

       

       

        </aop:aspect>

       

       

        </aop:config>

      </beans>

      And the join point class is

      package com.custom;

       

       

      import org.aspectj.lang.JoinPoint;

      import org.aspectj.lang.annotation.Aspect;

      import org.springframework.security.core.context.SecurityContextHolder;

      import org.springframework.stereotype.Component;

       

       

      @Component

      @Aspect

      public class AuthorizeBeforeAspect {

       

       

       

        public void secureBefore(JoinPoint joinPoint) {

        System.out.println("Inside AuthorizeBeforeAspect.secureBefore() method");

        if (SecurityContextHolder.getContext().getAuthentication().getPrincipal() != null)

        {

        DEPUser user = (DEPUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();

       

       

        }

        }

      }

      AuthorizeBeforeAspect .java class does not get executed at all. Not sure where am I going wrong?