Source Code Cross Referenced for BEC2.java in  » J2EE » JOnAS-4.8.6 » org » objectweb » jonas » jtests » beans » relation » pkcomp » 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.relation.pkcomp 
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: BEC2.java 5995 2004-12-17 15:08:36Z joaninh $
023:         * --------------------------------------------------------------------------
024:         */
025:
026:        package org.objectweb.jonas.jtests.beans.relation.pkcomp;
027:
028:        import org.objectweb.util.monolog.api.Logger;
029:        import org.objectweb.util.monolog.api.BasicLevel;
030:        import org.objectweb.jonas.common.Log;
031:
032:        import javax.ejb.CreateException;
033:        import javax.ejb.DuplicateKeyException;
034:        import javax.ejb.EntityContext;
035:        import javax.ejb.RemoveException;
036:        import javax.ejb.FinderException;
037:        import javax.ejb.EJBException;
038:        import javax.naming.Context;
039:        import javax.naming.InitialContext;
040:        import javax.naming.NamingException;
041:        import javax.rmi.PortableRemoteObject;
042:
043:        import java.util.Collection;
044:        import java.util.ArrayList;
045:        import java.util.Iterator;
046:
047:        /**
048:         * @author J.Camilleri
049:         */
050:        public abstract class BEC2 implements  javax.ejb.EntityBean {
051:
052:            private AHomeLocal ahl = null;
053:
054:            public void m1() {
055:            }
056:
057:            public BPK getId() {
058:                return (BPK) ejbContext.getPrimaryKey();
059:            }
060:
061:            public void assignA(Collection c) throws FinderException {
062:                ArrayList al;
063:                if (c == null)
064:                    al = new ArrayList();
065:                else {
066:                    if (c.size() == -1)
067:                        al = new ArrayList();
068:                    else {
069:                        al = new ArrayList(c.size());
070:                        for (Iterator it = c.iterator(); it.hasNext();) {
071:                            al.add(ahl.findByPrimaryKey((APK) it.next()));
072:                        }
073:                    }
074:                }
075:                setA(al);
076:            }
077:
078:            public void assignAInNewTx(Collection c) throws FinderException {
079:                assignA(c);
080:            }
081:
082:            public Collection retrieveA() {
083:                Collection bs = getA();
084:                ArrayList result;
085:                if (bs.size() == -1)
086:                    result = new ArrayList();
087:                else
088:                    result = new ArrayList(bs.size());
089:
090:                for (Iterator it = bs.iterator(); it.hasNext();)
091:                    result.add(((ALocal) it.next()).getPrimaryKey());
092:                return result;
093:            }
094:
095:            public Collection retrieveAInNewTx() {
096:                return retrieveA();
097:            }
098:
099:            public void addInA(APK pkb) throws FinderException {
100:                getA().add(ahl.findByPrimaryKey(pkb));
101:            }
102:
103:            public void addInAInNewTx(APK pkb) throws FinderException {
104:                addInA(pkb);
105:            }
106:
107:            public void addAllInA(Collection pkbs) throws FinderException {
108:                ArrayList al = new ArrayList();
109:                for (Iterator it = pkbs.iterator(); it.hasNext();)
110:                    al.add(ahl.findByPrimaryKey((APK) it.next()));
111:                getA().addAll(al);
112:            }
113:
114:            public void addAllInAInNewTx(Collection pkbs)
115:                    throws FinderException {
116:                addAllInA(pkbs);
117:            }
118:
119:            public void removeFromA(APK pkb) throws FinderException {
120:                getA().remove(ahl.findByPrimaryKey(pkb));
121:            }
122:
123:            public void removeFromAInNewTx(APK pkb) throws FinderException {
124:                removeFromA(pkb);
125:            }
126:
127:            public void clearA() {
128:                getA().clear();
129:            }
130:
131:            public void clearAInNewTx() {
132:                clearA();
133:            }
134:
135:            public boolean containAllInA(Collection pkbs)
136:                    throws FinderException {
137:                ArrayList al = new ArrayList(pkbs.size());
138:                for (Iterator it = pkbs.iterator(); it.hasNext();)
139:                    al.add(ahl.findByPrimaryKey((APK) it.next()));
140:                return getA().containsAll(al);
141:            }
142:
143:            /**
144:             * It returns true the multivalued relation contains the bean A defined
145:             * by the primary key specified by the parameter.
146:             * This method has the transactional attribut TX_SUPPORTS.
147:             * @throw a FinderException if the primary key does not match to a bean.
148:             */
149:            public boolean containInA(APK pkb) throws FinderException {
150:                return (getA().contains(ahl.findByPrimaryKey(pkb)));
151:            }
152:
153:            // ------------------------------------------------------------------
154:            // Get and Set accessor methods of the bean's abstract schema
155:            // ------------------------------------------------------------------
156:            public abstract String getIdb1();
157:
158:            public abstract int getIdb2();
159:
160:            public abstract void setIdb1(String id);
161:
162:            public abstract void setIdb2(int id);
163:
164:            public abstract Collection getA();
165:
166:            public abstract void setA(Collection bl);
167:
168:            // ------------------------------------------------------------------
169:            // EntityBean implementation
170:            // ------------------------------------------------------------------
171:
172:            static protected Logger logger = null;
173:            EntityContext ejbContext;
174:
175:            /**
176:             * The Entity bean can define 0 or more ejbCreate methods.
177:             *
178:             * @throws CreateException Failure to create an entity EJB object.
179:             * @throws DuplicateKeyException An object with the same key already exists.
180:             */
181:            public String ejbCreate(String idb1, int idb2)
182:                    throws CreateException, DuplicateKeyException {
183:                logger.log(BasicLevel.DEBUG, "");
184:
185:                // Init here the bean fields
186:                setIdb1(idb1);
187:                setIdb2(idb2);
188:                // In CMP, should return null.
189:                return null;
190:            }
191:
192:            /**
193:             * Set the associated entity context. The container invokes this method
194:             * on an instance after the instance has been created.
195:             * This method is called in an unspecified transaction context.
196:             *
197:             * @param ctx - An EntityContext interface for the instance. The instance
198:             * should store the reference to the context in an instance variable.
199:             * @throws EJBException Thrown by the method to indicate a failure caused by a
200:             * system-level error.
201:             */
202:            public void setEntityContext(EntityContext ctx) {
203:                if (logger == null)
204:                    logger = Log.getLogger(Log.JONAS_TESTS_PREFIX);
205:                logger.log(BasicLevel.DEBUG, "");
206:                ejbContext = ctx;
207:                try {
208:                    Context ictx = new InitialContext();
209:                    ahl = (AHomeLocal) ictx.lookup("java:comp/env/ejb/a");
210:                } catch (NamingException e) {
211:                    throw new EJBException("Impossible to fetch the ", e);
212:                }
213:            }
214:
215:            /**
216:             * Unset the associated entity context. The container calls this method
217:             * before removing the instance.
218:             * This is the last method that the container invokes on the instance.
219:             * The Java garbage collector will eventually invoke the finalize() method
220:             * on the instance.
221:             * This method is called in an unspecified transaction context.
222:             *
223:             * @throws EJBException Thrown by the method to indicate a failure caused by a
224:             * system-level error.
225:             */
226:            public void unsetEntityContext() {
227:                logger.log(BasicLevel.DEBUG, "");
228:                ejbContext = null;
229:            }
230:
231:            /**
232:             * A container invokes this method before it removes the EJB object
233:             * that is currently associated with the instance. This method is
234:             * invoked when a client invokes a remove operation on the enterprise Bean's
235:             * home interface or the EJB object's remote interface. This method
236:             * transitions the instance from the ready state to the pool of available
237:             * instances.
238:             *
239:             * This method is called in the transaction context of the remove operation.
240:             * @throws RemoveException  The enterprise Bean does not allow destruction of the object.
241:             * @throws EJBException - Thrown by the method to indicate a failure caused by a system-level
242:             * error.
243:             */
244:            public void ejbRemove() throws RemoveException {
245:                logger.log(BasicLevel.DEBUG, "");
246:            }
247:
248:            /**
249:             * A container invokes this method to instruct the instance to synchronize
250:             * its state by loading it state from the underlying database.
251:             * This method always executes in the proper transaction context.
252:             *
253:             * @throws EJBException Thrown by the method to indicate a failure caused by
254:             * a system-level error.
255:             */
256:            public void ejbLoad() {
257:                logger.log(BasicLevel.DEBUG, "");
258:            }
259:
260:            /**
261:             * A container invokes this method to instruct the instance to synchronize
262:             * its state by storing it to the underlying database.
263:             * This method always executes in the proper transaction context.
264:             *
265:             * @throws EJBException Thrown by the method to indicate a failure caused by
266:             * a system-level error.
267:             */
268:            public void ejbStore() {
269:                logger.log(BasicLevel.DEBUG, "");
270:            }
271:
272:            /**
273:             * There must be an ejbPostCreate par ejbCreate method
274:             *
275:             * @throws CreateException Failure to create an entity EJB object.
276:             */
277:            public void ejbPostCreate(String idb1, int idb2)
278:                    throws CreateException {
279:                logger
280:                        .log(BasicLevel.DEBUG, "idb1=" + idb1 + " / idb2="
281:                                + idb2);
282:            }
283:
284:            /**
285:             * A container invokes this method on an instance before the instance
286:             * becomes disassociated with a specific EJB object.
287:             */
288:            public void ejbPassivate() {
289:                logger.log(BasicLevel.DEBUG, "");
290:            }
291:
292:            /**
293:             * A container invokes this method when the instance is taken out of
294:             * the pool of available instances to become associated with a specific
295:             * EJB object.
296:             */
297:            public void ejbActivate() {
298:                logger.log(BasicLevel.DEBUG, "");
299:            }
300:
301:        }
ww__w_.___j_a__v___a_2_s.___c_o___m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.