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


001:        //$Id: FieldInterceptorImpl.java 10209 2006-08-03 20:35:26Z steve.ebersole@jboss.com $
002:        package org.hibernate.intercept.javassist;
003:
004:        import java.io.Serializable;
005:        import java.util.Set;
006:
007:        import org.hibernate.bytecode.javassist.FieldHandler;
008:        import org.hibernate.intercept.AbstractFieldInterceptor;
009:        import org.hibernate.engine.SessionImplementor;
010:        import org.hibernate.proxy.HibernateProxy;
011:        import org.hibernate.proxy.LazyInitializer;
012:
013:        /**
014:         * A field-level interceptor that initializes lazily fetched properties.
015:         * This interceptor can be attached to classes instrumented by Javassist.
016:         * Note that this implementation assumes that the instance variable
017:         * name is the same as the name of the persistent property that must
018:         * be loaded.
019:         * </p>
020:         * Note: most of the interesting functionality here is farmed off
021:         * to the super-class.  The stuff here mainly acts as an adapter to the
022:         * Javassist-specific functionality, routing interception through
023:         * the super-class's intercept() method
024:         *
025:         * @author Steve Ebersole
026:         */
027:        public final class FieldInterceptorImpl extends
028:                AbstractFieldInterceptor implements  FieldHandler, Serializable {
029:
030:            /**
031:             * Package-protected constructor.
032:             *
033:             * @param session
034:             * @param uninitializedFields
035:             * @param entityName
036:             */
037:            FieldInterceptorImpl(SessionImplementor session,
038:                    Set uninitializedFields, String entityName) {
039:                super (session, uninitializedFields, entityName);
040:            }
041:
042:            // FieldHandler impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
043:
044:            public boolean readBoolean(Object target, String name,
045:                    boolean oldValue) {
046:                return ((Boolean) intercept(target, name,
047:                        oldValue ? Boolean.TRUE : Boolean.FALSE))
048:                        .booleanValue();
049:            }
050:
051:            public byte readByte(Object target, String name, byte oldValue) {
052:                return ((Byte) intercept(target, name, new Byte(oldValue)))
053:                        .byteValue();
054:            }
055:
056:            public char readChar(Object target, String name, char oldValue) {
057:                return ((Character) intercept(target, name, new Character(
058:                        oldValue))).charValue();
059:            }
060:
061:            public double readDouble(Object target, String name, double oldValue) {
062:                return ((Double) intercept(target, name, new Double(oldValue)))
063:                        .doubleValue();
064:            }
065:
066:            public float readFloat(Object target, String name, float oldValue) {
067:                return ((Float) intercept(target, name, new Float(oldValue)))
068:                        .floatValue();
069:            }
070:
071:            public int readInt(Object target, String name, int oldValue) {
072:                return ((Integer) intercept(target, name, new Integer(oldValue)))
073:                        .intValue();
074:            }
075:
076:            public long readLong(Object target, String name, long oldValue) {
077:                return ((Long) intercept(target, name, new Long(oldValue)))
078:                        .longValue();
079:            }
080:
081:            public short readShort(Object target, String name, short oldValue) {
082:                return ((Short) intercept(target, name, new Short(oldValue)))
083:                        .shortValue();
084:            }
085:
086:            public Object readObject(Object target, String name, Object oldValue) {
087:                Object value = intercept(target, name, oldValue);
088:                if (value instanceof  HibernateProxy) {
089:                    LazyInitializer li = ((HibernateProxy) value)
090:                            .getHibernateLazyInitializer();
091:                    if (li.isUnwrap()) {
092:                        value = li.getImplementation();
093:                    }
094:                }
095:                return value;
096:            }
097:
098:            public boolean writeBoolean(Object target, String name,
099:                    boolean oldValue, boolean newValue) {
100:                dirty();
101:                intercept(target, name, oldValue ? Boolean.TRUE : Boolean.FALSE);
102:                return newValue;
103:            }
104:
105:            public byte writeByte(Object target, String name, byte oldValue,
106:                    byte newValue) {
107:                dirty();
108:                intercept(target, name, new Byte(oldValue));
109:                return newValue;
110:            }
111:
112:            public char writeChar(Object target, String name, char oldValue,
113:                    char newValue) {
114:                dirty();
115:                intercept(target, name, new Character(oldValue));
116:                return newValue;
117:            }
118:
119:            public double writeDouble(Object target, String name,
120:                    double oldValue, double newValue) {
121:                dirty();
122:                intercept(target, name, new Double(oldValue));
123:                return newValue;
124:            }
125:
126:            public float writeFloat(Object target, String name, float oldValue,
127:                    float newValue) {
128:                dirty();
129:                intercept(target, name, new Float(oldValue));
130:                return newValue;
131:            }
132:
133:            public int writeInt(Object target, String name, int oldValue,
134:                    int newValue) {
135:                dirty();
136:                intercept(target, name, new Integer(oldValue));
137:                return newValue;
138:            }
139:
140:            public long writeLong(Object target, String name, long oldValue,
141:                    long newValue) {
142:                dirty();
143:                intercept(target, name, new Long(oldValue));
144:                return newValue;
145:            }
146:
147:            public short writeShort(Object target, String name, short oldValue,
148:                    short newValue) {
149:                dirty();
150:                intercept(target, name, new Short(oldValue));
151:                return newValue;
152:            }
153:
154:            public Object writeObject(Object target, String name,
155:                    Object oldValue, Object newValue) {
156:                dirty();
157:                intercept(target, name, oldValue);
158:                return newValue;
159:            }
160:
161:            public String toString() {
162:                return "FieldInterceptorImpl(" + "entityName="
163:                        + getEntityName() + ",dirty=" + isDirty()
164:                        + ",uninitializedFields=" + getUninitializedFields()
165:                        + ')';
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.