Source Code Cross Referenced for JournalledFileStore.java in  » Database-DBMS » mckoi » com » mckoi » store » 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 » mckoi » com.mckoi.store 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * com.mckoi.store.ScatteringFileStore  24 Jan 2003
003:         *
004:         * Mckoi SQL Database ( http://www.mckoi.com/database )
005:         * Copyright (C) 2000, 2001, 2002  Diehl and Associates, Inc.
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * Version 2 as published by the Free Software Foundation.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License Version 2 for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * Version 2 along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         * Change Log:
021:         * 
022:         * 
023:         */package com.mckoi.store;
024:
025:        import java.io.IOException;
026:
027:        /**
028:         * An implementation of AbstractStore that persists to an underlying data
029:         * format via a robust journalling system that supports check point and crash
030:         * recovery.  Note that this object is a bridge between the Store API and the
031:         * journalled behaviour defined in LoggingBufferManager, JournalledSystem and
032:         * the StoreDataAccessor implementations.
033:         * <p>
034:         * Note that access to the resources is abstracted via a 'resource_name'
035:         * string.  The LoggingBufferManager object converts the resource name into a
036:         * concrete object that accesses the actual data.
037:         *
038:         * @author Tobias Downer
039:         */
040:
041:        public final class JournalledFileStore extends AbstractStore {
042:
043:            /**
044:             * The name of the resource.
045:             */
046:            private final String resource_name;
047:
048:            /**
049:             * The buffering strategy for accessing the data in an underlying file.
050:             */
051:            private final LoggingBufferManager buffer_manager;
052:
053:            /**
054:             * The JournalledResource object that's used to journal all read/write
055:             * operations to the above 'store_accessor'.
056:             */
057:            private JournalledResource store_resource;
058:
059:            /**
060:             * Constructs the ScatteringFileStore.
061:             */
062:            public JournalledFileStore(String resource_name,
063:                    LoggingBufferManager buffer_manager, boolean read_only) {
064:                super (read_only);
065:                this .resource_name = resource_name;
066:                this .buffer_manager = buffer_manager;
067:
068:                // Create the store resource object for this resource name
069:                this .store_resource = buffer_manager
070:                        .createResource(resource_name);
071:            }
072:
073:            // ---------- JournalledFileStore methods ----------
074:
075:            /**
076:             * Deletes this store from the file system.  This operation should only be
077:             * used when the store is NOT open.
078:             */
079:            public boolean delete() throws IOException {
080:                store_resource.delete();
081:                return true;
082:            }
083:
084:            /**
085:             * Returns true if this store exists in the file system.
086:             */
087:            public boolean exists() throws IOException {
088:                return store_resource.exists();
089:            }
090:
091:            public void lockForWrite() {
092:                try {
093:                    buffer_manager.lockForWrite();
094:                } catch (InterruptedException e) {
095:                    throw new Error("Interrupted: " + e.getMessage());
096:                }
097:            }
098:
099:            public void unlockForWrite() {
100:                buffer_manager.unlockForWrite();
101:            }
102:
103:            // ---------- Implemented from AbstractStore ----------
104:
105:            /**
106:             * Internally opens the backing area.  If 'read_only' is true then the
107:             * store is opened in read only mode.
108:             */
109:            protected void internalOpen(boolean read_only) throws IOException {
110:                store_resource.open(read_only);
111:            }
112:
113:            /**
114:             * Internally closes the backing area.
115:             */
116:            protected void internalClose() throws IOException {
117:                buffer_manager.close(store_resource);
118:            }
119:
120:            protected int readByteFrom(long position) throws IOException {
121:                return buffer_manager.readByteFrom(store_resource, position);
122:            }
123:
124:            protected int readByteArrayFrom(long position, byte[] buf, int off,
125:                    int len) throws IOException {
126:                return buffer_manager.readByteArrayFrom(store_resource,
127:                        position, buf, off, len);
128:            }
129:
130:            protected void writeByteTo(long position, int b) throws IOException {
131:                buffer_manager.writeByteTo(store_resource, position, b);
132:            }
133:
134:            protected void writeByteArrayTo(long position, byte[] buf, int off,
135:                    int len) throws IOException {
136:                buffer_manager.writeByteArrayTo(store_resource, position, buf,
137:                        off, len);
138:            }
139:
140:            protected long endOfDataAreaPointer() throws IOException {
141:                return buffer_manager.getDataAreaSize(store_resource);
142:            }
143:
144:            protected void setDataAreaSize(long new_size) throws IOException {
145:                buffer_manager.setDataAreaSize(store_resource, new_size);
146:            }
147:
148:            // For diagnosis
149:
150:            public String toString() {
151:                return "[ JournalledFileStore: " + resource_name + " ]";
152:            }
153:
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.