Source Code Cross Referenced for ParentBean.java in  » EJB-Server-JBoss-4.2.1 » testsuite » org » jboss » test » cmp2 » cmrstress » ejb » 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 » EJB Server JBoss 4.2.1 » testsuite » org.jboss.test.cmp2.cmrstress.ejb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * JBoss, Home of Professional Open Source.
003:         * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004:         * as indicated by the @author tags. See the copyright.txt file in the
005:         * distribution for a full listing of individual contributors.
006:         *
007:         * This is free software; you can redistribute it and/or modify it
008:         * under the terms of the GNU Lesser General Public License as
009:         * published by the Free Software Foundation; either version 2.1 of
010:         * the License, or (at your option) any later version.
011:         *
012:         * This software is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this software; if not, write to the Free
019:         * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020:         * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021:         */
022:        package org.jboss.test.cmp2.cmrstress.ejb;
023:
024:        import java.util.HashMap;
025:        import java.util.Iterator;
026:        import java.util.Map;
027:        import java.util.Set;
028:
029:        import javax.ejb.CreateException;
030:        import javax.ejb.EJBException;
031:        import javax.ejb.EntityBean;
032:        import javax.ejb.EntityContext;
033:        import javax.ejb.RemoveException;
034:        import javax.naming.NamingException;
035:
036:        import org.apache.log4j.Logger;
037:        import org.jboss.test.cmp2.cmrstress.interfaces.ChildLocal;
038:        import org.jboss.test.cmp2.cmrstress.interfaces.ChildUtil;
039:
040:        /**
041:         * This class implements the "parent" side of 1..many unidirectional relationship.
042:         * It doesn't do anything particularly interesting besides provide the CMR getter
043:         * and a method (@see #getPropertyMap()) that provides a transactional context for
044:         * iterating over the CMR collection.
045:         * 
046:         * This code is based upon the original test case provided by Andrew May.
047:         *
048:         * @version <tt>$Revision: 57211 $</tt>
049:         * @author  <a href="mailto:steve@resolvesw.com">Steve Coy</a>.
050:         *
051:         * @ejb.bean name="Parent"
052:         *           type="CMP"
053:         *           cmp-version="2.x"
054:         *           view-type="both"
055:         *           jndi-name="cmrstress/Parent"
056:         *           primkey-field="id"
057:         * 
058:         * @ejb.pk class="java.lang.String"
059:         *         generate="false"
060:         * 
061:         * @ejb.persistence table-name="StressedParent"
062:         * 
063:         * @@ejb.home generate="both"
064:         * @@ejb.interface generate="both"
065:         * 
066:         * @ejb.ejb-ref ejb-name="Child"
067:         *              view-type="local"
068:         *  
069:         * @ejb.transaction type="Supports"
070:         * 
071:         * @jboss.persistence
072:         *       create-table="true"
073:         *       remove-table="true"
074:         * @jboss.tuned-updates tune="true"
075:         */
076:        public abstract class ParentBean implements  EntityBean {
077:            /**
078:             * CMP get method for Id attribute.
079:             * @ejb.interface-method view-type="remote"
080:             * @ejb.persistent-field
081:             * @jboss.column-name name="id"
082:             * @jboss.method-attributes read-only="true"
083:             */
084:            public abstract String getId();
085:
086:            /**
087:             * CMP set method for Id attribute.
088:             * @ejb.interface-method view-type="remote"
089:             * @ejb.transaction type="Mandatory"
090:             */
091:            public abstract void setId(String id);
092:
093:            /** 
094:             * Get Children that apply to this Parent.
095:             * 
096:             * @ejb.interface-method view-type="remote" 
097:             * @ejb.relation name="Parent-Child"
098:             *               role-name="Parent-has-Children"
099:             *               cascade-delete="no"
100:             *               target-ejb="Child"
101:             *               target-role-name="Child-of-Parent"
102:             *               target-cascade-delete="yes"
103:             * @jboss.target-relation related-pk-field="id"
104:             *                        fk-column="parentid"
105:             * jboss.method-attributes read-only="true"
106:             */
107:            public abstract Set getChildren();
108:
109:            /** 
110:             * Set Children.
111:             * @ejb.interface-method view-type="remote" 
112:             * @ejb.transaction type="Mandatory"
113:             */
114:            public abstract void setChildren(Set children);
115:
116:            /** 
117:             * Get a map of Child values.
118:             * This is the current axis of evil.
119:             * 
120:             * @ejb.interface-method view-type="remote" 
121:             * @ejb.transaction type="Required"
122:             * @jboss.method-attributes read-only="true"
123:             */
124:            public Map getPropertyMap() {
125:                Map result = new HashMap();
126:                Set children = getChildren();
127:                for (Iterator i = children.iterator(); i.hasNext();) {
128:                    ChildLocal c = (ChildLocal) i.next();
129:                    result.put(c.getName(), c.getValue());
130:                }
131:
132:                return result;
133:            }
134:
135:            /**
136:             * Adds a child bean with the given attributes to this bean.
137:             * @ejb.interface-method view-type="remote" 
138:             * @ejb.transaction type="RequiresNew"
139:             */
140:            public void addChild(int k, String field1, String field2)
141:                    throws CreateException {
142:                msLog.debug("Adding child with pk: " + k);
143:                try {
144:                    getChildren().add(
145:                            ChildUtil.getLocalHome().create(
146:                                    Integer.toString(k), field1, field2));
147:                } catch (NamingException e) {
148:                    throw new EJBException(e);
149:                }
150:            }
151:
152:            /**
153:             * Create method for Entity.
154:             * @ejb.create-method view-type="remote"
155:             * @ejb.transaction type="RequiresNew"
156:             */
157:            public String ejbCreate(String id) throws javax.ejb.CreateException {
158:                msLog.debug("Created '" + id + "'");
159:                setId(id);
160:                return null;
161:            }
162:
163:            public void ejbPostCreate(String id) {
164:            }
165:
166:            /**
167:             * @see javax.ejb.EntityBean#ejbActivate()
168:             */
169:            public void ejbActivate() {
170:            }
171:
172:            /**
173:             * @see javax.ejb.EntityBean#ejbLoad()
174:             */
175:            public void ejbLoad() {
176:            }
177:
178:            /**
179:             * @see javax.ejb.EntityBean#ejbPassivate()
180:             */
181:            public void ejbPassivate() {
182:            }
183:
184:            /**
185:             * @see javax.ejb.EntityBean#ejbRemove()
186:             */
187:            public void ejbRemove() throws RemoveException {
188:                msLog.debug("Removed");
189:            }
190:
191:            /**
192:             * @see javax.ejb.EntityBean#ejbStore()
193:             */
194:            public void ejbStore() {
195:            }
196:
197:            /**
198:             * @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
199:             */
200:            public void setEntityContext(EntityContext arg0) {
201:            }
202:
203:            /**
204:             * @see javax.ejb.EntityBean#unsetEntityContext()
205:             */
206:            public void unsetEntityContext() {
207:            }
208:
209:            private static final Logger msLog = Logger
210:                    .getLogger(ParentBean.class);
211:
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.