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

  • Spring Exception Handling

    Hi all ,

    I ahve the following requirement. I need to be able to configure an exception and if the particular exception is caught I need the handler to be invoked.

    Is this possible in Spring

    -Thanks,

  • #2
    you can create your own set of Exceptions and throw them
    and handle in some Action/Controller

    something like this

    Code:
    public List<Proveedor> getAllProveedoresDAO()throws MyGlobalException{
    	List<Proveedor> mylist = new ArrayList<Proveedor>();
    	try{
    		mylist = (List) getHibernateTemplate().find("FROM Proveedor p WHERE p.idProveedor!='100000' ");			
    		if(mylist.isEmpty())
    			throw new MyListEmptyException();
    	}
    	catch(DataAccessException dae){
    		logger.info("DataAccessException"+dae.getMessage());
    		throw new MyGlobalException();
    	}	
    	return mylist;
    }
    am i right?

    regards

    Comment


    • #3
      Hi,

      if you just want to caught an exception, you can wrap the call with an after-throwing advice.

      Have a look here if you want to go for Spring XML-AOP

      regards
      agim

      Comment


      • #4
        Thanks for ur reply. Can I achieve the same using Spring IOC instead of AOP?

        Comment


        • #5
          Hello,

          yes it is possible by using a proxyfactory bean with an afterthrwoing advice.
          Have a look here , after that you have to implement the afterthrowingadvice interface.

          Here is the documentation about that

          Best regards
          agim

          Comment


          • #6
            Originally posted by sreepriyar View Post
            Can I achieve the same using Spring IOC instead of AOP?
            I'm not entirely sure I understand the question.
            Last edited by karldmoore; Aug 29th, 2007, 12:54 PM.

            Comment

            Working...
            X