Source Code Cross Referenced for FieldInterceptionHelper.java in  » Database-ORM » hibernate » org » hibernate » intercept » 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 » hibernate » org.hibernate.intercept 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.hibernate.intercept;
002:
003:        import org.hibernate.engine.SessionImplementor;
004:        import org.hibernate.intercept.cglib.CGLIBHelper;
005:        import org.hibernate.intercept.javassist.JavassistHelper;
006:
007:        import java.util.Set;
008:
009:        /**
010:         * Helper class for dealing with enhanced entity classes.
011:         *
012:         * @author Steve Ebersole
013:         */
014:        public class FieldInterceptionHelper {
015:
016:            // VERY IMPORTANT!!!! - This class needs to be free of any static references
017:            // to any CGLIB or Javassist classes.  Otherwise, users will always need both
018:            // on their classpaths no matter which (if either) they use.
019:            //
020:            // Another option here would be to remove the Hibernate.isPropertyInitialized()
021:            // method and have the users go through the SessionFactory to get this information.
022:
023:            private FieldInterceptionHelper() {
024:            }
025:
026:            public static boolean isInstrumented(Class entityClass) {
027:                Class[] definedInterfaces = entityClass.getInterfaces();
028:                for (int i = 0; i < definedInterfaces.length; i++) {
029:                    if ("net.sf.cglib.transform.impl.InterceptFieldEnabled"
030:                            .equals(definedInterfaces[i].getName())
031:                            || "org.hibernate.bytecode.javassist.FieldHandled"
032:                                    .equals(definedInterfaces[i].getName())) {
033:                        return true;
034:                    }
035:                }
036:                return false;
037:            }
038:
039:            public static boolean isInstrumented(Object entity) {
040:                return entity != null && isInstrumented(entity.getClass());
041:            }
042:
043:            public static FieldInterceptor extractFieldInterceptor(Object entity) {
044:                if (entity == null) {
045:                    return null;
046:                }
047:                Class[] definedInterfaces = entity.getClass().getInterfaces();
048:                for (int i = 0; i < definedInterfaces.length; i++) {
049:                    if ("net.sf.cglib.transform.impl.InterceptFieldEnabled"
050:                            .equals(definedInterfaces[i].getName())) {
051:                        // we have a CGLIB enhanced entity
052:                        return CGLIBHelper.extractFieldInterceptor(entity);
053:                    } else if ("org.hibernate.bytecode.javassist.FieldHandled"
054:                            .equals(definedInterfaces[i].getName())) {
055:                        // we have a Javassist enhanced entity
056:                        return JavassistHelper.extractFieldInterceptor(entity);
057:                    }
058:                }
059:                return null;
060:            }
061:
062:            public static FieldInterceptor injectFieldInterceptor(
063:                    Object entity, String entityName,
064:                    Set uninitializedFieldNames, SessionImplementor session) {
065:                if (entity != null) {
066:                    Class[] definedInterfaces = entity.getClass()
067:                            .getInterfaces();
068:                    for (int i = 0; i < definedInterfaces.length; i++) {
069:                        if ("net.sf.cglib.transform.impl.InterceptFieldEnabled"
070:                                .equals(definedInterfaces[i].getName())) {
071:                            // we have a CGLIB enhanced entity
072:                            return CGLIBHelper.injectFieldInterceptor(entity,
073:                                    entityName, uninitializedFieldNames,
074:                                    session);
075:                        } else if ("org.hibernate.bytecode.javassist.FieldHandled"
076:                                .equals(definedInterfaces[i].getName())) {
077:                            // we have a Javassist enhanced entity
078:                            return JavassistHelper.injectFieldInterceptor(
079:                                    entity, entityName,
080:                                    uninitializedFieldNames, session);
081:                        }
082:                    }
083:                }
084:                return null;
085:            }
086:
087:            public static void clearDirty(Object entity) {
088:                FieldInterceptor interceptor = extractFieldInterceptor(entity);
089:                if (interceptor != null) {
090:                    interceptor.clearDirty();
091:                }
092:            }
093:
094:            public static void markDirty(Object entity) {
095:                FieldInterceptor interceptor = extractFieldInterceptor(entity);
096:                if (interceptor != null) {
097:                    interceptor.dirty();
098:                }
099:            }
100:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.