KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateful > containermanaged > ejb2view > SimpleEjb2BeanBase


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: SimpleEjb2BeanBase.java 826 2006-07-10 13:05:42Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.ejb2view;
26
27 import java.rmi.RemoteException JavaDoc;
28
29 import javax.ejb.CreateException JavaDoc;
30
31 /**
32  * Implements the methods of the local, remote, local-home and remote-home
33  * interfaces.
34  * @author Gisele Pinheiro Souza
35  * @author Eduardo Studzinski Estima de Castro
36  */

37 public class SimpleEjb2BeanBase {
38
39     /**
40      * The bean code.
41      */

42     private int intCode;
43
44     /**
45      * The bean name.
46      */

47     private String JavaDoc strName;
48
49     /**
50      * Creates an instance of the bean with the default values.
51      * @throws CreateException if an error during the creation occurs.
52      * @throws RemoteException if a system level error occurs.
53      */

54     public void ejbCreate() throws CreateException JavaDoc, RemoteException JavaDoc {
55         this.intCode = SimpleEjb2.DEFAULT_CODE_REMOTE;
56         this.strName = SimpleEjb2.DEFAULT_NAME_REMOTE;
57     }
58
59     /**
60      * Creates an instance of the bean with the values in the parameters.
61      * @param code the bean code.
62      * @param name the bean name.
63      * @throws CreateException if an error during the creation occurs
64      * @throws RemoteException if a system level error occurs.
65      */

66     public void init(final int code, final String JavaDoc name) throws CreateException JavaDoc, RemoteException JavaDoc {
67         this.intCode = code;
68         this.strName = name;
69     }
70
71     /**
72      * Creates an instance of the bean with the default name and the code
73      * defined in the parameter.
74      * @param code the bean code.
75      * @throws CreateException if a creation error occurs.
76      */

77     void ejbCreate(final int code) throws CreateException JavaDoc {
78         this.intCode = code;
79         this.strName = SimpleEjb2Local.DEFAULT_NAME_LOCAL;
80     }
81
82     /**
83      * Creates an instance of the bean with the default code and the name
84      * defined in the parameter.
85      * @param name the bean name.
86      * @throws CreateException if a creation error occurs.
87      */

88     void init(final String JavaDoc name) throws CreateException JavaDoc {
89         this.intCode = SimpleEjb2Local.DEFAULT_CODE_LOCAL;
90         this.strName = name;
91     }
92
93     /**
94      * Returns the message in the parameter.
95      * @param message the message.
96      * @return the message.
97      * @throws RemoteException if a system level error occurs.
98      */

99     public String JavaDoc sayHello(final String JavaDoc message) throws RemoteException JavaDoc {
100         return message;
101     }
102
103     /**
104      * Gets the bean code.
105      * @return the code.
106      * @throws RemoteException if a system level error occurs.
107      */

108     public int getCode() throws RemoteException JavaDoc {
109         return intCode;
110     }
111
112     /**
113      * Sets the bean code.
114      * @param intCode the code.
115      * @throws RemoteException if a system level error occurs.
116      */

117     public void setCode(final int intCode) throws RemoteException JavaDoc {
118         this.intCode = intCode;
119     }
120
121     /**
122      * Gets the bean name.
123      * @return the bean name.
124      * @throws RemoteException if a system level error occurs.
125      */

126     public String JavaDoc getName() throws RemoteException JavaDoc {
127         return strName;
128     }
129
130     /**
131      * Sets the bean name.
132      * @param strName the bean name.
133      * @throws RemoteException if a system level error occurs.
134      */

135     public void setName(final String JavaDoc strName) throws RemoteException JavaDoc {
136         this.strName = strName;
137     }
138
139     /**
140      * Sets the bean values.
141      * @param code the bean code.
142      * @param name the bean name.
143      */

144     void setValues(final int code, final String JavaDoc name) {
145         this.intCode = code;
146         this.strName = name;
147     }
148
149     /**
150      * Gets the default message.
151      * @return the message.
152      */

153     String JavaDoc sayHello() {
154         return SimpleEjb2Local.DEFAULT_MESSAGE;
155     }
156
157     /**
158      * Gets the bean code.
159      * @return the code.
160      */

161     int getCodeLocal(){
162         return intCode;
163     }
164
165     /**
166      * Gets the bean name.
167      * @return the bean name.
168      */

169     String JavaDoc getNameLocal(){
170         return strName;
171     }
172
173 }
174
Popular Tags