Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Exception Handling

Hi,

Some comments

> void around() : call(* *.*(..)) {
>         try {
>             proceed();
>         } catch (Exception e) {
>             //Get Interface from Sping Context and Run It
>             //business action or view , etc
>         }
> }

this would make your code very very slow I imagine, as every single
method invocation will be intercepted.  I wouldn't recommend this.
ideally you would at least scope it by a subset of packages (instead
of 'all packages') - to limit the advice application.

> 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
>         }
> }

They would all be listed in just one place though... but as I say,
around...call() would be  very expensive.

> 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?

There is no 'before throwing' - if by that you mean at the point in
time where we are *about* to throw an exception but haven't yet done
it?  We could add a join point at this time during execution but
(surprisingly?) no one has asked for it before.

(The other construct we have related to exceptions is handler() but
I'm guessing that isn't what you need as that only applies to catch
blocks that already exist.)

> 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?

I feel like people have spent time thinking about this kind of problem
before, but I can't find a good link to give you right now.  Did you
try searching the mailing list archives?
http://www.eclipse.org/aspectj/userlists.php

cheers
Andy


Back to the top