KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > enterprise > lottery_annotation_ejb_stateful > LotteryBean


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package enterprise.lottery_annotation_ejb_stateful;
24
25
26 import javax.ejb.EJB JavaDoc;
27 import javax.ejb.Stateful JavaDoc;
28
29 import enterprise.lottery_annotation_ejb_stateless.Date;
30
31
32 @Stateful JavaDoc
33 public class LotteryBean implements Lottery {
34
35     public String JavaDoc getName() {
36         return name;
37     }
38
39     public String JavaDoc getNumber() {
40         return number;
41     }
42
43     public String JavaDoc getDate() {
44         return date.today();
45     }
46
47     public void select(int number) {
48         if( (number > -1) && (number < 10) ) {
49             this.number = this.number + SPACE +
50                 java.lang.Integer.toString(number);
51     }
52     }
53
54     public void setName(String JavaDoc name) {
55     this.name = name;
56     }
57
58
59     //Dependency injection to get an instance of the Date EJB.
60
@EJB JavaDoc(name="Date")
61     private Date date;
62
63     private String JavaDoc name = "Super Lotto";
64     private String JavaDoc number = "";
65     private static final String JavaDoc SPACE = " ";
66 }
67
Popular Tags