Announcement Announcement Module
Collapse
No announcement yet.
Exception Handling and annidated methods Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception Handling and annidated methods

    Hi at all that read this thread.

    For my project I have a class that implements an interface like this:
    -------------------------------------
    public interface PerformedAction {

    public void doExecution(Forward forward);

    }

    An typical implementing class is like this:

    ----------------------------------------

    public class InitStateAction extends GenericStateAction implements PerformedAction {
    private Logger log = Logger.getLogger(getClass());
    private TransactionAccessDAO transactionDao = null;

    public void setTransactionDao(TransactionAccessDAO transactionDao) {
    this.transactionDao = transactionDao;
    }

    //Test method for Throws advice
    private void g(){
    Integer i = null;

    i.toString();

    //In real case, in this method there are a called method
    that thows Excetion()
    }
    public void doExecution(Forward forward) {
    try {
    g();
    transactionDao.updateTransactionForInitRunning
    (theForward.getTransactionId(),forward.getData());
    forward.setEvent
    (StateMachineConstants.CHARGING_STATE);
    } catch (SQLException e) {
    log.debug("Exception during initialization: ");
    }catch(Exception e){
    System.out.println("Test message");
    }
    }

    }
    ---------------------------------------------------------
    The configuration xml Spring document is:

    <aop:config proxy-target-class="true">
    <aop:aspect id="stateMachineExceptionAspect"
    ref="recoveryStateMachineException">
    <aopointcut id="stateMachinePointcut" expression="execution(*
    com.ericsson.sm.recurrent.monthly.charging.statema chine..*(..))
    || execution(* com.ericsson.sm.recurrent.monthly.vo..*(..))"/>
    <aop:after-throwing pointcut-ref="stateMachinePointcut"
    throwing="exception" method="recoveryStateMachineException" />
    </aop:config>

    So, when the method <<doExecution>> it was executed never advice act to recover the exception, infact in the code there is a 'catch' that don't transmit over the exception generated in the method 'g()'.

    I want to advise all the exception rise in this method but I don't modify the interface that my class implements. Someone of us, know how configurate AOP to see also the exception rised internally of all method of my class?

    Maybe I have to modify the pointcut? Notice that I have more class like this.


    Thank for the answer!!

    Samuele Pretini

  • #2
    Resolved....

    I have generated in the Exception catch a new personalized RuntimeException, and I throw it. In this mode the pointcut match all the exception rised in my classes.

    Thanks for the readers.

    Samuele Pretini

    Comment

    Working...
    X