Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Multiple Method Introductions: patterns?

Hi Jeff,

Do you have a common interface that all of the classes
(CIncludeTransformer, DatabaseReader, FragmentExtractorGenerator)
implement? And does such interface provide access to 
inputSource field? If so, you can do soemthing like:

privileged public aspect CachingAspect {
    /* assuming your classes implement InputSourceProvider 
       that contain a method "getInputSource()" */

    public interface Validator extends InputSourceProvider {
        public void generateValidity();
    }

    declare parents:
        (org.apache.cocoon.transformation.CIncludeTransformer || 
         org.apache.cocoon.reading.DatabaseReader || 
         org.apache.cocoon.generation.FragmentExtractorGenerator) 
        implements Validator;

    public Validator.generateValidity() {
        if (this.getInputSource() == null)
            return null;
        return this.getInputSource().getValidity();
    }
}

-Ramnivas

--- daltonj@xxxxxxxxx wrote:
> I am doing method introductions on a large scale while refactoring
> Apache
> Cocoon.  What I have run into is this, I have used AspectJ to extend
> a large
> number of classes to implement an interface
> (CacheableProcessingComponenent).  .. so for example:
> 
> privileged public aspect CachingAspect {
> // This works, clearly.
> declare parents:
> (org.apache.cocoon.transformation.CIncludeTransformer || 
> org.apache.cocoon.reading.DatabaseReader || 
> org.apache.cocoon.generation.FragmentExtractorGenerator) implements 
> CacheableProcessingComponent;
> 
> // This requires introducing two methods, one of which is below.  
> What I
> // would like to do is this:
> 
> public SourceValidity 
>
(org.apache.cocoon.transformation.CIncludeTransformer||org.apache.cocoon.reading
>
.DatabaseReader||org.apache.cocoon.generation.FragmentExtractorGenerator).genera
> teValidity() {
>   if (this.inputSource == null)
>     return null;
>   return this.inputSource.getValidity();
> }
> }
> 
> I have a large classes that use this method that I want to insert
> using this
> one introduction. What is the best way to accomplish the above?
> I have seen some simple wild-card matching in Ramnivas's book, but I
> have
> not see anything like what I am trying to do.  I have not seen any
> complicated examples that would relate to the above.
> 
> Suggestions?
> 
> Thanks.
> 
> - Jeff
> 
> 
> 
> 
> -------------------------------------------------
> This mail sent through IMP: http://horde.org/imp/
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html


Back to the top