Source Code Cross Referenced for MDBEjbRef.java in  » J2EE » ow2-easybeans » org » ow2 » easybeans » tests » common » ejbs » mdb » containermanaged » ejbref » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » ow2 easybeans » org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.ejbref 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * EasyBeans
003:         * Copyright (C) 2006 Bull S.A.S.
004:         * Contact: easybeans@ow2.org
005:         *
006:         * This library is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU Lesser General Public
008:         * License as published by the Free Software Foundation; either
009:         * version 2.1 of the License, or any later version.
010:         *
011:         * This library is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         * Lesser General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU Lesser General Public
017:         * License along with this library; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
019:         * USA
020:         *
021:         * --------------------------------------------------------------------------
022:         * $Id: MDBEjbRef.java 1970 2007-10-16 11:49:25Z benoitf $
023:         * --------------------------------------------------------------------------
024:         */package org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.ejbref;
025:
026:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.ON_MESSAGE;
027:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_INJECTION_FIELD;
028:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_INJECTION_METHOD;
029:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_RESOURCES_DECLARATION;
030:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.ANNOTATION_RESOURCE_DECLARATION;
031:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.OVERRIDE_INJECTION_FIELD;
032:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.OVERRIDE_INJECTION_METHOD;
033:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_INJECTION_FIELD;
034:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_INJECTION_METHOD;
035:        import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.XML_RESOURCE_DECLARATION;
036:        import static org.ow2.easybeans.tests.common.helper.ContextHelper.checkBeanRef;
037:
038:        import javax.annotation.Resource;
039:        import javax.ejb.ActivationConfigProperty;
040:        import javax.ejb.EJB;
041:        import javax.ejb.EJBs;
042:        import javax.ejb.MessageDriven;
043:        import javax.ejb.MessageDrivenContext;
044:        import javax.jms.Message;
045:        import javax.jms.MessageListener;
046:
047:        import org.ow2.easybeans.tests.common.ejbs.base.ItfOneMethod01;
048:        import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.BaseInsertOperation;
049:        import org.ow2.easybeans.tests.common.jms.JMSManager;
050:        import org.ow2.util.log.Log;
051:        import org.ow2.util.log.LogFactory;
052:
053:        /**
054:         * /** This bean is used to test the ejb references in the environement.
055:         * Operations:<li>Declaration using annotation.</li> <li>Declaration using XML.</li>
056:         * <li>Injection in a field using annotation.</li> <li>Injection in a method
057:         * using annotation.</li> <li>Injection in a field using XML.</li> <li>Injection
058:         * in a method using XML.</li> <li>Override an injection in a field with a
059:         * XML.</li><li>Override an injection in a method with a
060:         * XML.</li>
061:         * @author Eduardo Studzinski Estima de Castro
062:         * @author Gisele Pinheiro Souza
063:         */
064:        @MessageDriven(messageListenerInterface=MessageListener.class,activationConfig={@ActivationConfigProperty(propertyName="destinationType",propertyValue="javax.jms.Queue"),@ActivationConfigProperty(propertyName="destination",propertyValue=JMSManager.DEFAULT_QUEUE),@ActivationConfigProperty(propertyName="messageSelector",propertyValue="TYPE = 'org.ow2.easybeans.tests." + "common.ejbs.mdb.containermanaged.ejbref.MDBEjbRef'")})
065:        @EJBs({@EJB(name="ejb/beanDeclaration00",beanInterface=ItfOneMethod01.class,beanName="EJBInjectionBean"),@EJB(name="ejb/beanDeclaration01",beanInterface=ItfOneMethod01.class,beanName="EJBInjectionBean")})
066:        @EJB(name="ejb/beanDeclaration02",beanInterface=ItfOneMethod01.class,beanName="EJBInjectionBean")
067:        public class MDBEjbRef extends BaseInsertOperation {
068:
069:            /**
070:             * Message type.
071:             */
072:            public static final String MESSAGE_TYPE = "org.ow2.easybeans.tests.common.ejbs.mdb.containermanaged.ejbref."
073:                    + "MDBEjbRef";
074:
075:            /**
076:             * Logger.
077:             */
078:            private static Log logger = LogFactory.getLog(MDBEjbRef.class);
079:
080:            /**
081:             * Bean.
082:             */
083:            @SuppressWarnings("unused")
084:            @EJB(name="ejb/beanFieldInjection",beanName="EJBInjectionBean")
085:            private ItfOneMethod01 beanFieldInjection;
086:
087:            /**
088:             * Bean.
089:             */
090:            @SuppressWarnings("unused")
091:            @EJB(name="ejb/beanOverrideField",beanName="EJBInjectionBean")
092:            private ItfOneMethod01 beanOverrideFieldInjection;
093:
094:            /**
095:             * Bean.
096:             */
097:            private ItfOneMethod01 beanMethodInjection;
098:
099:            /**
100:             * Bean.
101:             */
102:            private ItfOneMethod01 beanXMLMethodInjection;
103:
104:            /**
105:             * Bean.
106:             */
107:            private ItfOneMethod01 beanXMLFieldInjection;
108:
109:            /**
110:             * Bean.
111:             */
112:            private ItfOneMethod01 beanOverrideMethodInjection;
113:
114:            /**
115:             * Setter method.
116:             * @param b bean
117:             */
118:            @EJB(name="ejb/beanMethodInjection",beanName="EJBInjectionBean")
119:            public void setMethodInjection(final ItfOneMethod01 b) {
120:                beanMethodInjection = b;
121:            }
122:
123:            /**
124:             * Setter method.
125:             * @param b bean
126:             */
127:            public void setXMLMethodInjection(final ItfOneMethod01 b) {
128:                beanXMLMethodInjection = b;
129:            }
130:
131:            /**
132:             * Setter method.
133:             * @param b bean
134:             */
135:            @EJB(name="ejb/beanOverrideMethod",beanName="EJBInjectionBean")
136:            public void setOverrideMethodInjection(final ItfOneMethod01 b) {
137:                beanOverrideMethodInjection = b;
138:            }
139:
140:            /**
141:             * Context.
142:             */
143:            @Resource
144:            private MessageDrivenContext ctx;
145:
146:            /**
147:             * Tests declaration and injection.
148:             * @param message msg
149:             */
150:            public void onMessage(final Message message) {
151:
152:                //Declaration using annotation.
153:                try {
154:                    checkBeanRef(ctx, "ejb/beanDeclaration00",
155:                            ItfOneMethod01.class);
156:                    checkBeanRef(ctx, "ejb/beanDeclaration01",
157:                            ItfOneMethod01.class);
158:                    super .log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class,
159:                            ANNOTATION_RESOURCES_DECLARATION);
160:                    logger.debug("{0} is working properly.",
161:                            ANNOTATION_RESOURCES_DECLARATION.toString());
162:                } catch (Exception e) {
163:                    logger.debug("Error checking {0}: {1}",
164:                            ANNOTATION_RESOURCES_DECLARATION.toString(), e
165:                                    .getMessage());
166:                }
167:                try {
168:                    checkBeanRef(ctx, "ejb/beanDeclaration02",
169:                            ItfOneMethod01.class);
170:                    super .log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class,
171:                            ANNOTATION_RESOURCE_DECLARATION);
172:                    logger.debug("{0} is working properly.",
173:                            ANNOTATION_RESOURCE_DECLARATION.toString());
174:                } catch (Exception e) {
175:                    logger.debug("Error checking {0}: {1}",
176:                            ANNOTATION_RESOURCE_DECLARATION.toString(), e
177:                                    .getMessage());
178:                }
179:
180:                //Declaration using XML.
181:                try {
182:                    checkBeanRef(ctx, "ejb/beanXMLDeclaration",
183:                            ItfOneMethod01.class);
184:                    super .log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class,
185:                            XML_RESOURCE_DECLARATION);
186:                    logger.debug("{0} is working properly.",
187:                            XML_RESOURCE_DECLARATION.toString());
188:                } catch (Exception e) {
189:                    logger
190:                            .debug("Error checking {0}: {1}",
191:                                    XML_RESOURCE_DECLARATION.toString(), e
192:                                            .getMessage());
193:                }
194:
195:                //Injection in a field using annotation.
196:                try {
197:                    assert beanFieldInjection.getBool();
198:                    checkBeanRef(ctx, "ejb/beanFieldInjection",
199:                            ItfOneMethod01.class);
200:                    super .log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class,
201:                            ANNOTATION_INJECTION_FIELD);
202:                    logger.debug("{0} is working properly.",
203:                            ANNOTATION_INJECTION_FIELD.toString());
204:                } catch (Exception e) {
205:                    logger.debug("Error checking {0}: {1}",
206:                            ANNOTATION_INJECTION_FIELD.toString(), e
207:                                    .getMessage());
208:                }
209:
210:                //Injection in a method using annotation.
211:                try {
212:                    assert beanMethodInjection.getBool();
213:                    checkBeanRef(ctx, "ejb/beanMethodInjection",
214:                            ItfOneMethod01.class);
215:                    super .log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class,
216:                            ANNOTATION_INJECTION_METHOD);
217:                    logger.debug("{0} is working properly.",
218:                            ANNOTATION_INJECTION_METHOD.toString());
219:                } catch (Exception e) {
220:                    logger.debug("Error checking {0}: {1}",
221:                            ANNOTATION_INJECTION_METHOD.toString(), e
222:                                    .getMessage());
223:                }
224:
225:                //Injection in a field using XML.
226:                try {
227:                    assert beanXMLFieldInjection.getBool();
228:                    checkBeanRef(ctx, "ejb/beanXMLFieldInjection",
229:                            ItfOneMethod01.class);
230:                    super .log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class,
231:                            XML_INJECTION_FIELD);
232:                    logger.debug("{0} is working properly.",
233:                            XML_INJECTION_FIELD.toString());
234:                } catch (Exception e) {
235:                    logger.debug("Error checking {0}: {1}", XML_INJECTION_FIELD
236:                            .toString(), e.getMessage());
237:                }
238:
239:                //Injection in a method using XML.
240:                try {
241:                    assert beanXMLMethodInjection.getBool();
242:                    checkBeanRef(ctx, "ejb/beanXMLMethodInjection",
243:                            ItfOneMethod01.class);
244:                    super .log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class,
245:                            XML_INJECTION_METHOD);
246:                    logger.debug("{0} is working properly.",
247:                            XML_INJECTION_METHOD.toString());
248:                } catch (Exception e) {
249:                    logger.debug("Error checking {0}: {1}",
250:                            XML_INJECTION_METHOD.toString(), e.getMessage());
251:                }
252:
253:                //Override an injection in a field with a XML.
254:                try {
255:                    //Attention: the "ejb/beanOverrideFieldInjection" is the injection declared using the XML.
256:                    assert beanOverrideFieldInjection.getBool();
257:                    checkBeanRef(ctx, "ejb/beanOverrideFieldInjection",
258:                            ItfOneMethod01.class);
259:                    super .log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class,
260:                            OVERRIDE_INJECTION_FIELD);
261:                    logger.debug("{0} is working properly.",
262:                            OVERRIDE_INJECTION_FIELD.toString());
263:                } catch (Exception e) {
264:                    logger
265:                            .debug("Error checking {0}: {1}",
266:                                    OVERRIDE_INJECTION_FIELD.toString(), e
267:                                            .getMessage());
268:                }
269:
270:                //Override an injection in a method with a XML.
271:                try {
272:                    //Attention: the "ejb/beanOverrideMethodInjection" is the injection declared using the XML.
273:                    assert beanOverrideMethodInjection.getBool();
274:                    checkBeanRef(ctx, "ejb/beanOverrideMethodInjection",
275:                            ItfOneMethod01.class);
276:                    super .log(MDBEjbRef.class, ON_MESSAGE, MDBEjbRef.class,
277:                            OVERRIDE_INJECTION_METHOD);
278:                    logger.debug("{0} is working properly.",
279:                            OVERRIDE_INJECTION_METHOD.toString());
280:                } catch (Exception e) {
281:                    logger.debug("Error checking {0}: {1}",
282:                            OVERRIDE_INJECTION_METHOD.toString(), e
283:                                    .getMessage());
284:                }
285:            }
286:        }
w___ww___.___ja___v___a_2_s__.co_m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.