[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Examining a destructive read in an aspect
|
I've been working on
intercepting the service() method invocation in a Sonic ESB container. I
had just started to write my before() advice when the bad news dawned on
me. Just about every ESB service() method starts
with the following...
public void service(XQServiceContext ctx) throws XQServiceException
{
XQEnvelope env =
null;
while
(ctx.hasNextIncoming())
{
env =
ctx.getNextIncoming();
if (env != null)
{
XQMessage msg = env.getMessage();
That call to
ctx.getNextIncoming() is a destructive read that returns a different XQEnvelope
every time it's called. The problem is that I need to evaluate the
contents of the message that comes from ctx.getNextIncoming() in my before()
advice. What that means is that the call to ctx.getNextIncoming() in the
service() method is not going to get the message, because the before() advice
already got it.
Now I'm wondering if
there's a way to put an aspect around ctx.getNextIncoming() to make it deliver
the message again. Or if I can somehow clone ctx so that I can read
the cloned message in before() and then read it from the
real XQServiceContext object in service(). XQServiceContext
doesn't offer any way to peek or browse, and it doesn't have a method to put a
message, either.
I would imagine I'm
not the first person to run into this kind of issue with AOP before.
I'm hoping that there's a pattern to address it.
Thanks,
Lee
Grey