[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] How to apply an aspect for a subtype of a payload without an instanceof?

Hi,
  I am trying to find out a way to aspect a call only if the payload of the
passed message is of a certain type. Here is what I have:

@Pointcut(value = "execution(* com.xyz.MyService.submit(" +
         "com.xyz.MessageEnvelope)) &&" +
         "args(message)")
public void init(MessageEnvelope message) { }

@Before(value="init(message)", argsName = "message")
public void setValue(MessageEnvelope message) {
   Payload payload = message.getPayload();
   // -- Now if payload is of type say APayload then I want to do something
but 
   // -- If the payload is of type BPayload then skip.
}


So, I want to call setValue() only if message.getPayload() should be of a
certain type of the Payload interface in the above code. I do not want to
use an instanceof and seeking a way that setValue is only called if the
payload is of type say APayload --> Payload.

I hope was able to explain the problem articulate enough. Appreciate your
help,

-Ashish

--
View this message in context: http://aspectj.2085585.n4.nabble.com/How-to-apply-an-aspect-for-a-subtype-of-a-payload-without-an-instanceof-tp4170709p4170709.html
Sent from the AspectJ - users mailing list archive at Nabble.com.