Source Code Cross Referenced for DirStorageFactory.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » io » 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 » db derby 10.2 » org.apache.derby.impl.io 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.io.DirStorageFactory
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.io;
023:
024:        import org.apache.derby.iapi.services.sanity.SanityManager;
025:
026:        import org.apache.derby.io.WritableStorageFactory;
027:        import org.apache.derby.io.StorageFile;
028:        import org.apache.derby.io.StorageRandomAccessFile;
029:
030:        import java.io.File;
031:        import java.io.FileNotFoundException;
032:        import java.io.FileOutputStream;
033:        import java.io.FileInputStream;
034:        import java.io.InputStream;
035:        import java.io.OutputStream;
036:        import java.io.IOException;
037:        import java.io.SyncFailedException;
038:
039:        import java.util.Properties;
040:
041:        /**
042:         * This class provides a disk based implementation of the StorageFactory interface. It is used by the
043:         * database engine to access persistent data and transaction logs under the directory (default) subsubprotocol.
044:         */
045:
046:        public class DirStorageFactory extends BaseStorageFactory implements 
047:                WritableStorageFactory {
048:            /**
049:             * Construct a StorageFile from a path name.
050:             *
051:             * @param path The path name of the file
052:             *
053:             * @return A corresponding StorageFile object
054:             */
055:            public final StorageFile newStorageFile(String path) {
056:                return newPersistentFile(path);
057:            }
058:
059:            /**
060:             * Construct a StorageFile from a directory and file name.
061:             *
062:             * @param directoryName The directory part of the path name.
063:             * @param fileName The name of the file within the directory.
064:             *
065:             * @return A corresponding StorageFile object
066:             */
067:            public final StorageFile newStorageFile(String directoryName,
068:                    String fileName) {
069:                return newPersistentFile(directoryName, fileName);
070:            }
071:
072:            /**
073:             * Construct a StorageFile from a directory and file name.
074:             *
075:             * @param directoryName The directory part of the path name.
076:             * @param fileName The name of the file within the directory.
077:             *
078:             * @return A corresponding StorageFile object
079:             */
080:            public final StorageFile newStorageFile(StorageFile directoryName,
081:                    String fileName) {
082:                return newPersistentFile(directoryName, fileName);
083:            }
084:
085:            /**
086:             * Construct a persistent StorageFile from a path name.
087:             *
088:             * @param path The path name of the file. Guaranteed not to be in the temporary file directory. If null
089:             *             then the database directory should be returned.
090:             *
091:             * @return A corresponding StorageFile object
092:             */
093:            StorageFile newPersistentFile(String path) {
094:                if (path == null)
095:                    return new DirFile(dataDirectory);
096:                return new DirFile(dataDirectory, path);
097:            }
098:
099:            /**
100:             * Construct a persistent StorageFile from a directory and path name.
101:             *
102:             * @param directoryName The path name of the directory. Guaranteed not to be in the temporary file directory.
103:             *                  Guaranteed not to be null
104:             * @param fileName The name of the file within the directory. Guaranteed not to be null.
105:             *
106:             * @return A corresponding StorageFile object
107:             */
108:            StorageFile newPersistentFile(String directoryName, String fileName) {
109:                return new DirFile(separatedDataDirectory + directoryName,
110:                        fileName);
111:            }
112:
113:            /**
114:             * Construct a persistent StorageFile from a directory and path name.
115:             *
116:             * @param directoryName The path name of the directory. Guaranteed not to be to be null. Guaranteed to be
117:             *                  created by a call to one of the newPersistentFile methods.
118:             * @param fileName The name of the file within the directory. Guaranteed not to be null.
119:             *
120:             * @return A corresponding StorageFile object
121:             */
122:            StorageFile newPersistentFile(StorageFile directoryName,
123:                    String fileName) {
124:                return new DirFile((DirFile) directoryName, fileName);
125:            }
126:
127:            /**
128:             * Force the data of an output stream out to the underlying storage. That is, ensure that
129:             * it has been made persistent. If the database is to be transient, that is, if the database
130:             * does not survive a restart, then the sync method implementation need not do anything.
131:             *
132:             * @param stream The stream to be synchronized.
133:             * @param metaData If true then this method must force both changes to the file's
134:             *          contents and metadata to be written to storage; if false, it need only force file content changes
135:             *          to be written. The implementation is allowed to ignore this parameter and always force out
136:             *          metadata changes.
137:             *
138:             * @exception IOException if an I/O error occurs.
139:             * @exception SyncFailedException Thrown when the buffers cannot be flushed,
140:             *            or because the system cannot guarantee that all the buffers have been
141:             *            synchronized with physical media.
142:             */
143:            public void sync(OutputStream stream, boolean metaData)
144:                    throws IOException, SyncFailedException {
145:                ((FileOutputStream) stream).getFD().sync();
146:            }
147:
148:            /**
149:             * This method tests whether the "rws" and "rwd" modes are implemented. If the "rws" method is supported
150:             * then the database engine will conclude that the write methods of "rws" mode StorageRandomAccessFiles are
151:             * slow but the sync method is fast and optimize accordingly.
152:             *
153:             * @return <b>true</b> if an StIRandomAccess file opened with "rws" or "rwd" modes immediately writes data to the
154:             *         underlying storage, <b>false</b> if not.
155:             */
156:            public boolean supportsRws() {
157:                return false;
158:            }
159:
160:            public boolean isReadOnlyDatabase() {
161:                return false;
162:            }
163:
164:            /**
165:             * Determine whether the storage supports random access. If random access is not supported then
166:             * it will only be accessed using InputStreams and OutputStreams (if the database is writable).
167:             *
168:             * @return <b>true</b> if the storage supports random access, <b>false</b> if it is writable.
169:             */
170:            public boolean supportsRandomAccess() {
171:                return true;
172:            }
173:
174:            void doInit() throws IOException {
175:                if (dataDirectory != null) {
176:                    File dataDirectoryFile = new File(dataDirectory);
177:                    File databaseRoot = null;
178:                    if (dataDirectoryFile.isAbsolute())
179:                        databaseRoot = dataDirectoryFile;
180:                    else if (home != null && dataDirectory.startsWith(home))
181:                        databaseRoot = dataDirectoryFile;
182:                    else {
183:                        databaseRoot = new File(home, dataDirectory);
184:                        if (home != null)
185:                            dataDirectory = home + getSeparator()
186:                                    + dataDirectory;
187:                    }
188:                    canonicalName = databaseRoot.getCanonicalPath();
189:                    createTempDir();
190:                    separatedDataDirectory = dataDirectory + getSeparator();
191:                } else if (home != null) {
192:                    File root = new File(home);
193:                    dataDirectory = root.getCanonicalPath();
194:                    separatedDataDirectory = dataDirectory + getSeparator();
195:                }
196:            } // end of doInit
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.