Announcement Announcement Module
No announcement yet.
Ordering advice with @AspjectJ Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ordering advice with @AspjectJ

    I have a situation where I have 2 annotations applied to a DAO method. Each annotation has a specific aspect tied to it. One aspect for @FilterMe takes the resulting list of getMyObjects and returns a subset of that list depending on some real-time information. The @Cacheable aspect adds the resulting list to the cache and will use the cache if the list is currently valid. That's implemented through an Around advice..

    See below.

    List getMyObjects() { //do something }
    And 2 Aspects written for each annotation

    @Cacheable(Around advice)
    @Around(value = "within(com.client.cwp..*) && @annotation(com.client.cwp.component.caching.annotation.Cacheable)",
                argNames = "jp")
    public Object lookupCacheObjects(ProceedingJoinPoint jp) throws Throwable { }
    @AfterReturning(value = "within(com.client.cwp.component.content.dao..*) && @annotation(com.client.cwp.component.content.annotation.FilterMe)",
                argNames = "jp, contentList", returning = "contentList")
        public void personlizeContent(JoinPoint jp, List<ContentTO> contentList) { //Filter }
    My problem is that I always need the @Cacheable advice to fire first. In other words, I want the cache to return the FULL unfiltered list of content objects and THEN the @FilterMe aspect will filter the cached listings. What's happening is that my cache is returning the cached set of data the 2nd call regardless of any filtering going on in the @FilterMe. I think I need to guarantee that the cache always returns first, THEN the list is filtered.

    Have people run into this type of situation before?

  • #2
    Doing a little tracing, it seems the first call to getMyObjects() executes both aspects: the caching aspect and the filtering aspect. The subsequent calls only the caching aspect is called (the around advice) and the filtering aspect (after returning advice) is not called at all.

    Could this possibly be because in the case where the caching aspect is called and we have a cache hit, I'm not calling jp.proceed() so no other aspects will be executed?
    Last edited by GrantGochnauer; Sep 8th, 2008, 06:19 PM.