KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > java > storagebuilder > MDRManagerImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.java.storagebuilder;
21
22 import java.util.HashMap JavaDoc;
23 import java.util.Map JavaDoc;
24 import org.netbeans.api.mdr.MDRepository;
25 import org.netbeans.api.mdr.MDRManager;
26 import org.netbeans.mdr.NBMDRepositoryImpl;
27
28 public class MDRManagerImpl extends MDRManager {
29
30     // private static final String DEFAULT_REPOSITORY = "Default";
31
private static final String JavaDoc JAVA_REPOSITORY = "org.netbeans.java"; // NOI18N
32

33     private Map JavaDoc parameters;
34     private MDRepository repository = null;
35     private String JavaDoc[] repositoryNames;
36
37     private void init() {
38         if (repository == null) {
39             repositoryNames = new String JavaDoc[] {JAVA_REPOSITORY};
40             String JavaDoc storagesDir = System.getProperty("mdr.filename"); // NOI18N
41
System.out.println(" " + storagesDir); // NOI18N
42
if (storagesDir == null) {
43                 System.out.println();
44                 System.out.println("Cannot init mdr, mdr.filename property not specified."); // NOI18N
45
return;
46             }
47             parameters = new HashMap JavaDoc();
48             parameters.put("storage", "org.netbeans.mdr.persistence.btreeimpl.btreestorage.BtreeFactory"); // NOI18N
49
parameters.put("mutexClass", "org.netbeans.modules.javacore.ExclusiveMutex"); // NOI18N
50
parameters.put("org.netbeans.mdr.persistence.btreeimpl.filename", storagesDir); // NOI18N
51
parameters.put("org.netbeans.mdr.persistence.btreeimpl.cacheSize", "256"); // NOI18N
52
parameters.put("org.netbeans.mdr.persistence.btreeimpl.cacheThreshHold", "1000"); // NOI18N
53
parameters.put("org.netbeans.mdr.persistence.btreeimpl.uuid", "66666666-6666-6666-6666-666666666666"); // NOI18N
54
repository = new NBMDRepositoryImpl(parameters);
55         }
56     }
57     
58     public MDRepository getRepository(String JavaDoc name) {
59         init();
60         return repository;
61     }
62
63     public MDRepository getDefaultRepository() {
64         return getRepository(JAVA_REPOSITORY);
65     }
66
67     public String JavaDoc[] getRepositoryNames() {
68         init();
69         return repositoryNames;
70     }
71     
72 }
73
Popular Tags