Source Code Cross Referenced for ObjectSpace.java in  » Database-DBMS » Ozone-1.1 » org » ozoneDB » core » classicStore » 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 DBMS » Ozone 1.1 » org.ozoneDB.core.classicStore 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // You can redistribute this software and/or modify it under the terms of
002:        // the Ozone Core License version 1 published by ozone-db.org.
003:        //
004:        // The original code and portions created by SMB are
005:        // Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
006:        //
007:        // $Id: ObjectSpace.java,v 1.1 2001/12/18 10:31:31 per_nyfelt Exp $
008:
009:        package org.ozoneDB.core.classicStore;
010:
011:        import java.io.*;
012:        import org.ozoneDB.DxLib.*;
013:        import org.ozoneDB.*;
014:        import org.ozoneDB.core.*;
015:        import org.ozoneDB.util.*;
016:
017:        /** */
018:        public final class ObjectSpace extends Object {
019:            /** */
020:            final static long serialVersionUID = 2;
021:            final static byte subSerialVersionUID = 1;
022:
023:            /** The environment of this object. */
024:            protected transient Env env;
025:            protected transient ClusterSpace clusterSpace;
026:
027:            /** */
028:            protected DxMap objectTable;
029:            protected DxMap nameTable;
030:
031:            /**
032:             */
033:            public ObjectSpace(Env _env) {
034:                env = _env;
035:                clusterSpace = new ClusterSpace(_env);
036:            }
037:
038:            /**
039:             */
040:            public void startup() throws Exception {
041:                env.logWriter.newEntry(this , "startup...", LogWriter.INFO);
042:                int tableBuffSize = env.config.intProperty(
043:                        Setup.CS_TABLE_BUFF_SIZE, -1);
044:                if (tableBuffSize == -1) {
045:                    env.logWriter.newEntry(this , "Property "
046:                            + Setup.CS_TABLE_BUFF_SIZE + " is not set.",
047:                            LogWriter.WARN);
048:                    tableBuffSize = 20;
049:                }
050:                //objectTable = new DxDiskHashMap (env.dir + Env.OS_DIR + File.separator + "idtable", tableBuffSize / 256, 12);
051:                objectTable = new DxHashMap(1000);
052:                nameTable = new DxHashMap(10);
053:                clusterSpace.startup();
054:            }
055:
056:            /**
057:             */
058:            public void shutdown() throws Exception {
059:                env.logWriter.newEntry(this , "shutdown...", LogWriter.INFO);
060:                clusterSpace.shutdown();
061:                //objectTable.printCacheStatistics();
062:                if (objectTable instanceof  DxDiskHashMap) {
063:                    ((DxDiskHashMap) objectTable).cleanFiles();
064:                }
065:            }
066:
067:            /**
068:             */
069:            public synchronized void addObject(ObjectContainer container)
070:                    throws Exception {
071:                //use a copy of the objID because objectTable is a diskHash
072:                objectTable.addForKey(container, container.id().clone());
073:                if (container.name() != null) {
074:                    nameTable
075:                            .addForKey(container, new String(container.name()));
076:                }
077:            }
078:
079:            /**
080:             * Creates a new object container for the given target with the given oid
081:             * and an optional name.
082:             */
083:            public synchronized ObjectContainer newContainer(Transaction ta,
084:                    OzoneCompatible target, ObjectID objID,
085:                    Permissions permissions) throws ClassicStoreExc {
086:                ClassicObjectContainer container = new ClassicObjectContainer(
087:                        target, objID, permissions);
088:                if (!objectTable.addForKey(container, objID.clone())) {
089:                    throw new ClassicStoreExc("ObjectID " + objID
090:                            + " already exists !");
091:                }
092:
093:                return container;
094:            }
095:
096:            /**
097:             * @param id The object id to search for.
098:             * @return The object container with the given id or null.
099:             */
100:            public ObjectContainer objectForID(ObjectID id) {
101:                return (ObjectContainer) objectTable.elementForKey(id);
102:            }
103:
104:            /**
105:             * Applies a name to an object.
106:             * @param container The container to name.
107:             * @param name The new name of the container.
108:             */
109:            public void nameObject(ObjectContainer container, String name)
110:                    throws ClassicStoreExc {
111:                if (container.name() != null) {
112:                    nameTable.removeForKey(container.name());
113:                }
114:                if (name != null) {
115:                    if (!nameTable.addForKey(container, new String(name))) {
116:                        throw new ClassicStoreExc("Name '" + name
117:                                + "' already exists !");
118:                    }
119:                    container.nameTarget(name);
120:                }
121:            }
122:
123:            /**
124:             * @param name
125:             * @return The object container with the given name.
126:             */
127:            public ObjectContainer objectForName(String name) {
128:                return (ObjectContainer) nameTable.elementForKey(name);
129:            }
130:
131:            /**
132:             * entfernt ObjectContainer fuer entsprechende ObjectID;
133:             */
134:            public synchronized void deleteObject(ObjectContainer toRemove) {
135:                synchronized (toRemove) {
136:                    objectTable.removeForKey(toRemove.id());
137:                    if (toRemove.name() != null) {
138:                        nameTable.removeForKey(toRemove.name());
139:                    }
140:                }
141:            }
142:
143:            /** */
144:            public synchronized void prepareCommitObjects(Transaction ta)
145:                    throws Exception {
146:                env.logWriter.newEntry(this ,
147:                        "prepareCommitObjects: transaction " + ta.taID(),
148:                        LogWriter.DEBUG3);
149:
150:                //at first we have to insert new objects + containers into the object
151:                //space, so that we have access to them while further commiting
152:                DxListBag created = new DxListBag();
153:                DxListBag modified = new DxListBag();
154:                DxIterator it = ta.idTable.iterator();
155:                ClassicObjectContainer container;
156:
157:                while ((container = (ClassicObjectContainer) it.next()) != null) {
158:                    if (container.isCreated()) {
159:                        addObject(container);
160:                        created.add(container);
161:                    } else {
162:                        if (container.lockLevel(ta) > Lock.LEVEL_READ) {
163:                            modified.add(container.id());
164:                        }
165:                    }
166:                }
167:
168:                //make all changes persistent
169:                clusterSpace.prepareCommit(ta.taID(), created, modified);
170:
171:                // remove all deleted objects from the object space _after_ commiting
172:                // them; otherwise we wouldn't have access to them while commiting
173:                // commit all written objects _after_ we know everthing worked fine;
174:                // if not, the transaction has to abort
175:                it = ta.idTable.iterator();
176:                while ((container = (ClassicObjectContainer) it.next()) != null) {
177:                    if (container.isDeleted()) {
178:                        deleteObject(container);
179:                    } else {
180:                        container.commitTarget(ta);
181:                    }
182:                }
183:            }
184:
185:            /** */
186:            public synchronized void commitObjects(Transaction ta) {
187:                clusterSpace.commitTransaction(ta.taID());
188:            }
189:
190:            /** */
191:            public synchronized void abortObjects(Transaction ta)
192:                    throws Exception {
193:                DxIterator it = ta.idTable.iterator();
194:                ClassicObjectContainer container;
195:                while ((container = (ClassicObjectContainer) it.next()) != null) {
196:                    container.abortTarget(ta);
197:                }
198:                clusterSpace.abortTransaction(ta.taID());
199:            }
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.