KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateless > containermanaged > simpleentry > SLSBSimpleEnvEntryFieldInjection00


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: SLSBSimpleEnvEntryFieldInjection00.java 547 2006-05-30 13:50:43Z studzine $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.simpleentry;
26
27 import static org.objectweb.easybeans.tests.common.helper.ContextHelper.checkSimpleEntry;
28
29 import javax.annotation.Resource;
30 import javax.ejb.Remote JavaDoc;
31 import javax.ejb.SessionContext JavaDoc;
32 import javax.ejb.Stateless JavaDoc;
33
34 import org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry;
35
36 /**
37  * This bean is used to test injection of simple environment entries.
38  * @author Eduardo Studzinski Estima de Castro
39  * @author Gisele Pinheiro Souza
40  */

41 @Stateless JavaDoc(name="SLSBSimpleEnvEntryFieldInjection00")
42 @Remote JavaDoc({ItfSimpleEnvEntry.class})
43 public class SLSBSimpleEnvEntryFieldInjection00 implements ItfSimpleEnvEntry{
44
45     /**
46      * SessionContext.
47      */

48     @Resource
49     private SessionContext JavaDoc sessionContext;
50
51     /**
52      * The default value must be injected by the container.
53      */

54     @Resource(name = "str00")
55     private String JavaDoc strInjection;
56
57     /**
58      * The value will be injected by the container.
59      */

60     @Resource(name = "strWithDefaultValue")
61     private String JavaDoc strWithDefaultValue = ENTRY_STRING;
62
63     /**
64      * The default value must be injected by the container.
65      */

66     @Resource(name = "chr00")
67     private char chrInjection;
68
69     /**
70      * The default value must be injected by the container.
71      */

72     @Resource(name = "int00")
73     private int intInjection;
74
75     /**
76      * The default value must be injected by the container.
77      */

78     @Resource(name = "bol00")
79     private boolean bolInjection;
80
81     /**
82      * The default value must be injected by the container.
83      */

84     @Resource(name = "dbl00")
85     private double dblInjection;
86
87     /**
88      * The default value must be injected by the container.
89      */

90     @Resource(name = "bte00")
91     private byte bteInjection;
92
93     /**
94      * The default value must be injected by the container.
95      */

96     @Resource(name = "shr00")
97     private short shrInjection;
98
99     /**
100      * The default value must be injected by the container.
101      */

102     @Resource(name = "lng00")
103     private long lngInjection;
104
105     /**
106      * The default value must be injected by the container. The name must be generated by the container: class name/field name.
107      */

108     @Resource
109     private float fltInjection;
110
111     /**
112      * Checks if a String was correctly injected, if the session context can be
113      * used to access the entry and if the JNDI API can be used directly to
114      * access an environment entry. Also, check if a default value remains if an
115      * env-entry-value was not defined in the deployment descriptor. An
116      * IllegalStateException is thrown if fails.
117      */

118     public void checkString00() {
119         checkSimpleEntry(sessionContext, "str00", strInjection, ENTRY_STRING);
120
121         if (!ENTRY_STRING.equals(strWithDefaultValue)) {
122             throw new IllegalStateException JavaDoc("There is not a default value declared in the deployment descriptor, "
123                     + "so the container should not override the value specified in the variable declaration.");
124         }
125     }
126
127     /**
128      * @see org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry
129      */

130     @SuppressWarnings JavaDoc("boxing")
131     public void checkCharacter00() {
132         checkSimpleEntry(sessionContext, "chr00", chrInjection, ENTRY_CHARACTER);
133     }
134
135     /**
136      * @see org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry
137      */

138     @SuppressWarnings JavaDoc("boxing")
139     public void checkInteger00() {
140         checkSimpleEntry(sessionContext, "int00", intInjection, ENTRY_INTEGER);
141     }
142
143     /**
144      * @see org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry
145      */

146     @SuppressWarnings JavaDoc("boxing")
147     public void checkBoolean00() {
148         checkSimpleEntry(sessionContext, "bol00", bolInjection, ENTRY_BOOLEAN);
149     }
150
151     /**
152      * @see org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry
153      */

154     @SuppressWarnings JavaDoc("boxing")
155     public void checkDouble00() {
156         checkSimpleEntry(sessionContext, "dbl00", dblInjection, ENTRY_DOUBLE);
157     }
158
159     /**
160      * @see org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry
161      */

162     @SuppressWarnings JavaDoc("boxing")
163     public void checkByte00() {
164         checkSimpleEntry(sessionContext, "bte00", bteInjection, ENTRY_BYTE);
165
166     }
167
168     /**
169      * @see org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry
170      */

171     @SuppressWarnings JavaDoc("boxing")
172     public void checkShort00() {
173         checkSimpleEntry(sessionContext, "shr00", shrInjection, ENTRY_SHORT);
174     }
175
176     /**
177      * @see org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry
178      */

179     @SuppressWarnings JavaDoc("boxing")
180     public void checkLong00() {
181         checkSimpleEntry(sessionContext, "lng00", lngInjection, ENTRY_LONG);
182     }
183
184     /**
185      * @see org.objectweb.easybeans.tests.common.ejbs.base.ItfSimpleEnvEntry
186      */

187     @SuppressWarnings JavaDoc("boxing")
188     public void checkFloat00() {
189         checkSimpleEntry(sessionContext, this.getClass().getName().toString()+"/"+ "fltInjection", fltInjection, ENTRY_FLOAT);
190     }
191
192 }
193
Popular Tags