KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > ce > auction > command > CommandHandlerBean


1 package org.hibernate.ce.auction.command;
2
3 import org.hibernate.ce.auction.persistence.HibernateUtil;
4
5
6 /**
7  * The implementation of a generic EJB command handler.
8  *
9  * @author Christian Bauer <christian@hibernate.org>
10  */

11 public class CommandHandlerBean {
12
13     public Command executeCommand(Command command)
14         throws CommandException {
15
16         try {
17             command.execute();
18         } catch (CommandException ex) {
19             // Actually, set the UserTransaction in JTA to rollback only.
20
// It is possible to not catch the exception and let the
21
// container set rollback when this method fails.
22
HibernateUtil.rollbackTransaction();
23             throw ex;
24         }
25         return command;
26     }
27 }
28
Popular Tags