[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] Exception Handling
|
Hi everyone
I am new at AspectJ and came to it because I want to implement an Exception Handling like this from Spring Rich Client.
http://spring-rich-c.sourceforge.net/1.0.0/spring-richclient-manual/reference/html/exception-handling.html
I was thinking about the ways to do It, and you tell me if it is possible and if I am going the right way.
The first thing is to soft the checked exceptions
like
declare soft : Exception : execution(* *.*(..));
So afterwards I shoud put an point cut on every application methods doing things like this?
void around() : call(* *.*(..)) {
try {
proceed();
} catch (Exception e) {
//Get Interface from Sping Context and Run It
//business action or view , etc
}
}
This was what I thought after some searchs but I am still thinking it is not right, or the better way. Mainly because I would have to put as many exceptions as I would need, like
void around() : call(* *.*(..)) {
try {
proceed();
} catch (SomeSQLExcep e) {
//Get Interface from Sping Context and Run It
//business action or view , etc
} catch (SomeHibernateExcep e) {
//Get Interface from Sping Context and Run It
//business action or view , etc
} catch (AnyExcep e) {
//Get Interface from Sping Context and Run It
//business action or view , etc
}
}
So I think it is not the best option.
Searching a little more I found a code that runs after an exception is thrown
after() throwing(SoftException t): scope() {
System.out.println("Logado pelo Aspecto - (Soft) ");
}
What would be the code that runs before it? How to intercept it?
I think If I could do something like this for example
before() throwing(SQLException t): scope() {
//Get from Spring and run
}
In the spring could be anything like showing a JSF message to the user or anything.
I think that only detailed exceptions could be managed like this right? If I put some generic Code like Exception, all the system would be intercepted and it is not the better move.
I am not really sure if I made myself clear and my doubts.
The first thing I would like to know if what I am trying to do is possible and if I am going in the right way?
Thanks a lot
Leonardo Moreira