Hello all.

I'm new to writing AOP code and have only used it for common uses like
transactions (in spring).  Please forgive me if I mess up the AOP terms, but
feel free to correct me. ;-)

Now I'm trying to solve an issues and I wanted to see if you guys have any
advice about if I'm on the right track, "this is already done with lib X",
...  (aside: I use maven / eclipse for the projects)

Background for the problem I'm trying to solve:
I am trying to put in some AOP code that will intercept calls to
HTTPSession.setAttribute(...).  Using this we will be able to verify that
any code being put into session is serializable.  Also, for any object that
implments HTTPSession, we'll trap the state of the object being set (using
HashcodeBuilder to generate a hash), and then at the end of the test verify
the the object in our mock session has not changed (has the same hashcode).
In this way we are hoping to be able to verify if an application is
clusterable without a tedious class by class inspection.

Here are the issues that I currently have:
1) I'm a little confused on what code should be "woven" - the creating of a
mock HTTPSession will only happen in testing code (src/test/java) while the
*calls* to setAttribute(..) that I care about will only happen in prod code
(src/main/java)

2) I only want to add this weaving for the tests, I don't want these checks
making it into code running in production or for the project to have a
non-test dependency on this code

3) I think that I need to add a joinpoint (pointcut ?) to an "after return"
on my @Test methods in order to check the state of the session.  Most of the
examples are done using method name matching.  Can I mix a pattern match
(public void test*) and an annotation, or is that 2 seperate join points?
http://www.eclipse.org/aspectj/doc/released/adk15notebook/annotations-pointcuts-and-advice.html

4) in order to check the state of the mock session at the end of the test,
I think that I will need to keep a reference to them in the advice.  Is this
normally done or is there something wrong with this approach?  Would it need
to be a static member variable of the advice (I'm not clear of the lifecycle
/ state of the advice yet)

Thanks for your time in even reading this far. ;-)  Any help would be
wonderful.

Thanks for your time,
Jim
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to