Announcement Announcement Module
Collapse
No announcement yet.
Limiting the invocation of aspects to specific classes Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Limiting the invocation of aspects to specific classes

    Hi all.

    I'm currently trying my hand out at writing aspects which are applied only when the pointcut method is invoked from a specific class.

    For e.g. let's consider a sample pointcut like:
    Code:
    execution(* home.projects.withinaoptest.framework.MyChain.execute(..))
    There might be multiple situations in which this point cut will be satisfied but I need the aspect to be applied only when the `execute' method is invoked from within a given class. In simple terms, given multiple invocations of `execute' throughout the code, I need to filter out the aspect application part based on the package of the code which invokes the `execute' method.
    Code:
    package home.test.component;
    public class TestComponent {
      public void doIt() {
        MyChain chain = new MyChain();
        chain.execute();
      }
    }
    
    package home.test.realcomponent;
    public class RealComponent {
      public void doIt() {
        MyChain chain = new MyChain();
        chain.execute();
      }
    }
    Here I'd like the filtering to be done based on the package name of the class invoking MyChain's methods. I've tried a few things with the `within' advice but to no avail. Is there any way around this?

    Suggestions, ideas are welcome. Any sort of help is highly appreciated.

    -sasuke
Working...
X