Source Code Cross Referenced for DefragmentConfig.java in  » Database-DBMS » db4o-6.4 » com » db4o » defragment » 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 » db4o 6.4 » com.db4o.defragment 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (C) 2004 - 2007  db4objects Inc.  http://www.db4o.com
002:
003:        This file is part of the db4o open source object database.
004:
005:        db4o is free software; you can redistribute it and/or modify it under
006:        the terms of version 2 of the GNU General Public License as published
007:        by the Free Software Foundation and as clarified by db4objects' GPL 
008:        interpretation policy, available at
009:        http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
010:        Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
011:        Suite 350, San Mateo, CA 94403, USA.
012:
013:        db4o is distributed in the hope that it will be useful, but WITHOUT ANY
014:        WARRANTY; without even the implied warranty of MERCHANTABILITY or
015:        FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
016:        for more details.
017:
018:        You should have received a copy of the GNU General Public License along
019:        with this program; if not, write to the Free Software Foundation, Inc.,
020:        59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */
021:        package com.db4o.defragment;
022:
023:        import com.db4o.*;
024:        import com.db4o.config.*;
025:        import com.db4o.ext.*;
026:        import com.db4o.internal.*;
027:
028:        /**
029:         * Configuration for a defragmentation run.
030:         * 
031:         * @see Defragment
032:         */
033:        public class DefragmentConfig {
034:
035:            public static final boolean DEBUG = false;
036:
037:            public final static String BACKUP_SUFFIX = "backup";
038:
039:            private String _origPath;
040:            private String _backupPath;
041:            private String _tempPath;
042:            private ContextIDMapping _mapping;
043:            private Configuration _config;
044:
045:            private StoredClassFilter _storedClassFilter = null;
046:            private boolean _forceBackupDelete = false;
047:
048:            private int _objectCommitFrequency;
049:
050:            /**
051:             * Creates a configuration for a defragmentation run. The backup and mapping
052:             * file paths are generated from the original path by appending the default
053:             * suffixes. All properties other than the provided paths are set to FALSE
054:             * by default.
055:             * 
056:             * @param origPath The path to the file to be defragmented. Must exist and must be
057:             *         a valid yap file.
058:             */
059:            public DefragmentConfig(String origPath) {
060:                this (origPath, origPath + "." + BACKUP_SUFFIX);
061:            }
062:
063:            /**
064:             * Creates a configuration for a defragmentation run with in-memory mapping.
065:             * All properties other than the provided paths are set to FALSE by default.
066:             * 
067:             * @param origPath The path to the file to be defragmented. Must exist and must be
068:             *         a valid yap file.
069:             * @param backupPath The path to the backup of the original file. No file should
070:             *         exist at this position, otherwise it will be OVERWRITTEN if forceBackupDelete()
071:             *         is set to true!
072:             */
073:            public DefragmentConfig(String origPath, String backupPath) {
074:                this (origPath, backupPath, new TreeIDMapping());
075:            }
076:
077:            /**
078:             * Creates a configuration for a defragmentation run. All properties other
079:             * than the provided paths are set to FALSE by default.
080:             * 
081:             * @param origPath The path to the file to be defragmented. Must exist and must be
082:             *         a valid yap file.
083:             * @param backupPath The path to the backup of the original file. No file should
084:             *         exist at this position, otherwise it will be OVERWRITTEN if forceBackupDelete()
085:             *         is set to true!
086:             * @param mapping The intermediate mapping used internally.
087:             */
088:            public DefragmentConfig(String origPath, String backupPath,
089:                    ContextIDMapping mapping) {
090:                _origPath = origPath;
091:                _backupPath = backupPath;
092:                _mapping = mapping;
093:            }
094:
095:            /**
096:             * @return The path to the file to be defragmented.
097:             */
098:            public String origPath() {
099:                return _origPath;
100:            }
101:
102:            /**
103:             * @return The path to the backup of the original file.
104:             */
105:            public String backupPath() {
106:                return _backupPath;
107:            }
108:
109:            /**
110:             * @return The intermediate mapping used internally. For internal use only.
111:             */
112:            public ContextIDMapping mapping() {
113:                return _mapping;
114:            }
115:
116:            /**
117:             * @return The {@link StoredClassFilter} used to select stored class extents to
118:             * be included into the defragmented file.
119:             */
120:            public StoredClassFilter storedClassFilter() {
121:                return (_storedClassFilter == null ? NULLFILTER
122:                        : _storedClassFilter);
123:            }
124:
125:            /**
126:             * @param storedClassFilter The {@link StoredClassFilter} used to select stored class extents to
127:             * be included into the defragmented file.
128:             */
129:            public void storedClassFilter(StoredClassFilter storedClassFilter) {
130:                _storedClassFilter = storedClassFilter;
131:            }
132:
133:            /**
134:             * @return true, if an existing backup file should be deleted, false otherwise.
135:             */
136:            public boolean forceBackupDelete() {
137:                return _forceBackupDelete;
138:            }
139:
140:            /**
141:             * @param forceBackupDelete true, if an existing backup file should be deleted, false otherwise.
142:             */
143:            public void forceBackupDelete(boolean forceBackupDelete) {
144:                _forceBackupDelete = forceBackupDelete;
145:            }
146:
147:            /**
148:             * @return The db4o {@link com.db4o.config.Configuration Configuration} to be applied
149:             * during the defragment process.
150:             */
151:            public Configuration db4oConfig() {
152:                if (_config == null) {
153:                    _config = vanillaDb4oConfig(1);
154:                }
155:                return _config;
156:            }
157:
158:            /**
159:             * @param config The db4o {@link com.db4o.config.Configuration Configuration} to be applied
160:             * during the defragment process.
161:             */
162:            public void db4oConfig(Configuration config) {
163:                _config = config;
164:            }
165:
166:            public int objectCommitFrequency() {
167:                return _objectCommitFrequency;
168:            }
169:
170:            /**
171:             * @param objectCommitFrequency The number of processed object (slots) that should trigger an
172:             * intermediate commit of the target file. Default: 0, meaning: never.
173:             */
174:            public void objectCommitFrequency(int objectCommitFrequency) {
175:                _objectCommitFrequency = objectCommitFrequency;
176:            }
177:
178:            /**
179:             * Instruct the defragment process to upgrade the source file to the current db4o
180:             * version prior to defragmenting it. Use this option if your source file has been created
181:             * with an older db4o version than the one you are using.
182:             * @param tempPath The location for an intermediate, upgraded version of the source file. 
183:             */
184:            public void upgradeFile(String tempPath) {
185:                _tempPath = tempPath;
186:            }
187:
188:            public boolean fileNeedsUpgrade() {
189:                return _tempPath != null;
190:            }
191:
192:            public String tempPath() {
193:                return (_tempPath != null ? _tempPath : _backupPath);
194:            }
195:
196:            public int blockSize() {
197:                return ((Config4Impl) db4oConfig()).blockSize();
198:            }
199:
200:            protected static class NullFilter implements  StoredClassFilter {
201:                public boolean accept(StoredClass storedClass) {
202:                    return true;
203:                }
204:            }
205:
206:            private final static StoredClassFilter NULLFILTER = new NullFilter();
207:
208:            public static Configuration vanillaDb4oConfig(int blockSize) {
209:                Configuration config = Db4o.newConfiguration();
210:                config.weakReferences(false);
211:                config.blockSize(blockSize);
212:                return config;
213:            }
214:
215:            public Configuration clonedDb4oConfig() {
216:                return (Configuration) ((Config4Impl) db4oConfig())
217:                        .deepClone(null);
218:            }
219:
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.