Announcement Announcement Module
Collapse
No announcement yet.
AfterReturning advice with generic collection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AfterReturning advice with generic collection

    Hi,

    I'm trying to write an Aspect that proxies all method implementation of the following interface:

    Code:
    public interface ContentConverter<T> {
    	
    	public T convert(LifecycleContext<AbstractRequest> context, byte[] content) throws ProcessingException;
    
    }
    So I've written an aspect that declares the pointcut:

    Code:
    @Aspect
    @Component
    public class ConnectorLifecyclePointcuts {
        
    @Pointcut(value = "execution(java.util.Collection<com.example.HarvestedDocument+>+ com.example.ContentConverter.convert(..))")
        public void contentConversion() {}
    
    }
    And I've written an aspect that declares the advice:

    Code:
    @AfterReturning(pointcut = "com.example.ConnectorLifecyclePointcuts.contentConversion()", returning = "documents")
        public void setNumberOfRetrievedDocuments(Collection<HarvestedDocument> documents) {
    	getStatsCollector().setNumberOfRetrievedDocuments(documents.size());
        }
    This doesn't seem to work. But if I remove the generic declaration of the Collection in the setNumberOfRetrievedDocuments method, it does work. That is - when I write the following advice:

    Code:
    @AfterReturning(pointcut = "com.example.ConnectorLifecyclePointcuts.contentConversion()", returning = "documents")
        public void setNumberOfRetrievedDocuments(Collection documents) {
    	getStatsCollector().setNumberOfRetrievedDocuments(documents.size());
        }
    the advice is called as expected. What am I missing here?

    I'm using Spring 3.0.5.

    Thanks!
Working...
X