Source Code Cross Referenced for TestClientObjectManager.java in  » Net » Terracotta » com » tc » object » 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 » Net » Terracotta » com.tc.object 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice.  All rights reserved.
003:         */
004:        package com.tc.object;
005:
006:        import com.tc.exception.ImplementMe;
007:        import com.tc.exception.TCNonPortableObjectError;
008:        import com.tc.object.appevent.ApplicationEvent;
009:        import com.tc.object.appevent.ApplicationEventContext;
010:        import com.tc.object.bytecode.Manageable;
011:        import com.tc.object.dna.api.DNA;
012:        import com.tc.object.tx.ClientTransactionManager;
013:        import com.tc.object.tx.optimistic.OptimisticTransactionManager;
014:        import com.tc.util.Assert;
015:
016:        import java.lang.ref.ReferenceQueue;
017:        import java.lang.ref.WeakReference;
018:        import java.util.Collection;
019:        import java.util.HashMap;
020:        import java.util.IdentityHashMap;
021:        import java.util.Map;
022:
023:        /**
024:         * @author steve
025:         */
026:        public class TestClientObjectManager implements  ClientObjectManager {
027:            public final Map objects = new HashMap();
028:            public final Map object2TCObject = new IdentityHashMap();
029:            private int idSequence = 1;
030:            private Object root = new IdentityHashMap();
031:            private boolean isManaged;
032:            private ReferenceQueue referenceQueue;
033:            private ClientTransactionManager txManager;
034:
035:            public void add(Object id, TCObject tc) {
036:                objects.put(id, tc);
037:                this .object2TCObject.put(tc.getPeerObject(), tc);
038:            }
039:
040:            public void setIsManaged(boolean b) {
041:                this .isManaged = b;
042:            }
043:
044:            public boolean getIsManaged() {
045:                return this .isManaged;
046:            }
047:
048:            public boolean isManaged(Object pojo) {
049:                return this .object2TCObject.containsKey(pojo) || isManaged;
050:            }
051:
052:            public boolean isPortableInstance(Object pojo) {
053:                return true;
054:            }
055:
056:            public boolean isPortableClass(Class clazz) {
057:                return true;
058:            }
059:
060:            public void sharedIfManaged(Object pojo) {
061:                if (isManaged(pojo)) {
062:                    lookupOrCreate(pojo);
063:                }
064:            }
065:
066:            public synchronized TCObject lookupOrCreate(Object obj) {
067:                // System.out.println(this + ".lookupOrCreate(" + obj + ")");
068:                TCObject rv = lookup(obj);
069:                if (rv == null) {
070:                    rv = new MockTCObject(new ObjectID(idSequence++), obj);
071:                    object2TCObject.put(obj, rv);
072:                    if (obj instanceof  Manageable) {
073:                        ((Manageable) obj).__tc_managed(rv);
074:                    }
075:                }
076:                return rv;
077:            }
078:
079:            private synchronized TCObject lookup(Object obj) {
080:                TCObject rv = (TCObject) object2TCObject.get(obj);
081:                return rv;
082:            }
083:
084:            public Object lookupOrCreateRoot(String name, Object candidate) {
085:                Object rv = null;
086:                if (candidate == null) {
087:                    rv = this .root;
088:                } else {
089:                    rv = candidate;
090:                }
091:                Assert.assertNotNull(rv);
092:                return rv;
093:            }
094:
095:            public TCObject lookupIfLocal(ObjectID id) {
096:                throw new ImplementMe();
097:            }
098:
099:            public Collection getAllObjectIDsAndClear(Collection c) {
100:                c.addAll(objects.keySet());
101:                return c;
102:            }
103:
104:            public TCObject lookup(ObjectID id) {
105:                System.out.println(this  + ".lookup(" + id + ")");
106:                return (TCObject) objects.get(id);
107:            }
108:
109:            public WeakReference createNewPeer(TCClass clazz, int size,
110:                    ObjectID id, ObjectID parentID) {
111:                throw new ImplementMe();
112:            }
113:
114:            public Object lookupObject(ObjectID id) {
115:                return ((TCObject) objects.get(id)).getPeerObject();
116:            }
117:
118:            public Object lookupObject(ObjectID id, ObjectID parentContext) {
119:                return ((TCObject) objects.get(id)).getPeerObject();
120:            }
121:
122:            public TCClass getOrCreateClass(Class clazz) {
123:                throw new ImplementMe();
124:            }
125:
126:            public void setTransactionManager(ClientTransactionManager txManager) {
127:                this .txManager = txManager;
128:            }
129:
130:            public void setReferenceQueue(ReferenceQueue rq) {
131:                this .referenceQueue = rq;
132:            }
133:
134:            public ReferenceQueue getReferenceQueue() {
135:                return this .referenceQueue;
136:            }
137:
138:            public ObjectID lookupExistingObjectID(Object obj) {
139:                return ((TCObject) this .object2TCObject.get(obj)).getObjectID();
140:            }
141:
142:            public void markReferenced(TCObject tcobj) {
143:                // mark referenced
144:            }
145:
146:            public void shutdown() {
147:                //
148:            }
149:
150:            public ClientTransactionManager getTransactionManager() {
151:                return txManager;
152:            }
153:
154:            public Class getClassFor(String className, String loaderDesc) {
155:                throw new ImplementMe();
156:            }
157:
158:            public TCObject lookupExistingOrNull(Object pojo) {
159:                //    if (isManaged) {
160:                //      lookupOrCreate(pojo);
161:                //    }
162:
163:                return (TCObject) this .object2TCObject.get(pojo);
164:            }
165:
166:            public Object lookupRoot(String name) {
167:                throw new ImplementMe();
168:            }
169:
170:            public void unpause() {
171:                return;
172:            }
173:
174:            public void pause() {
175:                return;
176:            }
177:
178:            public void starting() {
179:                return;
180:            }
181:
182:            public void checkPortabilityOfField(Object value, String fieldName,
183:                    Object pojo) throws TCNonPortableObjectError {
184:                return;
185:            }
186:
187:            public void checkPortabilityOfLogicalAction(Object[] params,
188:                    int index, String methodName, Object pojo)
189:                    throws TCNonPortableObjectError {
190:                return;
191:            }
192:
193:            public WeakReference createNewPeer(TCClass clazz, DNA dna) {
194:                throw new ImplementMe();
195:            }
196:
197:            public Object deepCopy(Object source,
198:                    OptimisticTransactionManager optimisticTxManager) {
199:                throw new ImplementMe();
200:            }
201:
202:            public Object createNewCopyInstance(Object source, Object parent) {
203:                throw new ImplementMe();
204:            }
205:
206:            public Object createParentCopyInstanceIfNecessary(Map visited,
207:                    Map cloned, Object v) {
208:                throw new ImplementMe();
209:            }
210:
211:            public void replaceRootIDIfNecessary(String rootName,
212:                    ObjectID newRootID) {
213:                throw new ImplementMe();
214:            }
215:
216:            public Object lookupOrCreateRoot(String name, Object obj,
217:                    boolean dsoFinal) {
218:                throw new ImplementMe();
219:            }
220:
221:            public TCObject lookupOrShare(Object pojo) {
222:                throw new ImplementMe();
223:            }
224:
225:            public boolean isCreationInProgress() {
226:                return false;
227:            }
228:
229:            public void addPendingCreateObjectsToTransaction() {
230:                // do nothing
231:            }
232:
233:            public boolean hasPendingCreateObjects() {
234:                return false;
235:            }
236:
237:            public Object lookupObjectNoDepth(ObjectID id) {
238:                throw new ImplementMe();
239:            }
240:
241:            public Object lookupOrCreateRootNoDepth(String rootName,
242:                    Object object) {
243:                throw new ImplementMe();
244:            }
245:
246:            public Object createOrReplaceRoot(String rootName, Object r) {
247:                throw new ImplementMe();
248:            }
249:
250:            public void storeObjectHierarchy(Object pojo,
251:                    ApplicationEventContext context) {
252:                throw new ImplementMe();
253:            }
254:
255:            public void sendApplicationEvent(Object pojo, ApplicationEvent event) {
256:                throw new ImplementMe();
257:            }
258:
259:            public Object cloneAndInvokeLogicalOperation(Object pojo,
260:                    String methodName, Object[] parameters) {
261:                throw new ImplementMe();
262:            }
263:
264:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.