Source Code Cross Referenced for LifeCycleState.java in  » Database-ORM » TJDO » com » triactive » jdo » state » 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 » TJDO » com.triactive.jdo.state 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 (C) TJDO.
003:         * All rights reserved.
004:         *
005:         * This software is distributed under the terms of the TJDO License version 1.0.
006:         * See the terms of the TJDO License in the documentation provided with this software.
007:         *
008:         * $Id: LifeCycleState.java,v 1.7 2004/01/18 03:01:06 jackknifebarber Exp $
009:         */
010:
011:        package com.triactive.jdo.state;
012:
013:        import javax.jdo.Transaction;
014:        import org.apache.log4j.Category;
015:
016:        abstract class LifeCycleState {
017:            protected static final Category LOG = Category
018:                    .getInstance(LifeCycleState.class);
019:
020:            public static final int HOLLOW = 0, P_CLEAN = 1, P_DIRTY = 2,
021:                    P_NEW = 3, P_NEW_DELETED = 4, P_DELETED = 5,
022:                    P_NONTRANS = 6, T_CLEAN = 7, T_DIRTY = 8, TRANSIENT = 9,
023:                    TOTAL = 10;
024:
025:            protected boolean isPersistent;
026:            protected boolean isTransactional;
027:            protected boolean isDirty;
028:            protected boolean isNew;
029:            protected boolean isDeleted;
030:
031:            protected int stateType;
032:
033:            private static LifeCycleState states[];
034:
035:            static {
036:                states = new LifeCycleState[TOTAL];
037:
038:                states[HOLLOW] = new Hollow();
039:                states[P_CLEAN] = new PersistentClean();
040:                states[P_DIRTY] = new PersistentDirty();
041:                states[P_NEW] = new PersistentNew();
042:                states[P_NEW_DELETED] = new PersistentNewDeleted();
043:                states[P_DELETED] = new PersistentDeleted();
044:                states[P_NONTRANS] = new PersistentNontransactional();
045:                states[T_CLEAN] = new TransientClean();
046:                states[T_DIRTY] = new TransientDirty();
047:                states[TRANSIENT] = null;
048:            }
049:
050:            /**
051:             * Returns the LifeCycleState for the state constant.
052:             *
053:             * @param stateType the type as integer
054:             *
055:             * @return the type as LifeCycleState object
056:             */
057:
058:            public static LifeCycleState getLifeCycleState(int stateType) {
059:                return states[stateType];
060:            }
061:
062:            /**
063:             * Returns the type of the life cycle state
064:             *
065:             * @return the type of this life cycle state
066:             */
067:
068:            public final int stateType() {
069:                return stateType;
070:            }
071:
072:            protected final LifeCycleState changeState(StateManagerImpl sm,
073:                    int newStateType) {
074:                return changeState(sm, states[newStateType]);
075:            }
076:
077:            private LifeCycleState changeState(StateManagerImpl sm,
078:                    LifeCycleState newState) {
079:                if (LOG.isDebugEnabled())
080:                    LOG.debug(sm.toString() + ": " + this  + "->" + newState);
081:
082:                return newState;
083:            }
084:
085:            public LifeCycleState transitionRollbackState(StateManagerImpl sm,
086:                    LifeCycleState oldState) {
087:                if (isTransactional) {
088:                    if (oldState == null || !oldState.isTransactional)
089:                        sm.evictFromTransaction();
090:                } else {
091:                    if (oldState != null && oldState.isTransactional)
092:                        sm.enlistInTransaction();
093:                }
094:
095:                return changeState(sm, oldState);
096:            }
097:
098:            public LifeCycleState transitionMakePersistent(StateManagerImpl sm,
099:                    Transaction tx) {
100:                return this ;
101:            }
102:
103:            public LifeCycleState transitionDeletePersistent(
104:                    StateManagerImpl sm, Transaction tx) {
105:                return this ;
106:            }
107:
108:            public LifeCycleState transitionMakeTransactional(
109:                    StateManagerImpl sm, Transaction tx) {
110:                return this ;
111:            }
112:
113:            public LifeCycleState transitionMakeNontransactional(
114:                    StateManagerImpl sm) {
115:                return this ;
116:            }
117:
118:            public LifeCycleState transitionMakeTransient(StateManagerImpl sm) {
119:                return this ;
120:            }
121:
122:            public LifeCycleState transitionCommit(StateManagerImpl sm,
123:                    Transaction tx) {
124:                return this ;
125:            }
126:
127:            public LifeCycleState transitionRollback(StateManagerImpl sm,
128:                    Transaction tx) {
129:                return this ;
130:            }
131:
132:            public LifeCycleState transitionRefresh(StateManagerImpl sm,
133:                    Transaction tx) {
134:                return this ;
135:            }
136:
137:            public LifeCycleState transitionEvict(StateManagerImpl sm) {
138:                return this ;
139:            }
140:
141:            public LifeCycleState transitionReadField(StateManagerImpl sm,
142:                    Transaction tx) {
143:                return this ;
144:            }
145:
146:            public LifeCycleState transitionWriteField(StateManagerImpl sm,
147:                    Transaction tx) {
148:                return this ;
149:            }
150:
151:            public LifeCycleState transitionRetrieve(StateManagerImpl sm,
152:                    Transaction tx, boolean DFGOnly) {
153:                return this ;
154:            }
155:
156:            /**
157:             * Returns whether the state is persistent.
158:             */
159:
160:            public final boolean isPersistent() {
161:                return isPersistent;
162:            }
163:
164:            /**
165:             * Returns whether the state is transactional.
166:             */
167:
168:            public final boolean isTransactional() {
169:                return isTransactional;
170:            }
171:
172:            /**
173:             * Returns whether the state is dirty, ie the object has been changed
174:             * (created, updated, deleted) in this Tx.
175:             */
176:
177:            public final boolean isDirty() {
178:                return isDirty;
179:            }
180:
181:            /**
182:             * Returns whether the state represents a newly created object.
183:             */
184:
185:            public final boolean isNew() {
186:                return isNew;
187:            }
188:
189:            /**
190:             * Return whether the state represents a deleted object.
191:             */
192:
193:            public final boolean isDeleted() {
194:                return isDeleted;
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.