KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > banknew > ejb > TransactionBean


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.test.banknew.ejb;
23
24 import java.util.Date JavaDoc;
25
26 import org.jboss.test.banknew.interfaces.TransactionData;
27 import org.jboss.test.banknew.interfaces.TransactionPK;
28 import org.jboss.test.util.ejb.EntitySupport;
29
30 /**
31  * The Entity bean represents a bank transaction
32  *
33  * @author Andreas Schaefer
34  * @version $Revision: 41581 $
35  *
36  * @ejb:bean name="bank/Transaction"
37  * display-name="Bank Transaction Entity"
38  * type="CMP"
39  * view-type="remote"
40  * jndi-name="ejb/bank/Transaction"
41  * schema="Transaction"
42  *
43  * @ejb:interface extends="javax.ejb.EJBObject"
44  *
45  * @ejb:home extends="javax.ejb.EJBHome"
46  *
47  * @ejb:pk extends="java.lang.Object"
48  *
49  * @ejb:transaction type="Required"
50  *
51  * @ejb:data-object extends="java.lang.Object"
52  *
53  * @ejb:finder signature="java.util.Collection findAll()"
54  * query="SELECT OBJECT(o) FROM Transaction AS o"
55  *
56  * @ejb:finder signature="java.util.Collection findByAccount( java.lang.String pAccountId )"
57  * query="SELECT OBJECT(o) FROM Transaction AS o WHERE o.acountId = ?1"
58  *
59  * @jboss:finder-query name="findByAccount"
60  * query="Account_Id = {0}"
61  * order="Date"
62  *
63  * @jboss:table-name table-name="New_Transaction"
64  *
65  * @jboss:create-table create="true"
66  *
67  * @jboss:remove-table remove="true"
68  */

69 public abstract class TransactionBean
70    extends EntitySupport
71 {
72    // Constants -----------------------------------------------------
73

74    // Attributes ----------------------------------------------------
75

76    // Static --------------------------------------------------------
77

78    private static int sId = 0;
79    
80    // Constructors --------------------------------------------------
81

82    // Public --------------------------------------------------------
83

84    /**
85     * @ejb:persistent-field
86     * @ejb:pk-field
87     *
88     * @jboss:column-name name="Id"
89     **/

90    abstract public String JavaDoc getId();
91    
92    abstract public void setId( String JavaDoc pId );
93    
94    /**
95     * @ejb:persistent-field
96     *
97     * @jboss:column-name name="Account_Id"
98     **/

99    abstract public String JavaDoc getAcountId();
100    
101    abstract public void setAcountId( String JavaDoc pAcountId );
102    
103    /**
104     * @ejb:persistent-field
105     *
106     * @jboss:column-name name="Type"
107     **/

108    abstract public int getType();
109    
110    abstract public void setType( int pType );
111    
112    /**
113     * @ejb:persistent-field
114     *
115     * @jboss:column-name name="Amount"
116     **/

117    abstract public float getAmount();
118    
119    abstract public void setAmount( float pAmount );
120    
121    /**
122     * @ejb:persistent-field
123     *
124     * @jboss:column-name name="Date"
125     **/

126    abstract public Date JavaDoc getDate();
127    
128    abstract public void setDate( Date JavaDoc pDate );
129    
130    /**
131     * @ejb:persistent-field
132     *
133     * @jboss:column-name name="Description"
134     **/

135    abstract public String JavaDoc getDescription();
136    
137    abstract public void setDescription( String JavaDoc pDescription );
138    
139    /**
140     * @ejb:interface-method view-type="remote"
141     **/

142    abstract public TransactionData getData();
143    
144    abstract public void setData( TransactionData pDate );
145    
146    // EntityHome implementation -------------------------------------
147

148    /**
149     * @ejb:create-method view-type="remote"
150     **/

151    public TransactionPK ejbCreate( String JavaDoc pAccountId, int pType, float pAmount, String JavaDoc pDescription ) {
152       setId( "Tx: " + ( sId++ ) );
153       setAcountId( pAccountId );
154       setType( pType );
155       setAmount( pAmount );
156       setDescription( pDescription );
157       setDate( new Date JavaDoc() );
158       
159       return null;
160    }
161    
162    public void ejbPostCreate( String JavaDoc pAccountId, int pType, float pAmount, String JavaDoc pDescription )
163    {
164    }
165    
166    /**
167     * @ejb:create-method view-type="remote"
168     **/

169    public TransactionPK ejbCreate( TransactionData pData ) {
170       setId( "Tx: " + ( sId++ ) );
171       pData.setDate( new Date JavaDoc() );
172       setData( pData );
173       
174       return null;
175    }
176    
177    public void ejbPostCreate( TransactionData pData )
178    {
179    }
180 }
181
182 /*
183  * $Id: TransactionBean.java 41581 2006-03-01 16:10:00Z adrian $
184  * Currently locked by:$Locker$
185  * Revision:
186  * $Log$
187  * Revision 1.4 2006/03/01 16:09:58 adrian
188  * Remove xdoclet from jca tests
189  *
190  * Revision 1.2.16.1 2005/10/29 05:04:35 starksm
191  * Update the LGPL header
192  *
193  * Revision 1.2 2002/05/06 00:07:37 danch
194  * Added ejbql query specs, schema names
195  *
196  * Revision 1.1 2002/05/04 01:08:25 schaefera
197  * Added new Stats classes (JMS related) to JSR-77 implemenation and added the
198  * bank-new test application but this does not work right now properly but
199  * it is not added to the default tests so I shouldn't bother someone.
200  *
201  * Revision 1.1.2.3 2002/04/30 01:21:23 schaefera
202  * Added some fixes to the marathon test and a windows script.
203  *
204  * Revision 1.1.2.2 2002/04/29 21:05:17 schaefera
205  * Added new marathon test suite using the new bank application
206  *
207  * Revision 1.1.2.1 2002/04/17 05:07:24 schaefera
208  * Redesigned the banknew example therefore to a create separation between
209  * the Entity Bean (CMP) and the Session Beans (Business Logic).
210  * The test cases are redesigned but not finished yet.
211  *
212  * Revision 1.1.2.2 2002/04/15 04:28:15 schaefera
213  * Minor fixes regarding to the JNDI names of the beans.
214  *
215  * Revision 1.1.2.1 2002/04/15 02:32:24 schaefera
216  * Add a new test version of the bank because the old did no use transactions
217  * and the new uses XDoclet 1.1.2 to generate the DDs and other Java classes.
218  * Also a marathon test is added. Please specify the jbosstest.duration for
219  * how long and the test.timeout (which must be longer than the duration) to
220  * run the test with run_tests.xml, tag marathon-test-and-report.
221  *
222  * Revision 1.4 2001/01/20 16:32:51 osh
223  * More cleanup to avoid verifier warnings.
224  *
225  * Revision 1.3 2001/01/07 23:14:34 peter
226  * Trying to get JAAS to work within test suite.
227  *
228  * Revision 1.2 2000/09/30 01:00:54 fleury
229  * Updated bank tests to work with new jBoss version
230  *
231  * Revision 1.1.1.1 2000/06/21 15:52:37 oberg
232  * Initial import of jBoss test. This module contains CTS tests, some simple examples, and small bean suites.
233  */

234
Popular Tags