KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > bank > BankBean21


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.ejb3.test.bank;
23
24 import java.rmi.*;
25 import java.sql.Connection JavaDoc;
26
27 import javax.naming.*;
28 import javax.ejb.Init JavaDoc;
29 import javax.ejb.SessionContext JavaDoc;
30 import javax.sql.DataSource JavaDoc;
31
32 import org.jboss.logging.Logger;
33
34 /**
35  * @see <related>
36  * @author $Author: starksm $
37  * @version $Revision: 37459 $
38  */

39 public class BankBean21 implements javax.ejb.SessionBean JavaDoc
40 {
41    private static final Logger log = Logger.getLogger(BankBean21.class);
42    
43    public DataSource JavaDoc customerDb;
44    
45    static final String JavaDoc ID = "java:comp/env/id";
46
47    String JavaDoc id;
48
49    String JavaDoc customerId = "defaultId";
50
51    static long nextAccountId = System.currentTimeMillis();
52
53    static long nextCustomerId = System.currentTimeMillis();
54    
55    String JavaDoc initialized = "";
56    
57    private String JavaDoc activated = "";
58
59    public String JavaDoc getId()
60    {
61       return id;
62    }
63
64    public String JavaDoc createAccountId(Customer customer) throws RemoteException
65    {
66       return getId() + "." + customer.getName() + "." + (nextAccountId++);
67    }
68
69    public String JavaDoc createCustomerId()
70    {
71       return getId() + "." + (nextCustomerId++);
72    }
73
74    public void storeCustomerId(String JavaDoc customerId)
75    {
76       this.customerId = customerId;
77    }
78
79    public String JavaDoc retrieveCustomerId()
80    {
81       return customerId;
82    }
83    
84    public String JavaDoc interceptCustomerId(String JavaDoc customerId)
85    {
86       return customerId;
87    }
88    
89    public void testResource() throws Exception JavaDoc
90    {
91       if (customerDb == null) throw new Exception JavaDoc("customerDb resource not set");
92       Connection JavaDoc connection = customerDb.getConnection();
93       connection.close();
94    }
95    
96    public void remove()
97    {
98       
99    }
100    
101    @Init JavaDoc
102    public void annotatedInit()
103    {
104       initialized += "YES";
105    }
106    
107    public void init()
108    {
109       initialized += "YES";
110    }
111    
112    public String JavaDoc isInitialized()
113    {
114       return initialized;
115    }
116    
117    public String JavaDoc isActivated()
118    {
119       return activated;
120    }
121    
122    public void ejbCreate()
123    {
124       activated += "_CREATED";
125    }
126    
127    public void ejbActivate()
128    {
129       activated += "_ACTIVATED";
130    }
131    
132    public void ejbPassivate()
133    {
134       
135    }
136    
137    public void ejbRemove()
138    {
139       
140    }
141    
142    public void setSessionContext(SessionContext JavaDoc context)
143    {
144       
145    }
146 }
147
148 /*
149  * $Id: BankBean21.java 37459 2005-10-30 00:04:02Z starksm $ Currently locked
150  * by:$Locker$ Revision: $Log$
151  * by:$Locker: $ Revision: Revision 1.2 2005/10/30 00:06:46 starksm
152  * by:$Locker: $ Revision: Update the jboss LGPL headers
153  * by:$Locker: $ Revision:
154  * by:$Locker$ Revision: Revision 1.1 2005/06/02 23:25:14 bdecoste
155  * by:$Locker$ Revision: ejb3 jboss.xml support
156  * by:$Locker$ Revision:
157  * by:$Locker$ Revision: Revision 1.8 2005/05/26 02:24:09 bdecoste
158  * by:$Locker$ Revision: support for @Init
159  * by:$Locker$ Revision:
160  * by:$Locker$ Revision: Revision 1.7 2005/05/25 18:57:19 bdecoste
161  * by:$Locker$ Revision: added support for @Remove and @Exclude
162  * by:$Locker$ Revision:
163  * by:$Locker$ Revision: Revision 1.6 2005/05/17 22:37:42 bdecoste
164  * by:$Locker$ Revision: remove ejb2.1 rules
165  * by:$Locker$ Revision:
166  * by:$Locker$ Revision: Revision 1.5 2005/05/14 20:54:02 bdecoste
167  * by:$Locker$ Revision: added ejb3 dd support for Resource
168  * by:$Locker$ Revision:
169  * by:$Locker$ Revision: Revision 1.4 2005/05/12 20:31:46 bdecoste
170  * by:$Locker$ Revision: added ejb3 dd support for injection, callbacks, EJB
171  * by:$Locker$ Revision:
172  * by:$Locker$ Revision: Revision 1.3 2005/05/12 01:46:06 bdecoste
173  * by:$Locker$ Revision: added ejb3 dd support for RunAs and Inject
174  * by:$Locker$ Revision:
175  * by:$Locker$ Revision: Revision 1.2 2005/05/03 23:51:01 bdecoste
176  * by:$Locker$ Revision: fixed formatting
177  * by:$Locker$ Revision: Revision 1.1 2005/05/03
178  * 20:35:11 bdecoste test for ejb3 deployment descriptors Revision 1.5
179  * 2003/08/27 04:32:49 patriot1burke 4.0 rollback to 3.2 Revision 1.3 2002/02/15
180  * 06:15:50 user57 o replaced most System.out usage with Log4j. should really
181  * introduce some base classes to make this mess more maintainable... Revision
182  * 1.2 2001/01/07 23:14:34 peter Trying to get JAAS to work within test suite.
183  * Revision 1.1.1.1 2000/06/21 15:52:37 oberg Initial import of jBoss test. This
184  * module contains CTS tests, some simple examples, and small bean suites.
185  */

186
Popular Tags