Source Code Cross Referenced for RelationMetaData.java in  » EJB-Server-JBoss-4.2.1 » server » org » jboss » metadata » 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 » server » org.jboss.metadata 
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.metadata;
023:
024:        import java.util.Iterator;
025:
026:        import org.w3c.dom.Element;
027:        import org.jboss.deployment.DeploymentException;
028:
029:        /** 
030:         * Represents one ejb-relation element found in the ejb-jar.xml
031:         * file's relationships elements.
032:         *
033:         * @author <a href="mailto:dain@daingroup.com">Dain Sundstrom</a>
034:         * @version $Revision: 57209 $
035:         */
036:        public class RelationMetaData extends MetaData {
037:            /** Name of the relation. Loaded from the ejb-relation-name element. */
038:            private String relationName;
039:
040:            /** 
041:             * The left relationship role. Loaded from an ejb-relationship-role.
042:             * Left/right assignment is completely arbitrary.
043:             */
044:            private RelationshipRoleMetaData left;
045:
046:            /** 
047:             * The right relationship role. Loaded from an ejb-relationship-role.
048:             * Left/right assignment is completely arbitrary.
049:             */
050:            private RelationshipRoleMetaData right;
051:
052:            /** 
053:             * Gets the relation name. 
054:             * Relation name is loaded from the ejb-relation-name element.
055:             */
056:            public String getRelationName() {
057:                return relationName;
058:            }
059:
060:            /** 
061:             * Gets the left relationship role. 
062:             * The relationship role is loaded from an ejb-relationship-role.
063:             * Left/right assignment is completely arbitrary.
064:             */
065:            public RelationshipRoleMetaData getLeftRelationshipRole() {
066:                return left;
067:            }
068:
069:            /** 
070:             * Gets the right relationship role.
071:             * The relationship role is loaded from an ejb-relationship-role.
072:             * Left/right assignment is completely arbitrary.
073:             */
074:            public RelationshipRoleMetaData getRightRelationshipRole() {
075:                return right;
076:            }
077:
078:            public RelationshipRoleMetaData getOtherRelationshipRole(
079:                    RelationshipRoleMetaData role) {
080:
081:                if (left == role) {
082:                    return right;
083:                } else if (right == role) {
084:                    return left;
085:                } else {
086:                    throw new IllegalArgumentException(
087:                            "Specified role is not the left "
088:                                    + "or right role. role=" + role);
089:                }
090:            }
091:
092:            public void importEjbJarXml(Element element)
093:                    throws DeploymentException {
094:                // name - treating empty values as not specified
095:                relationName = getOptionalChildContent(element,
096:                        "ejb-relation-name");
097:                if ("".equals(relationName)) {
098:                    relationName = null;
099:                }
100:
101:                // left role
102:                Iterator iter = getChildrenByTagName(element,
103:                        "ejb-relationship-role");
104:                if (iter.hasNext()) {
105:                    left = new RelationshipRoleMetaData(this );
106:                    left.importEjbJarXml((Element) iter.next());
107:                } else {
108:                    throw new DeploymentException(
109:                            "Expected 2 ejb-relationship-role "
110:                                    + "roles but found none");
111:                }
112:
113:                // right role
114:                if (iter.hasNext()) {
115:                    right = new RelationshipRoleMetaData(this );
116:                    right.importEjbJarXml((Element) iter.next());
117:                } else {
118:                    throw new DeploymentException(
119:                            "Expected 2 ejb-relationship-role "
120:                                    + "but only found one");
121:                }
122:
123:                // assure there are only two ejb-relationship-role elements
124:                if (iter.hasNext()) {
125:                    throw new DeploymentException(
126:                            "Expected only 2 ejb-relationship-"
127:                                    + "role but found more then 2");
128:                }
129:
130:                // JBossCMP needs ejb-relation-name if jbosscmp-jdbc.xml is used to map relationships.
131:                if (relationName == null) {
132:                    // generate unique name, we can't rely on ejb-relationship-role-name being unique
133:                    relationName = left.getEntityName()
134:                            + (left.getCMRFieldName() == null ? "" : "_"
135:                                    + left.getCMRFieldName())
136:                            + "-"
137:                            + right.getEntityName()
138:                            + (right.getCMRFieldName() == null ? "" : "_"
139:                                    + right.getCMRFieldName());
140:                }
141:
142:                // assure that the left role and right role do not have the same name
143:                String leftName = left.getRelationshipRoleName();
144:                String rightName = right.getRelationshipRoleName();
145:                if (leftName != null && leftName.equals(rightName)) {
146:                    throw new DeploymentException(
147:                            "ejb-relationship-role-name must be "
148:                                    + "unique in ejb-relation: ejb-relationship-role-name is "
149:                                    + leftName);
150:                }
151:
152:                // verify cascade delete
153:                if (left.isCascadeDelete() && right.isMultiplicityMany()) {
154:                    throw new DeploymentException(
155:                            "cascade-delete is only allowed in "
156:                                    + "ejb-relationship-role where the other role has a "
157:                                    + "multiplicity One");
158:                }
159:                if (right.isCascadeDelete() && left.isMultiplicityMany()) {
160:                    throw new DeploymentException(
161:                            "cascade-delete is only allowed in "
162:                                    + "ejb-relationship-role where the other role has a "
163:                                    + "multiplicity One");
164:                }
165:            }
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.