Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Finally block in advice

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[quote Irum Godil::on 1/24/2005 11:13 PM]
| Hi,
| I have a piece of code like this:
|
| try {
| ...
| }
| finally {
| ...
| }
|
| Basically, I would like to remove the finally code and move it into an advice. I am not sure how
can I capture this, first of all i.e. how to say execute the advice at the end of the try block.
Secondly, if I just add a piece of code starting with just "finally" with no "try" around it, i get
compiler errors there. Does anyone know what to do?
|
| thanks.
|
|
| 		
| ---------------------------------
| Do you Yahoo!?
|  The all-new My Yahoo! ? What will yours do?

As far as i get it this is a classical after advice. After advice is executed whatever happens
(after returning and after throwing). Let's consider the method:

method_to_be_adviced() {
	try {
		// code here
	} finaly {
		// finally code here
	}
}

refactored to:

method_to_be_adviced() {
	try {
		refactored_code();
	} finally {
		// finally code here
	}
}

and now introducing the after advice:

after(): pointcuthere() {
	// finally code here	
}

where pointcuthere() should capture refactored_code() joinpoint.

- --
:pope
[the_mindstorm]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFB9WkrTTDTje0R2dgRAkZtAJ9ZfPvzkx3sREpMJqpuyTd69KBd6wCfaLRN
4rMOPdWTpcx/sFjx2dxHBco=
=6CWF
-----END PGP SIGNATURE-----


Back to the top