Announcement Announcement Module
Collapse
No announcement yet.
Aspect not recognized Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Aspect not recognized

    I read a couple of parent/child application context related posts but didnt really understand the solution.

    Secondly I do not have a Spring MVC project, rather I am exposing the service methods as Web Services using Java EE @Webservice annotations.

    I have a simple Logging Aspect Class to log all public methods as follows:

    Code:
    @Aspect
    @Component
    public class RvlxLoggingAspect
    {
    	private static final Logger LOG = Logger.getLogger(RvlxLoggingAspect.class);
    
    	@Pointcut("execution(public * *(..))")
    	private void loggingOperation() {}
    	
    	@Before("loggingOperation()")
    	public void logJoinPoint(JoinPoint joinPoint) {
    		System.out.println("Aspect: Before calling " + joinPoint.getSignature().getName());
    	}
    
    }
    Also I have 2 context files - applicationContext.xml and applicationContextDao.xml files that are loaded in web.xml as follows:

    Code:
    <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml
            			/WEB-INF/applicationContextDao.xml
            </param-value>
        </context-param>
       
        <listener>
        	<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

    I read in a previous post that the proxies generated do not carry the target annotations (which means @WebService would have been dropped in proxy classes). But what about logging the DAO classes?

    I am currently UNIT-Testing this app using AbstractDependencyInjectionSpringContextTests, so is there any alternative way of testing AOP?

  • #2
    I missed explaining the issue above:

    For the above example, the Logging aspect is not being recognized, hence loaded/weaved and applied to the regular execution of the application.
    Let me know what's missing?

    Comment


    • #3
      It is assumed that your aspect is loaded into the context and processed because it is marked by @Component, right? Did you define corresponding <context:component-scan base-package="xxx"/> element at the XML configuration?

      Comment


      • #4
        Yes I do have all the necessities in the applicationContext.xml file

        Code:
        <context:annotation-config />
        <context:component-scan base-package="com.company.component.service" />
        <aop:aspectj-autoproxy />

        Comment


        • #5
          Post complete small example that illustrates your problem here.

          Comment

          Working...
          X