Source Code Cross Referenced for DynamicMapperImpl.java in  » Database-ORM » ODAL » com » completex » objective » components » persistency » mapper » impl » 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 » ODAL » com.completex.objective.components.persistency.mapper.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.completex.objective.components.persistency.mapper.impl;
002:
003:        import com.completex.objective.components.persistency.mapper.Mapper;
004:        import com.completex.objective.components.persistency.mapper.ValueHandler;
005:        import com.completex.objective.components.persistency.mapper.MappingHandler;
006:        import com.completex.objective.components.persistency.PersistentObject;
007:        import com.completex.objective.components.log.Log;
008:
009:        /**
010:         * Implementation of the Mapper based on class reflection.
011:         * Use of this class makes sense when the Persistent Objects and the correponding 
012:         * POJO beans are close in structure. If their structure is the same this class
013:         * will perform the conversion based on Persistent Objects/POJO beans map (see the <t>map()</t> method).
014:         * 
015:         * @see Mapper
016:         * @author Gennady Krizhevsky
017:         */
018:        public class DynamicMapperImpl implements  Mapper {
019:
020:            private Log logger = Log.NULL_LOGGER;
021:
022:            private boolean validatePo = true;
023:
024:            protected final Object mapLock = new Object();
025:
026:            private final DynamicPoToBeanMapperImpl poToBeanMapper;
027:            private final DynamicBeanToPoMapperImpl beanToPoMapper;
028:
029:            public DynamicMapperImpl() {
030:                poToBeanMapper = new DynamicPoToBeanMapperImpl(this );
031:                beanToPoMapper = new DynamicBeanToPoMapperImpl(this );
032:            }
033:
034:            public void map(Class beanClass, Class poClass) {
035:                synchronized (mapLock) {
036:                    validate(poClass);
037:                    poToBeanMapper.map(poClass, beanClass);
038:                    beanToPoMapper.map(beanClass, poClass);
039:                }
040:            }
041:
042:            public void remap(Class beanClass, Class poClass) {
043:                synchronized (mapLock) {
044:                    validate(poClass);
045:                    poToBeanMapper.remap(poClass, beanClass);
046:                    beanToPoMapper.remap(beanClass, poClass);
047:                }
048:            }
049:
050:            protected void validate(Class poClass) {
051:                if (isValidatePo()
052:                        && !PersistentObject.class.isAssignableFrom(poClass)) {
053:                    throw new IllegalArgumentException(
054:                            "poClass argument is not assignable from PersistentObject");
055:                }
056:            }
057:
058:            /**
059:             * Registers handler to overrride the default value mapping from PO to POJO bean.
060:             * 
061:             * @see ValueHandler
062:             * @param valuePath value path
063:             * @param valueHandler value handler
064:             */
065:            public void registerPoToBeanValueHandler(String valuePath,
066:                    ValueHandler valueHandler) {
067:                synchronized (mapLock) {
068:                    poToBeanMapper
069:                            .registerValueHandler(valuePath, valueHandler);
070:                }
071:            }
072:
073:            /**
074:             * Registers handler to overrride the default value mapping from POJO bean to PO.
075:             * 
076:             * @see ValueHandler
077:             * @param valuePath value path
078:             * @param valueHandler value handler
079:             */
080:            public void registerBeanToPoValueHandler(String valuePath,
081:                    ValueHandler valueHandler) {
082:                synchronized (mapLock) {
083:                    beanToPoMapper
084:                            .registerValueHandler(valuePath, valueHandler);
085:                }
086:            }
087:
088:            public boolean mappingExists(Class beanClass, Class poClass) {
089:                return beanToPoMapper.mappingExists(poClass, beanClass);
090:            }
091:
092:            public Object convertPoToBean(Object po, boolean forModification) {
093:                return poToBeanMapper.convert(po, forModification);
094:            }
095:
096:            public Object convertBeanToPo(Object bean, boolean forModification) {
097:                return beanToPoMapper.convert(bean, forModification);
098:            }
099:
100:            public Log getLogger() {
101:                return logger;
102:            }
103:
104:            public void setLogger(Log logger) {
105:                if (logger != null) {
106:                    this .logger = logger;
107:                    if (poToBeanMapper != null) {
108:                        poToBeanMapper.setLogger(logger);
109:                    }
110:                    if (beanToPoMapper != null) {
111:                        beanToPoMapper.setLogger(logger);
112:                    }
113:                }
114:            }
115:
116:            public boolean isValidatePo() {
117:                return validatePo;
118:            }
119:
120:            public void setValidatePo(boolean validatePo) {
121:                this .validatePo = validatePo;
122:            }
123:
124:            public DynamicPoToBeanMapperImpl getPoToBeanMapper() {
125:                return poToBeanMapper;
126:            }
127:
128:            public DynamicBeanToPoMapperImpl getBeanToPoMapper() {
129:                return beanToPoMapper;
130:            }
131:
132:        }
w__ww.ja_va__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.