Source Code Cross Referenced for JDBCAuditMetaData.java in  » EJB-Server-JBoss-4.2.1 » server » org » jboss » ejb » plugins » cmp » jdbc » 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.ejb.plugins.cmp.jdbc.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.ejb.plugins.cmp.jdbc.metadata;
023:
024:        import org.jboss.deployment.DeploymentException;
025:        import org.jboss.metadata.MetaData;
026:        import org.jboss.logging.Logger;
027:        import org.w3c.dom.Element;
028:
029:        /**
030:         * Audit field meta data
031:         *
032:         * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>
033:         * @version $Revision: 57209 $
034:         */
035:        public final class JDBCAuditMetaData {
036:            // Constants ---------------------------------------
037:
038:            // Attributes --------------------------------------
039:
040:            /** The created by principal field */
041:            final private JDBCCMPFieldMetaData createdPrincipalField;
042:
043:            /** The created by time field */
044:            final private JDBCCMPFieldMetaData createdTimeField;
045:
046:            /** The last update by principal field */
047:            final private JDBCCMPFieldMetaData updatedPrincipalField;
048:
049:            /** The last update time time field */
050:            final private JDBCCMPFieldMetaData updatedTimeField;
051:
052:            /** logger */
053:            final private Logger log;
054:
055:            // Constructors ------------------------------------
056:
057:            /**
058:             * Constructs audit metadata reading
059:             * audit XML element
060:             */
061:            public JDBCAuditMetaData(JDBCEntityMetaData entityMetaData,
062:                    Element element) throws DeploymentException {
063:                log = Logger.getLogger(entityMetaData.getName());
064:
065:                Element workElement;
066:
067:                if ((workElement = MetaData.getOptionalChild(element,
068:                        "created-by")) != null) {
069:                    createdPrincipalField = constructAuditField(entityMetaData,
070:                            workElement, "audit_created_by");
071:
072:                    log.debug("created-by: " + createdPrincipalField);
073:                } else
074:                    createdPrincipalField = null;
075:
076:                if ((workElement = MetaData.getOptionalChild(element,
077:                        "created-time")) != null) {
078:                    createdTimeField = constructAuditField(entityMetaData,
079:                            workElement, "audit_created_time");
080:
081:                    log.debug("created-time: " + createdTimeField);
082:                } else
083:                    createdTimeField = null;
084:
085:                if ((workElement = MetaData.getOptionalChild(element,
086:                        "updated-by")) != null) {
087:                    updatedPrincipalField = constructAuditField(entityMetaData,
088:                            workElement, "audit_updated_by");
089:
090:                    log.debug("updated-by: " + updatedPrincipalField);
091:                } else
092:                    updatedPrincipalField = null;
093:
094:                if ((workElement = MetaData.getOptionalChild(element,
095:                        "updated-time")) != null) {
096:                    updatedTimeField = constructAuditField(entityMetaData,
097:                            workElement, "audit_updated_time");
098:
099:                    log.debug("updated-time: " + updatedTimeField);
100:                } else
101:                    updatedTimeField = null;
102:            }
103:
104:            // Public ------------------------------------------
105:
106:            public JDBCCMPFieldMetaData getCreatedPrincipalField() {
107:                return createdPrincipalField;
108:            }
109:
110:            public JDBCCMPFieldMetaData getCreatedTimeField() {
111:                return createdTimeField;
112:            }
113:
114:            public JDBCCMPFieldMetaData getUpdatedPrincipalField() {
115:                return updatedPrincipalField;
116:            }
117:
118:            public JDBCCMPFieldMetaData getUpdatedTimeField() {
119:                return updatedTimeField;
120:            }
121:
122:            // Private -----------------------------------------
123:
124:            /**
125:             * Constructs an audit locking field metadata from
126:             * XML element
127:             */
128:            private static JDBCCMPFieldMetaData constructAuditField(
129:                    JDBCEntityMetaData entity, Element element,
130:                    String defaultName) throws DeploymentException {
131:                // field name
132:                String fieldName = MetaData.getOptionalChildContent(element,
133:                        "field-name");
134:                if (fieldName == null || fieldName.trim().length() < 1)
135:                    fieldName = defaultName;
136:
137:                // column name
138:                String columnName = MetaData.getOptionalChildContent(element,
139:                        "column-name");
140:                if (columnName == null || columnName.trim().length() < 1)
141:                    columnName = defaultName;
142:
143:                // field type
144:                Class fieldType;
145:                String fieldTypeStr = MetaData.getOptionalChildContent(element,
146:                        "field-type");
147:                if (fieldTypeStr != null) {
148:                    try {
149:                        fieldType = GetTCLAction.getContextClassLoader()
150:                                .loadClass(fieldTypeStr);
151:                    } catch (ClassNotFoundException e) {
152:                        throw new DeploymentException(
153:                                "Could not load field type for audit field "
154:                                        + fieldName + ": " + fieldTypeStr);
155:                    }
156:                } else {
157:                    if (defaultName.endsWith("by"))
158:                        fieldType = String.class;
159:                    else
160:                        fieldType = java.util.Date.class;
161:                }
162:
163:                // JDBC/SQL Type
164:                int jdbcType;
165:                String sqlType;
166:                String jdbcTypeName = MetaData.getOptionalChildContent(element,
167:                        "jdbc-type");
168:                if (jdbcTypeName != null) {
169:                    jdbcType = JDBCMappingMetaData
170:                            .getJdbcTypeFromName(jdbcTypeName);
171:                    sqlType = MetaData.getUniqueChildContent(element,
172:                            "sql-type");
173:                } else {
174:                    jdbcType = Integer.MIN_VALUE;
175:                    sqlType = null;
176:                }
177:
178:                // Is the field exposed?
179:                JDBCCMPFieldMetaData result = entity
180:                        .getCMPFieldByName(fieldName);
181:
182:                if (result == null)
183:                    result = new JDBCCMPFieldMetaData(entity, fieldName,
184:                            fieldType, columnName, jdbcType, sqlType);
185:
186:                return result;
187:            }
188:        }
w___ww__._j_av_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.