J
Jeroen Budts
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
I have almost no knowledge about Aspect Oriented Programming. However i
know you can use it to execute code before a method is called and such.
Now i have the following piece of code which i will have to use a lot:
public static List getGames() throws Exception {
BusinessSession businessSession = new BusinessSession();
try {
businessSession.open();
List games = CreateGameHelper(businessSession).getGames();
businessSession.commit();
return games;
} catch (Exception e){
businessSession.rollback();
throw e;
}
}
short explanation: I have some components (which are in fact just
facades). Every component has some (static public) methods, to interact
with the business-layer. Every method is 'one unit of work', so it must
start a businessSession, do its stuff and commit the session, or in case
of an exception do a rollback.
No i'm wondering if it would be possible to extract the businessSession
stuff from all my methods and use aspects for this?
It should be something like:
basic method in a component:
public static List getGames() throws Exception {
List games = CreateGameHelper(businessSession).getGames();
}
an aspect which is executed before a method in component:
public void executeBeforeComponentMethod() {
BusinessSession businessSession = new BusinessSession();
businessSession.open();
}
one which is executed in case of a normal result of the componentmethod:
public void successfulComponentMethod() {
businessSession.commit();
}
and one which is executed in case of an exception:
public void exceptionInComponentMethod() {
businessSession.rollback();
throw e;
}
Is such a thing somehow possible?
(I'm developing with Eclipse 3.1M6)
Thx in advance!
Jeroen Budts
- --
<TeRanEX/>
--- e-mail: (e-mail address removed) - jid: (e-mail address removed)
--- blog: http://budts.be/weblog/ - cv: http://budts.be/jeroen/
--- projects: http://lightyear.be - pgp: 0x8B7B774A
_____________________________________
NO SoftwarePatents in Europe!
See an example: http://webshop.ffii.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCY3kSH04wF4t7d0oRAq2uAJ9skEnLF4enWmv/tqxLdyU28ep/dgCfZiaM
3HJg/RrOwCD0l076evjpkFM=
=RzCJ
-----END PGP SIGNATURE-----
Hash: SHA1
Hi,
I have almost no knowledge about Aspect Oriented Programming. However i
know you can use it to execute code before a method is called and such.
Now i have the following piece of code which i will have to use a lot:
public static List getGames() throws Exception {
BusinessSession businessSession = new BusinessSession();
try {
businessSession.open();
List games = CreateGameHelper(businessSession).getGames();
businessSession.commit();
return games;
} catch (Exception e){
businessSession.rollback();
throw e;
}
}
short explanation: I have some components (which are in fact just
facades). Every component has some (static public) methods, to interact
with the business-layer. Every method is 'one unit of work', so it must
start a businessSession, do its stuff and commit the session, or in case
of an exception do a rollback.
No i'm wondering if it would be possible to extract the businessSession
stuff from all my methods and use aspects for this?
It should be something like:
basic method in a component:
public static List getGames() throws Exception {
List games = CreateGameHelper(businessSession).getGames();
}
an aspect which is executed before a method in component:
public void executeBeforeComponentMethod() {
BusinessSession businessSession = new BusinessSession();
businessSession.open();
}
one which is executed in case of a normal result of the componentmethod:
public void successfulComponentMethod() {
businessSession.commit();
}
and one which is executed in case of an exception:
public void exceptionInComponentMethod() {
businessSession.rollback();
throw e;
}
Is such a thing somehow possible?
(I'm developing with Eclipse 3.1M6)
Thx in advance!
Jeroen Budts
- --
<TeRanEX/>
--- e-mail: (e-mail address removed) - jid: (e-mail address removed)
--- blog: http://budts.be/weblog/ - cv: http://budts.be/jeroen/
--- projects: http://lightyear.be - pgp: 0x8B7B774A
_____________________________________
NO SoftwarePatents in Europe!
See an example: http://webshop.ffii.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCY3kSH04wF4t7d0oRAq2uAJ9skEnLF4enWmv/tqxLdyU28ep/dgCfZiaM
3HJg/RrOwCD0l076evjpkFM=
=RzCJ
-----END PGP SIGNATURE-----