KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > deployment > annotations > impl > JApplicationException


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: JApplicationException.java 9 2006-02-19 18:53:32Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.deployment.annotations.impl;
27
28 import java.lang.annotation.Annotation JavaDoc;
29
30 import javax.ejb.ApplicationException JavaDoc;
31
32 /**
33  * Acts as an implementation of @{@link javax.ejb.ApplicationException} annotation.
34  * @author Florent Benoit
35  */

36 public class JApplicationException implements ApplicationException JavaDoc {
37
38     /**
39      * Container rollback the transaction ? if an exception is thrown.
40      */

41     private boolean rollback = false;
42
43     /**
44      * Build an object which represents &#64;{@link javax.ejb.ApplicationException} annotation.<br>
45      * Default value for rollback is false.
46      */

47     public JApplicationException() {
48         this(false);
49     }
50
51     /**
52      * Build an object which represents &#64;{@link javax.ejb.ApplicationException} annotation with a given boolean.<br>
53      * @param rollback true/false (false is a default value)
54      */

55     public JApplicationException(final boolean rollback) {
56         this.rollback = rollback;
57     }
58
59     /**
60      * @return the retainIfException value (true/false)
61      */

62     public boolean rollback() {
63         return rollback;
64     }
65
66     /**
67      * @return annotation type
68      */

69     public Class JavaDoc<? extends Annotation JavaDoc> annotationType() {
70         return ApplicationException JavaDoc.class;
71     }
72
73     /**
74      * @return string representation
75      */

76     @Override JavaDoc
77     public String JavaDoc toString() {
78         StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
79         // classname
80
sb.append(this.getClass().getName().substring(this.getClass().getPackage().getName().length() + 1));
81         // rollback
82
sb.append("[rollback=");
83         sb.append(rollback);
84
85         sb.append("]");
86         return sb.toString();
87     }
88 }
89
Popular Tags