Source Code Cross Referenced for LinkedHashMapManagedObjectState.java in  » Net » Terracotta » com » tc » objectserver » managedobject » 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.objectserver.managedobject 
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.objectserver.managedobject;
005:
006:        import com.tc.object.ObjectID;
007:        import com.tc.object.SerializationUtil;
008:        import com.tc.object.dna.api.DNACursor;
009:        import com.tc.object.dna.api.DNAWriter;
010:        import com.tc.object.dna.api.LogicalAction;
011:        import com.tc.object.dna.api.PhysicalAction;
012:        import com.tc.objectserver.mgmt.ManagedObjectFacade;
013:        import com.tc.util.Assert;
014:
015:        import java.io.IOException;
016:        import java.io.ObjectInput;
017:        import java.io.ObjectOutput;
018:        import java.util.Iterator;
019:        import java.util.LinkedHashMap;
020:        import java.util.Map.Entry;
021:
022:        /**
023:         * state for maps
024:         */
025:        public class LinkedHashMapManagedObjectState extends
026:                PartialMapManagedObjectState {
027:            private static final String ACCESS_ORDER_FIELDNAME = "java.util.LinkedHashMap.accessOrder";
028:            private boolean accessOrder = false;
029:
030:            // TODO:: Come back and make this partial too
031:            LinkedHashMapManagedObjectState(long classID) {
032:                super (classID, new LinkedHashMap(1));
033:            }
034:
035:            protected LinkedHashMapManagedObjectState(ObjectInput in)
036:                    throws IOException {
037:                super (in);
038:            }
039:
040:            public void apply(ObjectID objectID, DNACursor cursor,
041:                    BackReferences includeIDs) throws IOException {
042:                if (!cursor.next()) {
043:                    return;
044:                }
045:                Object action = cursor.getAction();
046:                if (action instanceof  PhysicalAction) {
047:                    PhysicalAction physicalAction = (PhysicalAction) action;
048:                    Assert.assertEquals(ACCESS_ORDER_FIELDNAME, physicalAction
049:                            .getFieldName());
050:                    setAccessOrder(physicalAction.getObject());
051:                } else {
052:                    LogicalAction logicalAction = (LogicalAction) action;
053:                    int method = logicalAction.getMethod();
054:                    Object[] params = logicalAction.getParameters();
055:                    applyMethod(objectID, includeIDs, method, params);
056:                }
057:
058:                while (cursor.next()) {
059:                    LogicalAction logicalAction = cursor.getLogicalAction();
060:                    int method = logicalAction.getMethod();
061:                    Object[] params = logicalAction.getParameters();
062:                    applyMethod(objectID, includeIDs, method, params);
063:                }
064:            }
065:
066:            protected void applyMethod(ObjectID objectID,
067:                    BackReferences includeIDS, int method, Object[] params) {
068:                switch (method) {
069:                case SerializationUtil.GET:
070:                    ((LinkedHashMap) references).get(params[0]);
071:                    break;
072:                default:
073:                    super .applyMethod(objectID, includeIDS, method, params);
074:                }
075:            }
076:
077:            private void setAccessOrder(Object accessOrderObject) {
078:                try {
079:                    Assert.assertTrue(accessOrderObject instanceof  Boolean);
080:                    accessOrder = ((Boolean) accessOrderObject).booleanValue();
081:                    references = new LinkedHashMap(1, 0.75f, accessOrder);
082:                } catch (Exception e) {
083:                    throw new RuntimeException(e);
084:                }
085:            }
086:
087:            public void dehydrate(ObjectID objectID, DNAWriter writer) {
088:                writer.addPhysicalAction(ACCESS_ORDER_FIELDNAME, new Boolean(
089:                        accessOrder));
090:                super .dehydrate(objectID, writer);
091:            }
092:
093:            // TODO: The Facade does not include the access order.
094:            public ManagedObjectFacade createFacade(ObjectID objectID,
095:                    String className, int limit) {
096:                return super .createFacade(objectID, className, limit);
097:            }
098:
099:            public byte getType() {
100:                return LINKED_HASHMAP_TYPE;
101:            }
102:
103:            //TODO:: Until partial collections support is enabled for this class
104:            protected void basicWriteTo(ObjectOutput out) throws IOException {
105:                out.writeBoolean(accessOrder);
106:                out.writeInt(references.size());
107:                for (Iterator i = references.entrySet().iterator(); i.hasNext();) {
108:                    Entry entry = (Entry) i.next();
109:                    out.writeObject(entry.getKey());
110:                    out.writeObject(entry.getValue());
111:                }
112:            }
113:
114:            // TODO:: Until CollectionsPersistor saves retrieves data in references map.
115:            static MapManagedObjectState readFrom(ObjectInput in)
116:                    throws IOException, ClassNotFoundException {
117:                LinkedHashMapManagedObjectState linkedsmo = new LinkedHashMapManagedObjectState(
118:                        in);
119:                linkedsmo.accessOrder = in.readBoolean();
120:                int size = in.readInt();
121:                LinkedHashMap map = new LinkedHashMap(size, 0.75f,
122:                        linkedsmo.accessOrder);
123:                for (int i = 0; i < size; i++) {
124:                    Object key = in.readObject();
125:                    Object value = in.readObject();
126:                    map.put(key, value);
127:                }
128:                linkedsmo.setMap(map);
129:                return linkedsmo;
130:            }
131:
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.