Announcement Announcement Module
No announcement yet.
Exception Handling and annidated methods Page Title Module
Move Remove Collapse
Conversation Detail Module
  • 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;


    //In real case, in this method there are a called method
    that thows Excetion()
    public void doExecution(Forward forward) {
    try {
    } 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"
    <aopointcut id="stateMachinePointcut" expression="execution(* chine..*(..))
    || execution(**(..))"/>
    <aop:after-throwing pointcut-ref="stateMachinePointcut"
    throwing="exception" method="recoveryStateMachineException" />

    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

    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