Source Code Cross Referenced for CustomerBean.java in  » J2EE » JOnAS-4.8.6 » xdoclet » 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 » xdoclet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * JOnAS: Java(TM) Open Application Server
003:         * Copyright (C) 1999-2004 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: CustomerBean.java 7401 2005-09-21 15:39:04Z camillej $
023:         * --------------------------------------------------------------------------
024:         */package xdoclet;
025:
026:        import java.rmi.RemoteException;
027:        import javax.ejb.EntityBean;
028:        import javax.ejb.EntityContext;
029:        import javax.ejb.ObjectNotFoundException;
030:        import javax.ejb.RemoveException;
031:        import javax.ejb.CreateException;
032:        import javax.ejb.EJBException;
033:        import java.util.Date;
034:        import java.util.Collection;
035:        import java.util.Iterator;
036:        import java.util.Vector;
037:        import javax.naming.InitialContext;
038:        import javax.naming.NamingException;
039:
040:        /**
041:         * CustomerBean is an entity bean with "container managed persistence version 2".
042:         * The state of an instance is stored into a relational database.
043:         *
044:         * @ejb.bean
045:         *      name="CustomerBean"
046:         *      description="Deployment descriptor for the CustomerBean bean with CMP2 JOnAS example"
047:         *      type="CMP"
048:         *      view-type="both"
049:         *      primkey-field="id"
050:         *      jndi-name="CustomerBeanHome"
051:         *      cmp-version="2.x"
052:         *      reentrant="false"
053:         * @ejb.home
054:         *      remote-class="xdoclet.CustomerHomeRemote"
055:         *      local-class="xdoclet.CustomerHomeLocal"
056:         * @ejb.interface
057:         *      remote-class="xdoclet.CustomerRemote"
058:         *      local-class="xdoclet.CustomerLocal"
059:         * @ejb:pk
060:         *      class="java.lang.Integer"
061:         * @ejb.ejb-ref
062:         *	    ejb-name="PhoneBean"
063:         *	    view-type="local"
064:         *	    ref-name="ejb/PhoneHomeLocal"
065:         *
066:         * @jonas.jdbc-mapping
067:         *       jdbc-table-name = "MyCustomer"
068:         *
069:         * @ejb:finder
070:         *	     signature= "java.util.Collection findByName(java.lang.String lastName, java.lang.String firstName)"
071:         *	     query ="SELECT OBJECT(c) FROM CustomerBean c WHERE c.lastName LIKE ?1 AND c.firstName LIKE ?2"
072:         * @ejb:finder
073:         *	     signature= "java.util.Collection findAllCustomers()"
074:         *	     query ="SELECT OBJECT(c) FROM CustomerBean AS c"
075:         *
076:         * @jonas.session-timeout
077:         *       session-timeout="60"
078:         * @ejb:transaction
079:         *       type="Required"
080:         */
081:        public abstract class CustomerBean implements  EntityBean {
082:
083:            // Keep the reference on the EntityContext
084:            protected EntityContext entityContext;
085:
086:            /**
087:             * EJBCREATE
088:             * @return pk primary key set to null
089:             *
090:             * @ejb.create-method
091:             */
092:            public Integer ejbCreate(Integer id, Name name)
093:                    throws CreateException {
094:                setLastName(name.getLastName());
095:                setFirstName(name.getFirstName());
096:
097:                // Init object state
098:                this .setId(id);
099:                return null;
100:            }
101:
102:            public void ejbPostCreate(Integer id, Name name) {
103:            }
104:
105:            // business methods
106:            /**
107:             * @ejb.interface-method
108:             *
109:             **/
110:            public Name getName() {
111:                Name name = new Name(getLastName(), getFirstName());
112:                return name;
113:            }
114:
115:            /**
116:             * @ejb.interface-method
117:             **/
118:            public void setName(Name name) {
119:                setLastName(name.getLastName());
120:                setFirstName(name.getFirstName());
121:            }
122:
123:            /**
124:             * @ejb.interface-method
125:             **/
126:            public void addPhoneNumber(String number, byte type)
127:                    throws NamingException, CreateException {
128:                InitialContext jndiEnc = new InitialContext();
129:                PhoneHomeLocal phoneHomeL = (PhoneHomeLocal) (jndiEnc
130:                        .lookup("java:comp/env/ejb/PhoneHomeLocal"));
131:
132:                PhoneLocal phone = phoneHomeL.create(number, type);
133:                Collection phoneNumbers = this .getPhoneNumber();
134:                phoneNumbers.add(phone);
135:            }
136:
137:            /**
138:             * @ejb.interface-method
139:             **/
140:            public void removePhoneNumber(byte typeToRemove) {
141:                Collection phoneNumbers = this .getPhoneNumber();
142:                Iterator iterator = phoneNumbers.iterator();
143:
144:                while (iterator.hasNext()) {
145:                    PhoneLocal phone = (PhoneLocal) iterator.next();
146:                    if (phone.getType() == typeToRemove) {
147:                        phoneNumbers.remove(phone);
148:                        try {
149:                            phone.remove();
150:                        } catch (Exception e) {
151:                            System.out.println("Problem during removing phone");
152:                        }
153:                    }
154:
155:                }
156:            }
157:
158:            /**
159:             * @ejb.interface-method
160:             **/
161:            public void updatePhoneNumber(String number, byte typeToUpdate) {
162:                Collection phoneNumbers = this .getPhoneNumber();
163:                Iterator iterator = phoneNumbers.iterator();
164:                while (iterator.hasNext()) {
165:                    PhoneLocal phone = (PhoneLocal) iterator.next();
166:                    if (phone.getType() == typeToUpdate) {
167:                        phone.setNumber(number);
168:                        break;
169:                    }
170:                }
171:            }
172:
173:            /**
174:             * @ejb.interface-method
175:             **/
176:            public Vector getPhoneList() {
177:
178:                Vector vv = new Vector();
179:                Collection phoneNumbers = this .getPhoneNumber();
180:
181:                Iterator iterator = phoneNumbers.iterator();
182:                while (iterator.hasNext()) {
183:                    PhoneLocal phone = (PhoneLocal) iterator.next();
184:                    String ss = "Type=" + phone.getType() + "  Number="
185:                            + phone.getNumber();
186:                    vv.add(ss);
187:                }
188:                return vv;
189:            }
190:
191:            // persistent relationships
192:            /**
193:             * @ejb.relation
194:             * name="CUSTOMER-PHONE"
195:             * role-name="PHONE-has-CUSTOMER"
196:             * target-ejb="PhoneBean"
197:             * target-role-name="CUSTOMER-has-PHONE"
198:             *
199:             * @jonas.field-mapping
200:             *    foreign-key-jdbc-name="CUSTOMER_FK_PHONE"
201:             *    key-jdbc-name="CustomerId"
202:             **/
203:            public abstract Collection getPhoneNumber();
204:
205:            public abstract void setPhoneNumber(Collection phones);
206:
207:            // abstract accessor methods
208:            /**
209:             * @ejb.persistent-field
210:             * @ejb.interface-method
211:             * @jonas.cmp-field-jdbc-mapping
212:             *	field-name="id"
213:             *	jdbc-field-name="CustomerId"
214:             */
215:            public abstract Integer getId();
216:
217:            /**
218:             * @ejb.persistent-field
219:             * @ejb.interface-method
220:             */
221:            public abstract void setId(Integer id);
222:
223:            /**
224:             * @ejb.persistent-field
225:             * @ejb.interface-method
226:             */
227:            public abstract String getLastName();
228:
229:            /**
230:             * @ejb.persistent-field
231:             * @ejb.interface-method
232:             */
233:            public abstract void setLastName(String lname);
234:
235:            /**
236:             * @ejb.persistence
237:             * 		column-name="CustomerFirstName"
238:             * 		jdbc-type="VARCHAR"
239:             * @ejb.persistent-field
240:             * @ejb.interface-method
241:             */
242:            public abstract String getFirstName();
243:
244:            /**
245:             * @ejb.persistent-field
246:             * @ejb.interface-method
247:             */
248:            public abstract void setFirstName(String fname);
249:
250:            // standard call back methods
251:
252:            public void ejbActivate() {
253:            }
254:
255:            public void ejbLoad() {
256:            }
257:
258:            public void ejbPassivate() {
259:            }
260:
261:            public void ejbRemove() throws RemoveException {
262:            }
263:
264:            public void ejbStore() {
265:            }
266:
267:            public void setEntityContext(EntityContext ctx) {
268:
269:                // Keep the entity context in object
270:                entityContext = ctx;
271:            }
272:
273:            public void unsetEntityContext() {
274:                entityContext = null;
275:            }
276:
277:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.