Source Code Cross Referenced for Config4Impl.java in  » Database-DBMS » db4o-6.4 » com » db4o » internal » 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.internal 
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.internal;
022:
023:        import java.io.*;
024:
025:        import com.db4o.*;
026:        import com.db4o.config.*;
027:        import com.db4o.diagnostic.*;
028:        import com.db4o.foundation.*;
029:        import com.db4o.internal.cs.*;
030:        import com.db4o.internal.diagnostic.*;
031:        import com.db4o.internal.freespace.*;
032:        import com.db4o.io.*;
033:        import com.db4o.messaging.*;
034:        import com.db4o.reflect.*;
035:        import com.db4o.reflect.generic.*;
036:
037:        /**
038:         * Configuration template for creating new db4o files
039:         * 
040:         * @exclude
041:         */
042:        public final class Config4Impl implements  Configuration, DeepClone,
043:                MessageSender, FreespaceConfiguration, QueryConfiguration,
044:                ClientServerConfiguration {
045:
046:            private KeySpecHashtable4 _config = new KeySpecHashtable4(50);
047:
048:            private final static KeySpec ACTIVATION_DEPTH = new KeySpec(5);
049:
050:            private final static KeySpec ALLOW_VERSION_UPDATES = new KeySpec(
051:                    false);
052:
053:            private final static KeySpec AUTOMATIC_SHUTDOWN = new KeySpec(true);
054:
055:            //  TODO: consider setting default to 8, it's more efficient with freespace.
056:            private final static KeySpec BLOCKSIZE = new KeySpec((byte) 1);
057:
058:            private final static KeySpec BLOBPATH = new KeySpec(null);
059:
060:            private final static KeySpec BTREE_NODE_SIZE = new KeySpec(119);
061:
062:            private final static KeySpec BTREE_CACHE_HEIGHT = new KeySpec(1);
063:
064:            private final static KeySpec CALLBACKS = new KeySpec(true);
065:
066:            private final static KeySpec CALL_CONSTRUCTORS = new KeySpec(
067:                    TernaryBool.UNSPECIFIED);
068:
069:            private final static KeySpec CONFIGURATION_ITEMS = new KeySpec(null);
070:
071:            private final static KeySpec CLASS_ACTIVATION_DEPTH_CONFIGURABLE = new KeySpec(
072:                    true);
073:
074:            private final static KeySpec CLASSLOADER = new KeySpec(null);
075:
076:            private final static KeySpec DETECT_SCHEMA_CHANGES = new KeySpec(
077:                    true);
078:
079:            private final static KeySpec DIAGNOSTIC = new KeySpec(
080:                    new DiagnosticProcessor());
081:
082:            private final static KeySpec DISABLE_COMMIT_RECOVERY = new KeySpec(
083:                    false);
084:
085:            private final static KeySpec DISCARD_FREESPACE = new KeySpec(0);
086:
087:            private final static KeySpec ENCODING = new KeySpec(Const4.UNICODE);
088:
089:            private final static KeySpec ENCRYPT = new KeySpec(false);
090:
091:            private final static KeySpec EXCEPTIONAL_CLASSES = new KeySpec(null);
092:
093:            private final static KeySpec EXCEPTIONS_ON_NOT_STORABLE = new KeySpec(
094:                    false);
095:
096:            private final static KeySpec FLUSH_FILE_BUFFERS = new KeySpec(true);
097:
098:            private final static KeySpec FREESPACE_FILLER = new KeySpec(null);
099:
100:            private final static KeySpec FREESPACE_SYSTEM = new KeySpec(
101:                    AbstractFreespaceManager.FM_DEFAULT);
102:
103:            private final static KeySpec GENERATE_UUIDS = new KeySpec(
104:                    ConfigScope.INDIVIDUALLY);
105:
106:            private final static KeySpec GENERATE_VERSION_NUMBERS = new KeySpec(
107:                    ConfigScope.INDIVIDUALLY);
108:
109:            private final static KeySpec IS_SERVER = new KeySpec(false);
110:
111:            private final static KeySpec QUERY_EVALUATION_MODE = new KeySpec(
112:                    QueryEvaluationMode.IMMEDIATE);
113:
114:            private final static KeySpec LOCK_FILE = new KeySpec(true);
115:
116:            private final static KeySpec MESSAGE_RECIPIENT = new KeySpec(null);
117:
118:            private final static KeySpec OPTIMIZE_NQ = new KeySpec(true);
119:
120:            private final static KeySpec OUTSTREAM = new KeySpec(null);
121:
122:            private final static KeySpec PASSWORD = new KeySpec((String) null);
123:
124:            // for playing with different strategies of prefetching
125:            // object
126:            private static final KeySpec CLIENT_QUERY_RESULT_ITERATOR_FACTORY = new KeySpec(
127:                    null);
128:
129:            private static final KeySpec PREFETCH_ID_COUNT = new KeySpec(10);
130:
131:            private static final KeySpec PREFETCH_OBJECT_COUNT = new KeySpec(10);
132:
133:            private final static KeySpec READ_AS = new KeySpec(new Hashtable4(
134:                    16));
135:
136:            private final static KeySpec CONFIGURED_REFLECTOR = new KeySpec(
137:                    null);
138:
139:            private final static KeySpec REFLECTOR = new KeySpec(null);
140:
141:            private final static KeySpec RENAME = new KeySpec(null);
142:
143:            private final static KeySpec RESERVED_STORAGE_SPACE = new KeySpec(0);
144:
145:            private final static KeySpec SINGLE_THREADED_CLIENT = new KeySpec(
146:                    false);
147:
148:            private final static KeySpec TEST_CONSTRUCTORS = new KeySpec(true);
149:
150:            private final static KeySpec TIMEOUT_CLIENT_SOCKET = new KeySpec(
151:                    Const4.CLIENT_SOCKET_TIMEOUT);
152:
153:            private final static KeySpec TIMEOUT_SERVER_SOCKET = new KeySpec(
154:                    Const4.SERVER_SOCKET_TIMEOUT);
155:
156:            private final static KeySpec UPDATE_DEPTH = new KeySpec(0);
157:
158:            private final static KeySpec WEAK_REFERENCE_COLLECTION_INTERVAL = new KeySpec(
159:                    1000);
160:
161:            private final static KeySpec WEAK_REFERENCES = new KeySpec(true);
162:
163:            private final static KeySpec IOADAPTER = new KeySpec(
164:                    new CachedIoAdapter(new RandomAccessFileAdapter()));
165:
166:            //	private final static KeySpec IOADAPTER=new KeySpec(new RandomAccessFileAdapter());
167:
168:            // NOTE: activate this config to trigger the defragment failure
169:            //= new NIOFileAdapter(512,3);
170:
171:            private final static KeySpec ALIASES = new KeySpec(null);
172:
173:            private final static KeySpec BATCH_MESSAGES = new KeySpec(true);
174:
175:            private static final KeySpec MAX_BATCH_QUEUE_SIZE = new KeySpec(
176:                    Integer.MAX_VALUE);
177:
178:            //  is null in the global configuration until deepClone is called
179:            private ObjectContainerBase i_stream;
180:
181:            // The following are very frequently being asked for, so they show up in the profiler. 
182:            // Let's keep them out of the Hashtable.
183:            private boolean _internStrings;
184:            private int _messageLevel;
185:            private boolean _readOnly;
186:
187:            public int activationDepth() {
188:                return _config.getAsInt(ACTIVATION_DEPTH);
189:            }
190:
191:            public void activationDepth(int depth) {
192:                _config.put(ACTIVATION_DEPTH, depth);
193:            }
194:
195:            public void add(ConfigurationItem item) {
196:                item.prepare(this );
197:                safeConfigurationItems().put(item, item);
198:            }
199:
200:            private Hashtable4 safeConfigurationItems() {
201:                Hashtable4 items = configurationItems();
202:                if (items == null) {
203:                    items = new Hashtable4(16);
204:                    _config.put(CONFIGURATION_ITEMS, items);
205:                }
206:                return items;
207:            }
208:
209:            public void allowVersionUpdates(boolean flag) {
210:                _config.put(ALLOW_VERSION_UPDATES, flag);
211:            }
212:
213:            private Hashtable4 configurationItems() {
214:                return (Hashtable4) _config.get(CONFIGURATION_ITEMS);
215:            }
216:
217:            public void applyConfigurationItems(
218:                    final InternalObjectContainer container) {
219:                Hashtable4 items = configurationItems();
220:                if (items == null) {
221:                    return;
222:                }
223:                Iterator4 i = items.iterator();
224:                while (i.moveNext()) {
225:                    Entry4 entry = (Entry4) i.current();
226:                    ConfigurationItem item = (ConfigurationItem) entry.value();
227:                    item.apply(container);
228:                }
229:            }
230:
231:            public void automaticShutDown(boolean flag) {
232:                _config.put(AUTOMATIC_SHUTDOWN, flag);
233:            }
234:
235:            public void blockSize(int bytes) {
236:                if (bytes < 1 || bytes > 127) {
237:                    throw new IllegalArgumentException();
238:                }
239:                globalSettingOnly();
240:                _config.put(BLOCKSIZE, (byte) bytes);
241:            }
242:
243:            public void bTreeNodeSize(int size) {
244:                _config.put(BTREE_NODE_SIZE, size);
245:            }
246:
247:            public void bTreeCacheHeight(int height) {
248:                _config.put(BTREE_CACHE_HEIGHT, height);
249:            }
250:
251:            public void callbacks(boolean turnOn) {
252:                _config.put(CALLBACKS, turnOn);
253:            }
254:
255:            public void callConstructors(boolean flag) {
256:                _config.put(CALL_CONSTRUCTORS, TernaryBool.forBoolean(flag));
257:            }
258:
259:            public void classActivationDepthConfigurable(boolean turnOn) {
260:                _config.put(CLASS_ACTIVATION_DEPTH_CONFIGURABLE, turnOn);
261:            }
262:
263:            Config4Class configClass(String className) {
264:                Config4Class config = (Config4Class) exceptionalClasses().get(
265:                        className);
266:
267:                if (Debug.configureAllClasses) {
268:                    if (config == null) {
269:
270:                        boolean skip = false;
271:
272:                        Class[] ignore = new Class[] { P1HashElement.class,
273:                                P1ListElement.class, P1Object.class,
274:                                P1Collection.class,
275:
276:                                // XXX You may need the following for indexing tests. 
277:
278:                                //                        P2HashMap.class,
279:                                //                        P2LinkedList.class,
280:
281:                                StaticClass.class, StaticField.class
282:
283:                        };
284:                        for (int i = 0; i < ignore.length; i++) {
285:                            if (ignore[i].getName().equals(className)) {
286:                                skip = true;
287:                                break;
288:                            }
289:
290:                        }
291:                        if (!skip) {
292:                            config = (Config4Class) objectClass(className);
293:                        }
294:
295:                    }
296:                }
297:                return config;
298:            }
299:
300:            public Object deepClone(Object param) {
301:                Config4Impl ret = new Config4Impl();
302:                ret._config = (KeySpecHashtable4) _config.deepClone(this );
303:                ret._internStrings = _internStrings;
304:                ret._messageLevel = _messageLevel;
305:                ret._readOnly = _readOnly;
306:                return ret;
307:            }
308:
309:            public void stream(ObjectContainerBase stream) {
310:                i_stream = stream;
311:            }
312:
313:            public void detectSchemaChanges(boolean flag) {
314:                _config.put(DETECT_SCHEMA_CHANGES, flag);
315:            }
316:
317:            public void disableCommitRecovery() {
318:                _config.put(DISABLE_COMMIT_RECOVERY, true);
319:            }
320:
321:            /**
322:             * @deprecated
323:             */
324:            public void discardFreeSpace(int bytes) {
325:                if (bytes < 0) {
326:                    throw new IllegalArgumentException();
327:                }
328:                _config.put(DISCARD_FREESPACE, bytes);
329:            }
330:
331:            public void discardSmallerThan(int byteCount) {
332:                discardFreeSpace(byteCount);
333:            }
334:
335:            /**
336:             * @deprecated
337:             */
338:            public void encrypt(boolean flag) {
339:                globalSettingOnly();
340:                _config.put(ENCRYPT, flag);
341:            }
342:
343:            void oldEncryptionOff() {
344:                _config.put(ENCRYPT, false);
345:            }
346:
347:            void ensureDirExists(String path) throws IOException {
348:                File file = new File(path);
349:                if (!file.exists()) {
350:                    file.mkdirs();
351:                }
352:                if (file.exists() && file.isDirectory()) {
353:                } else {
354:                    throw new IOException(Messages.get(37, path));
355:                }
356:            }
357:
358:            PrintStream errStream() {
359:                PrintStream outStream = outStreamOrNull();
360:                return outStream == null ? System.err : outStream;
361:            }
362:
363:            public void exceptionsOnNotStorable(boolean flag) {
364:                _config.put(EXCEPTIONS_ON_NOT_STORABLE, flag);
365:            }
366:
367:            public void flushFileBuffers(boolean flag) {
368:                _config.put(FLUSH_FILE_BUFFERS, flag);
369:            }
370:
371:            public FreespaceConfiguration freespace() {
372:                return this ;
373:            }
374:
375:            public void freespaceFiller(FreespaceFiller freespaceFiller) {
376:                _config.put(FREESPACE_FILLER, freespaceFiller);
377:            }
378:
379:            public FreespaceFiller freespaceFiller() {
380:                return (FreespaceFiller) _config.get(FREESPACE_FILLER);
381:            }
382:
383:            /**
384:             * @deprecated Use {@link #generateUUIDs(ConfigScope)} instead.
385:             */
386:            public void generateUUIDs(int setting) {
387:                generateUUIDs(ConfigScope.forID(setting));
388:            }
389:
390:            public void generateUUIDs(ConfigScope scope) {
391:                _config.put(GENERATE_UUIDS, scope);
392:            }
393:
394:            /**
395:             * @deprecated Use {@link #generateVersionNumbers(ConfigScope)} instead.
396:             */
397:            public void generateVersionNumbers(int setting) {
398:                generateVersionNumbers(ConfigScope.forID(setting));
399:            }
400:
401:            public void generateVersionNumbers(ConfigScope scope) {
402:                _config.put(GENERATE_VERSION_NUMBERS, scope);
403:            }
404:
405:            public MessageSender getMessageSender() {
406:                return this ;
407:            }
408:
409:            private void globalSettingOnly() {
410:                if (i_stream != null) {
411:                    throw new GlobalOnlyConfigException();
412:                }
413:            }
414:
415:            public void internStrings(boolean doIntern) {
416:                _internStrings = doIntern;
417:            }
418:
419:            public void io(IoAdapter adapter) {
420:                globalSettingOnly();
421:                _config.put(IOADAPTER, adapter);
422:            }
423:
424:            public void lockDatabaseFile(boolean flag) {
425:                _config.put(LOCK_FILE, flag);
426:            }
427:
428:            public void markTransient(String marker) {
429:                Platform4.markTransient(marker);
430:            }
431:
432:            public void messageLevel(int level) {
433:                _messageLevel = level;
434:                if (outStream() == null) {
435:                    setOut(System.out);
436:                }
437:            }
438:
439:            public void optimizeNativeQueries(boolean optimizeNQ) {
440:                _config.put(OPTIMIZE_NQ, optimizeNQ);
441:            }
442:
443:            public boolean optimizeNativeQueries() {
444:                return _config.getAsBoolean(OPTIMIZE_NQ);
445:            }
446:
447:            public ObjectClass objectClass(Object clazz) {
448:
449:                String className = null;
450:
451:                if (clazz instanceof  String) {
452:                    className = (String) clazz;
453:                } else {
454:                    ReflectClass claxx = reflectorFor(clazz);
455:                    if (claxx == null) {
456:                        return null;
457:                    }
458:                    className = claxx.getName();
459:                }
460:
461:                Hashtable4 xClasses = exceptionalClasses();
462:                Config4Class c4c = (Config4Class) xClasses.get(className);
463:                if (c4c == null) {
464:                    c4c = new Config4Class(this , className);
465:                    xClasses.put(className, c4c);
466:                }
467:                return c4c;
468:            }
469:
470:            private PrintStream outStreamOrNull() {
471:                return (PrintStream) _config.get(OUTSTREAM);
472:            }
473:
474:            PrintStream outStream() {
475:                PrintStream outStream = outStreamOrNull();
476:                return outStream == null ? System.out : outStream;
477:            }
478:
479:            /**
480:             * @deprecated
481:             */
482:            public void password(String pw) {
483:                globalSettingOnly();
484:                _config.put(PASSWORD, pw);
485:            }
486:
487:            public void readOnly(boolean flag) {
488:                _readOnly = flag;
489:            }
490:
491:            public GenericReflector reflector() {
492:                GenericReflector reflector = (GenericReflector) _config
493:                        .get(REFLECTOR);
494:                if (reflector == null) {
495:                    Reflector configuredReflector = (Reflector) _config
496:                            .get(CONFIGURED_REFLECTOR);
497:                    if (configuredReflector == null) {
498:                        configuredReflector = Platform4
499:                                .createReflector(classLoader());
500:                        _config.put(CONFIGURED_REFLECTOR, configuredReflector);
501:                    }
502:                    reflector = new GenericReflector(null, configuredReflector);
503:                    _config.put(REFLECTOR, reflector);
504:                    configuredReflector.setParent(reflector);
505:                }
506:                // TODO: transaction assignment has been moved to YapStreamBase#initialize1().
507:                // implement better, more generic solution as described in COR-288
508:                //		if(! reflector.hasTransaction() && i_stream != null){
509:                //			reflector.setTransaction(i_stream.getSystemTransaction());
510:                //		}
511:                return reflector;
512:            }
513:
514:            public void reflectWith(Reflector reflect) {
515:
516:                if (i_stream != null) {
517:                    Exceptions4.throwRuntimeException(46); // see readable message for code in Messages.java
518:                }
519:
520:                if (reflect == null) {
521:                    throw new NullPointerException();
522:                }
523:                _config.put(CONFIGURED_REFLECTOR, reflect);
524:                _config.put(REFLECTOR, null);
525:            }
526:
527:            public void refreshClasses() {
528:                if (i_stream != null) {
529:                    i_stream.refreshClasses();
530:                }
531:            }
532:
533:            void rename(Rename a_rename) {
534:                Collection4 renameCollection = rename();
535:                if (renameCollection == null) {
536:                    renameCollection = new Collection4();
537:                    _config.put(RENAME, renameCollection);
538:                }
539:                renameCollection.add(a_rename);
540:            }
541:
542:            public void reserveStorageSpace(long byteCount)
543:                    throws DatabaseReadOnlyException {
544:                int reservedStorageSpace = (int) byteCount;
545:                if (reservedStorageSpace < 0) {
546:                    reservedStorageSpace = 0;
547:                }
548:                _config.put(RESERVED_STORAGE_SPACE, reservedStorageSpace);
549:                if (i_stream != null) {
550:                    i_stream.reserve(reservedStorageSpace);
551:                }
552:            }
553:
554:            /**
555:             * The ConfigImpl also is our messageSender
556:             */
557:            public void send(Object obj) {
558:                if (i_stream != null) {
559:                    i_stream.send(obj);
560:                }
561:            }
562:
563:            public void setBlobPath(String path) throws IOException {
564:                ensureDirExists(path);
565:                _config.put(BLOBPATH, path);
566:            }
567:
568:            /**
569:             * @deprecated
570:             */
571:            public void setClassLoader(Object classLoader) {
572:                reflectWith(Platform4.createReflector(classLoader));
573:            }
574:
575:            public void setMessageRecipient(MessageRecipient messageRecipient) {
576:                _config.put(MESSAGE_RECIPIENT, messageRecipient);
577:            }
578:
579:            public void setOut(PrintStream outStream) {
580:                _config.put(OUTSTREAM, outStream);
581:                if (i_stream != null) {
582:                    i_stream.logMsg(19, Db4o.version());
583:                } else {
584:                    Messages.logMsg(Db4o.configure(), 19, Db4o.version());
585:                }
586:            }
587:
588:            public void singleThreadedClient(boolean flag) {
589:                _config.put(SINGLE_THREADED_CLIENT, flag);
590:            }
591:
592:            public void testConstructors(boolean flag) {
593:                _config.put(TEST_CONSTRUCTORS, flag);
594:            }
595:
596:            public void timeoutClientSocket(int milliseconds) {
597:                _config.put(TIMEOUT_CLIENT_SOCKET, milliseconds);
598:            }
599:
600:            public void timeoutServerSocket(int milliseconds) {
601:                _config.put(TIMEOUT_SERVER_SOCKET, milliseconds);
602:            }
603:
604:            public void unicode(boolean unicodeOn) {
605:                _config.put(ENCODING, (unicodeOn ? Const4.UNICODE
606:                        : Const4.ISO8859));
607:            }
608:
609:            public void updateDepth(int depth) {
610:                DiagnosticProcessor dp = diagnosticProcessor();
611:                if (dp.enabled()) {
612:                    dp.checkUpdateDepth(depth);
613:                }
614:                _config.put(UPDATE_DEPTH, depth);
615:            }
616:
617:            public void useBTreeSystem() {
618:                _config
619:                        .put(FREESPACE_SYSTEM,
620:                                AbstractFreespaceManager.FM_BTREE);
621:            }
622:
623:            public void useRamSystem() {
624:                _config.put(FREESPACE_SYSTEM, AbstractFreespaceManager.FM_RAM);
625:            }
626:
627:            public void useIndexSystem() {
628:                _config.put(FREESPACE_SYSTEM, AbstractFreespaceManager.FM_IX);
629:            }
630:
631:            public void weakReferenceCollectionInterval(int milliseconds) {
632:                _config.put(WEAK_REFERENCE_COLLECTION_INTERVAL, milliseconds);
633:            }
634:
635:            public void weakReferences(boolean flag) {
636:                _config.put(WEAK_REFERENCES, flag);
637:            }
638:
639:            private Collection4 aliases() {
640:                Collection4 aliasesCollection = (Collection4) _config
641:                        .get(ALIASES);
642:                if (null == aliasesCollection) {
643:                    aliasesCollection = new Collection4();
644:                    _config.put(ALIASES, aliasesCollection);
645:                }
646:                return aliasesCollection;
647:            }
648:
649:            public void addAlias(Alias alias) {
650:                if (null == alias)
651:                    throw new com.db4o.foundation.ArgumentNullException("alias");
652:                aliases().add(alias);
653:            }
654:
655:            public void removeAlias(Alias alias) {
656:                if (null == alias)
657:                    throw new com.db4o.foundation.ArgumentNullException("alias");
658:                aliases().remove(alias);
659:            }
660:
661:            public String resolveAliasRuntimeName(String runtimeType) {
662:
663:                Collection4 configuredAliases = aliases();
664:                if (null == configuredAliases) {
665:                    return runtimeType;
666:                }
667:
668:                Iterator4 i = configuredAliases.iterator();
669:                while (i.moveNext()) {
670:                    String resolved = ((Alias) i.current())
671:                            .resolveRuntimeName(runtimeType);
672:                    if (null != resolved) {
673:                        return resolved;
674:                    }
675:                }
676:
677:                return runtimeType;
678:            }
679:
680:            public String resolveAliasStoredName(String storedType) {
681:
682:                Collection4 configuredAliases = aliases();
683:                if (null == configuredAliases) {
684:                    return storedType;
685:                }
686:
687:                Iterator4 i = configuredAliases.iterator();
688:                while (i.moveNext()) {
689:                    String resolved = ((Alias) i.current())
690:                            .resolveStoredName(storedType);
691:                    if (null != resolved) {
692:                        return resolved;
693:                    }
694:                }
695:
696:                return storedType;
697:            }
698:
699:            ReflectClass reflectorFor(Object clazz) {
700:                return ReflectorUtils.reflectClassFor(reflector(), clazz);
701:            }
702:
703:            public boolean allowVersionUpdates() {
704:                return _config.getAsBoolean(ALLOW_VERSION_UPDATES);
705:            }
706:
707:            boolean automaticShutDown() {
708:                return _config.getAsBoolean(AUTOMATIC_SHUTDOWN);
709:            }
710:
711:            public byte blockSize() {
712:                return _config.getAsByte(BLOCKSIZE);
713:            }
714:
715:            public int bTreeNodeSize() {
716:                return _config.getAsInt(BTREE_NODE_SIZE);
717:            }
718:
719:            public int bTreeCacheHeight() {
720:                return _config.getAsInt(BTREE_CACHE_HEIGHT);
721:            }
722:
723:            String blobPath() {
724:                return _config.getAsString(BLOBPATH);
725:            }
726:
727:            boolean callbacks() {
728:                return _config.getAsBoolean(CALLBACKS);
729:            }
730:
731:            TernaryBool callConstructors() {
732:                return _config.getAsTernaryBool(CALL_CONSTRUCTORS);
733:            }
734:
735:            boolean classActivationDepthConfigurable() {
736:                return _config
737:                        .getAsBoolean(CLASS_ACTIVATION_DEPTH_CONFIGURABLE);
738:            }
739:
740:            Object classLoader() {
741:                return _config.get(CLASSLOADER);
742:            }
743:
744:            boolean detectSchemaChanges() {
745:                return _config.getAsBoolean(DETECT_SCHEMA_CHANGES);
746:            }
747:
748:            boolean commitRecoveryDisabled() {
749:                return _config.getAsBoolean(DISABLE_COMMIT_RECOVERY);
750:            }
751:
752:            public DiagnosticConfiguration diagnostic() {
753:                return (DiagnosticConfiguration) _config.get(DIAGNOSTIC);
754:            }
755:
756:            public DiagnosticProcessor diagnosticProcessor() {
757:                return (DiagnosticProcessor) _config.get(DIAGNOSTIC);
758:            }
759:
760:            public int discardFreeSpace() {
761:                return _config.getAsInt(DISCARD_FREESPACE);
762:            }
763:
764:            byte encoding() {
765:                return _config.getAsByte(ENCODING);
766:            }
767:
768:            boolean encrypt() {
769:                return _config.getAsBoolean(ENCRYPT);
770:            }
771:
772:            public Hashtable4 exceptionalClasses() {
773:                Hashtable4 exceptionalClasses = (Hashtable4) _config
774:                        .get(EXCEPTIONAL_CLASSES);
775:                if (exceptionalClasses == null) {
776:                    exceptionalClasses = new Hashtable4(16);
777:                    _config.put(EXCEPTIONAL_CLASSES, exceptionalClasses);
778:                }
779:                return exceptionalClasses;
780:            }
781:
782:            public boolean exceptionsOnNotStorable() {
783:                return _config.getAsBoolean(EXCEPTIONS_ON_NOT_STORABLE);
784:            }
785:
786:            public boolean flushFileBuffers() {
787:                return _config.getAsBoolean(FLUSH_FILE_BUFFERS);
788:            }
789:
790:            byte freespaceSystem() {
791:                return _config.getAsByte(FREESPACE_SYSTEM);
792:            }
793:
794:            public ConfigScope generateUUIDs() {
795:                return (ConfigScope) _config.get(GENERATE_UUIDS);
796:            }
797:
798:            public ConfigScope generateVersionNumbers() {
799:                return (ConfigScope) _config.get(GENERATE_VERSION_NUMBERS);
800:            }
801:
802:            public boolean internStrings() {
803:                return _internStrings;
804:            }
805:
806:            public void isServer(boolean flag) {
807:                _config.put(IS_SERVER, flag);
808:            }
809:
810:            boolean isServer() {
811:                return _config.getAsBoolean(IS_SERVER);
812:            }
813:
814:            boolean lockFile() {
815:                return _config.getAsBoolean(LOCK_FILE);
816:            }
817:
818:            int messageLevel() {
819:                return _messageLevel;
820:            }
821:
822:            public MessageRecipient messageRecipient() {
823:                return (MessageRecipient) _config.get(MESSAGE_RECIPIENT);
824:            }
825:
826:            boolean optimizeNQ() {
827:                return _config.getAsBoolean(OPTIMIZE_NQ);
828:            }
829:
830:            String password() {
831:                return _config.getAsString(PASSWORD);
832:            }
833:
834:            public void prefetchIDCount(int prefetchIDCount) {
835:                _config.put(PREFETCH_ID_COUNT, prefetchIDCount);
836:            }
837:
838:            public int prefetchIDCount() {
839:                return _config.getAsInt(PREFETCH_ID_COUNT);
840:            }
841:
842:            public void prefetchObjectCount(int prefetchObjectCount) {
843:                _config.put(PREFETCH_OBJECT_COUNT, prefetchObjectCount);
844:            }
845:
846:            public int prefetchObjectCount() {
847:                return _config.getAsInt(PREFETCH_OBJECT_COUNT);
848:            }
849:
850:            Hashtable4 readAs() {
851:                return (Hashtable4) _config.get(READ_AS);
852:            }
853:
854:            public boolean isReadOnly() {
855:                return _readOnly;
856:            }
857:
858:            Collection4 rename() {
859:                return (Collection4) _config.get(RENAME);
860:            }
861:
862:            int reservedStorageSpace() {
863:                return _config.getAsInt(RESERVED_STORAGE_SPACE);
864:            }
865:
866:            public boolean singleThreadedClient() {
867:                return _config.getAsBoolean(SINGLE_THREADED_CLIENT);
868:            }
869:
870:            boolean testConstructors() {
871:                return _config.getAsBoolean(TEST_CONSTRUCTORS);
872:            }
873:
874:            public int timeoutClientSocket() {
875:                return _config.getAsInt(TIMEOUT_CLIENT_SOCKET);
876:            }
877:
878:            public int timeoutServerSocket() {
879:                return _config.getAsInt(TIMEOUT_SERVER_SOCKET);
880:            }
881:
882:            int updateDepth() {
883:                return _config.getAsInt(UPDATE_DEPTH);
884:            }
885:
886:            int weakReferenceCollectionInterval() {
887:                return _config.getAsInt(WEAK_REFERENCE_COLLECTION_INTERVAL);
888:            }
889:
890:            boolean weakReferences() {
891:                return _config.getAsBoolean(WEAK_REFERENCES);
892:            }
893:
894:            IoAdapter ioAdapter() {
895:                return (IoAdapter) _config.get(IOADAPTER);
896:            }
897:
898:            public QueryConfiguration queries() {
899:                return this ;
900:            }
901:
902:            public void evaluationMode(QueryEvaluationMode mode) {
903:                _config.put(QUERY_EVALUATION_MODE, mode);
904:            }
905:
906:            public QueryEvaluationMode queryEvaluationMode() {
907:                return (QueryEvaluationMode) _config.get(QUERY_EVALUATION_MODE);
908:            }
909:
910:            public void queryResultIteratorFactory(
911:                    QueryResultIteratorFactory factory) {
912:                _config.put(CLIENT_QUERY_RESULT_ITERATOR_FACTORY, factory);
913:            }
914:
915:            public QueryResultIteratorFactory queryResultIteratorFactory() {
916:                return (QueryResultIteratorFactory) _config
917:                        .get(CLIENT_QUERY_RESULT_ITERATOR_FACTORY);
918:            }
919:
920:            public ClientServerConfiguration clientServer() {
921:                return this ;
922:            }
923:
924:            public void batchMessages(boolean flag) {
925:                _config.put(BATCH_MESSAGES, flag);
926:            }
927:
928:            public boolean batchMessages() {
929:                return _config.getAsBoolean(BATCH_MESSAGES);
930:            }
931:
932:            public void maxBatchQueueSize(int maxSize) {
933:                _config.put(MAX_BATCH_QUEUE_SIZE, maxSize);
934:            }
935:
936:            public int maxBatchQueueSize() {
937:                return _config.getAsInt(MAX_BATCH_QUEUE_SIZE);
938:            }
939:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.