Source Code Cross Referenced for JormGenerator.java in  » Database-ORM » Speedo_1.4.5 » org » objectweb » speedo » generation » jorm » 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 » Database ORM » Speedo_1.4.5 » org.objectweb.speedo.generation.jorm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Speedo: an implementation of JDO compliant personality on top of JORM generic
003:         * I/O sub-system.
004:         * Copyright (C) 2001-2004 France Telecom R&D
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 of the License, or (at your option) 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  USA
019:         *
020:         *
021:         *
022:         * Contact: speedo@objectweb.org
023:         *
024:         * Authors: S.Chassande-Barrioz.
025:         *
026:         */package org.objectweb.speedo.generation.jorm;
027:
028:        import java.util.ArrayList;
029:        import java.util.Collection;
030:        import java.util.Iterator;
031:        import java.util.List;
032:        import java.util.Set;
033:
034:        import org.objectweb.jorm.api.PException;
035:        import org.objectweb.jorm.compiler.api.JormCompilerConfigurator;
036:        import org.objectweb.jorm.compiler.api.JormCompilerParameter;
037:        import org.objectweb.jorm.compiler.lib.JormCompiler;
038:        import org.objectweb.jorm.metainfo.api.Class;
039:        import org.objectweb.jorm.metainfo.api.ClassProject;
040:        import org.objectweb.jorm.metainfo.api.CompositeName;
041:        import org.objectweb.jorm.metainfo.api.GenClassRef;
042:        import org.objectweb.jorm.metainfo.api.Manager;
043:        import org.objectweb.jorm.metainfo.api.Mapping;
044:        import org.objectweb.jorm.metainfo.api.NameDef;
045:        import org.objectweb.jorm.metainfo.api.TypedElement;
046:        import org.objectweb.jorm.util.io.lib.DirJavaExplorer;
047:        import org.objectweb.speedo.api.ExceptionHelper;
048:        import org.objectweb.speedo.api.SpeedoException;
049:        import org.objectweb.speedo.api.SpeedoProperties;
050:        import org.objectweb.speedo.generation.api.SpeedoXMLError;
051:        import org.objectweb.speedo.generation.lib.AbstractGeneratorComponent;
052:        import org.objectweb.speedo.lib.Personality;
053:        import org.objectweb.speedo.metadata.SpeedoClass;
054:        import org.objectweb.speedo.metadata.SpeedoField;
055:        import org.objectweb.speedo.metadata.SpeedoIdentity;
056:        import org.objectweb.speedo.metadata.SpeedoModifier;
057:        import org.objectweb.speedo.metadata.SpeedoPackage;
058:        import org.objectweb.speedo.metadata.SpeedoXMLDescriptor;
059:        import org.objectweb.util.monolog.api.BasicLevel;
060:
061:        /**
062:         * Generates the JORM Files corresponding to a set of Java Classes.
063:         * <p>See <a href="http://www.objectweb.org/jorm">http://www.objectweb.org/jorm</a>for more information.</p>
064:         * @author	S.Chassande-Barrioz
065:         */
066:        public class JormGenerator extends AbstractGeneratorComponent {
067:            public final static String LOGGER_NAME = SpeedoProperties.LOGGER_NAME
068:                    + ".generation.jorm";
069:            /**
070:             * Jorm classes intended for JORM generation
071:             */
072:            protected JormCompiler jormcompiler;
073:
074:            public JormGenerator(Personality p) {
075:                super (p);
076:            }
077:
078:            // IMPLEMENTATION OF THE GeneratorComponent INTERFACE //
079:            //----------------------------------------------------//
080:
081:            public boolean init() throws SpeedoException {
082:                if (scp.getXmldescriptor().isEmpty()) {
083:                    return false;
084:                }
085:                logger = scp.loggerFactory.getLogger(LOGGER_NAME);
086:                jormcompiler = (JormCompiler) scp.generatorsContext
087:                        .get("jormcompiler");
088:                JormCompilerParameter jcp = jormcompiler.getCompilerParameter();
089:                jcp.setProjectName(scp.projectName);
090:                jcp.setBindingInheritance("%p%c");
091:                jcp.setClassMappingInheritance("%p%cHome");
092:                jcp.setOutput(scp.output);
093:                jcp.setBindingAbstract(true);
094:                jcp.setDtdLocations(scp.dtdLocations);
095:                jcp.setInputFiles(scp.jorm);
096:                DirJavaExplorer pe = new DirJavaExplorer();
097:                pe.setLogger(scp.loggerFactory
098:                        .getLogger("org.objectweb.jorm.io.pathexplorer"));
099:                pe.addPath(scp.jormclasspath);
100:                jcp.setClasspath(pe);
101:                jcp.setGenerateBinding(false);
102:                jcp.setGeneratedWithMapperPackage(false);
103:                return true;
104:            }
105:
106:            public String getTitle() {
107:                return "Generating Jorm files...";
108:            }
109:
110:            /**
111:             * Performs the JORM objects' generation.
112:             */
113:            public void process() throws SpeedoException {
114:                if (scp.getXmldescriptor().isEmpty()) {
115:                    return;
116:                }
117:                if (logger.isLoggable(BasicLevel.DEBUG)) {
118:                    Manager m = jormcompiler.getMIManager();
119:                    for (Iterator it = m.getClasses().iterator(); it.hasNext();) {
120:                        logger.log(BasicLevel.DEBUG, "Class : "
121:                                + ((Class) it.next()).getFQName());
122:                    }
123:                    for (Iterator it = m.getCompositeNames().iterator(); it
124:                            .hasNext();) {
125:                        logger.log(BasicLevel.DEBUG, "CompositeName : "
126:                                + ((CompositeName) it.next()).getFQName());
127:                    }
128:                }
129:                try {
130:                    // Generate the .pd files
131:                    if (scp.generateNeededJormFile) {
132:                        jormcompiler.generateJormFiles(null);
133:                    }
134:                    //Launch the jorm generation
135:                    Collection gfs = jormcompiler.generateFiles(null);
136:                    if (logger.isLoggable(BasicLevel.DEBUG))
137:                        for (Iterator it = gfs.iterator(); it.hasNext();)
138:                            logger.log(BasicLevel.DEBUG, "Generated files: "
139:                                    + it.next());
140:
141:                    //Register the meta information to serialize for each xml descriptor
142:                    for (Iterator itDesc = scp.getXmldescriptor().values()
143:                            .iterator(); itDesc.hasNext();) {
144:                        addSerializeJormMI((SpeedoXMLDescriptor) itDesc.next());
145:                    }
146:                } catch (PException e) {
147:                    throw new SpeedoException("Error during Jorm generation", e);
148:                }
149:            }
150:
151:            private void addSerializeJormMI(SpeedoXMLDescriptor desc)
152:                    throws SpeedoException {
153:                // Calculate the list of the Jorm Meta Object which must be serialized
154:                //Set mos = new HashSet(desc.jdoPackage.size());
155:                for (Iterator itPack = desc.packages.values().iterator(); itPack
156:                        .hasNext();) {
157:                    SpeedoPackage sp = (SpeedoPackage) itPack.next();
158:                    for (Iterator itclass = sp.classes.values().iterator(); itclass
159:                            .hasNext();) {
160:                        SpeedoClass jdoClass = (SpeedoClass) itclass.next();
161:                        if (jdoClass.jormclass == null)
162:                            throw new SpeedoException(
163:                                    "The Jorm meta information of the jdo descriptor "
164:                                            + desc.xmlFile
165:                                            + " is not complete: class "
166:                                            + jdoClass.name
167:                                            + " has not been found");
168:                        // The class meta object
169:                        addMOClass(jdoClass.jormclass, desc.mos);
170:
171:                        // Add the CompositeName which could be used in the class name def
172:                        for (Iterator it = jdoClass.jormclass.getNameDefs()
173:                                .iterator(); it.hasNext();) {
174:                            NameDef nd = (NameDef) it.next();
175:                            if (nd.isNameRef()) {
176:                                desc.mos
177:                                        .add(nd.getNameRef().getCompositeName());
178:                            }
179:                        }
180:
181:                        //The compositeName used for the reference will be added by the
182:                        // name definition of the referenced class.
183:                    }
184:                }
185:            }
186:
187:            private void addMOClass(Class mo, Set mos) {
188:                mos.add(mo);
189:                for (Iterator it = mo.getSuperClasses().iterator(); it
190:                        .hasNext();) {
191:                    addMOClass((Class) it.next(), mos);
192:                }
193:            }
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.