Source Code Cross Referenced for PaperEC.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » beans » folder » 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 » JOnAS 4.8.6 » org.objectweb.jonas.jtests.beans.folder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999 Bull S.A.
004:         * Contact: jonas-team@objectweb.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: PaperEC.java 8462 2006-06-14 08:56:18Z coqp $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.beans.folder;
027:
028:        import javax.ejb.EJBException;
029:        import javax.ejb.EJBLocalHome;
030:        import javax.ejb.EntityBean;
031:        import javax.ejb.EntityContext;
032:        import javax.ejb.CreateException;
033:        import javax.ejb.RemoveException;
034:        import javax.naming.Context;
035:        import javax.naming.InitialContext;
036:        import javax.naming.NamingException;
037:        import javax.rmi.PortableRemoteObject;
038:
039:        import org.objectweb.jonas.common.Log;
040:        import org.objectweb.util.monolog.api.Logger;
041:        import org.objectweb.util.monolog.api.BasicLevel;
042:
043:        /**
044:         * Implementation for the bean PaperEC.
045:         * @author Philippe Durieux, Philippe Coq
046:         */
047:        public class PaperEC implements  EntityBean {
048:
049:            static protected Logger logger = null;
050:            EntityContext ejbContext;
051:            InitialContext ictx;
052:            Context myEnv;
053:
054:            // ------------------------------------------------------------------
055:            // State of the bean.
056:            // They must be public for Container Managed Persistance.
057:            // ------------------------------------------------------------------
058:            public String name;
059:            public int value;
060:
061:            /**
062:             * Check environment variables
063:             */
064:            void checkEnv(String method) {
065:
066:                // Check directly in my context
067:                logger.log(BasicLevel.DEBUG, "Check directly in my context");
068:                try {
069:                    String value = (String) myEnv.lookup("myname");
070:                    if (!value.equals("myentity")) {
071:                        logger.log(BasicLevel.ERROR,
072:                                ": myEnv.lookup failed: myname=" + value);
073:                        throw new EJBException("FileEC 1: " + method);
074:                    }
075:                } catch (NamingException e) {
076:                    logger.log(BasicLevel.ERROR,
077:                            ": myEnv.lookup raised exception:\n" + e);
078:                    throw new EJBException("FileEC 2: " + method);
079:                }
080:                // Check from initial Context
081:                logger.log(BasicLevel.DEBUG, "Check from initial Context");
082:                try {
083:                    String value = (String) ictx.lookup("java:comp/env/myname");
084:                    if (!value.equals("myentity")) {
085:                        logger.log(BasicLevel.ERROR,
086:                                ": ictx.lookup failed: myname=" + value);
087:                        throw new EJBException("FileEC 6: " + method);
088:                    }
089:                } catch (NamingException e) {
090:                    logger.log(BasicLevel.ERROR,
091:                            ": ictx.lookup raised exception:\n" + e);
092:                    throw new EJBException("FileEC 7: " + method);
093:                }
094:                logger.log(BasicLevel.DEBUG, ": checkEnv OK");
095:            }
096:
097:            // ------------------------------------------------------------------
098:            // EntityBean implementation
099:            // ------------------------------------------------------------------
100:
101:            public void setEntityContext(EntityContext ctx) {
102:                if (logger == null) {
103:                    logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
104:                }
105:                logger.log(BasicLevel.DEBUG, "");
106:                ejbContext = ctx;
107:                try {
108:                    // Get initial Context
109:                    ictx = new InitialContext();
110:                    myEnv = (Context) ictx.lookup("java:comp/env");
111:                } catch (NamingException e) {
112:                    throw new EJBException("PaperEC: Cannot get filehome:" + e);
113:                }
114:                checkEnv("setEntityContext");
115:
116:                // Check that we can do "getEJBLocalHome"
117:                EJBLocalHome homel = ctx.getEJBLocalHome();
118:                if (homel == null) {
119:                    throw new EJBException(
120:                            "PaperEC: setEntityContext cannot get EJBLocalHome");
121:                }
122:            }
123:
124:            public void unsetEntityContext() {
125:                logger.log(BasicLevel.DEBUG, "");
126:                ejbContext = null;
127:            }
128:
129:            public void ejbActivate() {
130:                logger.log(BasicLevel.DEBUG, "");
131:            }
132:
133:            public void ejbPassivate() {
134:                logger.log(BasicLevel.DEBUG, "");
135:            }
136:
137:            public void ejbLoad() {
138:                logger.log(BasicLevel.DEBUG, "");
139:            }
140:
141:            public void ejbStore() {
142:                logger.log(BasicLevel.DEBUG, "");
143:            }
144:
145:            public void ejbRemove() throws RemoveException {
146:                logger.log(BasicLevel.DEBUG, "");
147:            }
148:
149:            // ------------------------------------------------------------------
150:            // ejbCreate methods
151:            // ------------------------------------------------------------------
152:
153:            public String ejbCreate(String name) throws CreateException {
154:                logger.log(BasicLevel.DEBUG, "");
155:                this .name = name;
156:                this .value = 0;
157:                return null; // In CMP, should return null.
158:            }
159:
160:            public String ejbPostCreate(String name) throws CreateException {
161:                logger.log(BasicLevel.DEBUG, "");
162:                return null; // In CMP, should return null.
163:            }
164:
165:            // Not used for PaperEC only for PaperEC2
166:            public int ejbHomeGetTotalValeur() throws javax.ejb.FinderException {
167:                return 0;
168:            }
169:
170:            // ------------------------------------------------------------------
171:            // PaperLocal implementation
172:            // ------------------------------------------------------------------
173:
174:            public String getName() {
175:                logger.log(BasicLevel.DEBUG, "");
176:                return this .name;
177:            }
178:
179:            public int getValue() {
180:                logger.log(BasicLevel.DEBUG, "");
181:                return this .value;
182:            }
183:
184:            public void setValue(int v) {
185:                logger.log(BasicLevel.DEBUG, "");
186:                this.value = v;
187:            }
188:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.