[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [ajdt-dev] Advice, raising different exceptions depending on 'pointcut'
|
you can do this
void around():execution( void *.setData(..)){
try{
proceed();
}catch(Throwable raisedExc){
throw new ConcernRuntimeException(raisedExc)
}
}
p.s you can only do this if ConcernRuntimeException is a RuntimeException
On 29/03/06, Marco Mistroni <mmistroni@xxxxxxxxx> wrote:
> Hello all,
> i have following usecase..
> I need to intercept all calls to the method setOwner for all ejbs in
> package com.myapp.ejbs.
> If the owner does not satisfy a certain condition, i need to raise an
> exception.
> the challenge here is that the exception type to be raised must be the same
> exception that
> the intercepted pointcut is catching.
> Now, i posted some time ago here about raising exception from aspects, and
> after that i have
> created a ConcernRuntimeException to be raised if my advice raises some
> exceptions.
> THis exception wraps the original exception so that the calling object will
> be able to handle the exception properly.
>
> But in this case, my pointcut will intercept methods of different EJBs,
> which raise potentially
> different exceptions..
> I have some constraints for NOT to change so that all ejbs intercepted
> methods raise exactly the same
> exception.
>
> I was wondering if, instead, i use static information from the pointcut to
> get the Exception raised by
> the intercepted method..
> i saw something named CatchClauseSignature... i was wondering if it could
> be useful.....
>
> here's sample of intercepted methods
>
> EJBX {
>
> public void setData(XData data) throws XException {
> ....
> }
> }
>
> EJBY {
>
> public void setData(YData data) throws YException {
> ....
> }
> }
>
>
> i was wondering, thus, if i use the CatchClauseSignature, i could
> then put following code
>
> Exception raisedExc =
> thisJoinPoint.getSignature().getCatchClauseSignature().getParameterType();
>
> throw new ConcernRuntimeException(raisedExc)
>
> so i can raise a ConcernRuntimeException that could wrap XExceptiopn and
> YException...
>
> wil this work?
>
> thanx in advance and regards for you comments
>
> marco
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> ajdt-dev mailing list
> ajdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/ajdt-dev
>
>
>