[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] How best to code instance-based aspects?
|
(First off, "hi" to Ron from an old friend ...)
My question relates to the runtime-control of aspects. Specifically, I am
trying to watch the data going over a number of java.net.Socket objects.
Since the I/O methods won't be called on the socket objects directly, but
on their associated I/O streams, a pointcut on the socket will only be able
to match when the I/O stream reference is retrieved. However, matching the
I/O stream class is too broad, as it applies to non-socket streams as well.
I need a way to retain the historic fact that a stream has been acquired
from a socket.
One way would be to watch the getters for the streams on the socket. When
they're called, I would 'tag' the returned stream object with an inter-type
field and then watch it in a second pointcut. That seems awfully clumsy and
would only work if I wanted to watch every socket.
Much rather, I'd like to be able to control at runtime who gets watched,
along the lines of:
Socket s;
SocketLoggerAspect sla = new SocketLoggerAspect ();
sla.watch (s);
...
sla.close ();
What patterns would support that kind of instance-dependent flexibility?
Thanks for bearing with me
-- Joel
Joel Roth-Nater <rothnj@xxxxxxxxxxxxxxxx>
Sr. Software Engineer, R & D
Lakeview Technology, Burlington MA
ph 781-744-6921 / fx 781-744-6805
[ save the whales :: feed the hungry :: free the mallocs ]