Lines 23-33
Link Here
|
23 |
import java.io.IOException; |
23 |
import java.io.IOException; |
24 |
import java.net.MalformedURLException; |
24 |
import java.net.MalformedURLException; |
25 |
import java.net.URL; |
25 |
import java.net.URL; |
|
|
26 |
import javax.management.IntrospectionException; |
26 |
import org.netbeans.api.db.explorer.ConnectionManager; |
27 |
import org.netbeans.api.db.explorer.ConnectionManager; |
27 |
import org.netbeans.api.db.explorer.DatabaseConnection; |
28 |
import org.netbeans.api.db.explorer.DatabaseConnection; |
28 |
import org.netbeans.api.db.explorer.DatabaseException; |
29 |
import org.netbeans.api.db.explorer.DatabaseException; |
29 |
import org.netbeans.api.db.explorer.JDBCDriver; |
30 |
import org.netbeans.api.db.explorer.JDBCDriver; |
30 |
import org.netbeans.api.db.explorer.JDBCDriverManager; |
31 |
import org.netbeans.api.db.explorer.JDBCDriverManager; |
|
|
32 |
import org.netbeans.modules.derby.DerbyOptions; |
31 |
import org.openide.ErrorManager; |
33 |
import org.openide.ErrorManager; |
32 |
import org.openide.filesystems.FileObject; |
34 |
import org.openide.filesystems.FileObject; |
33 |
import org.openide.filesystems.FileSystem; |
35 |
import org.openide.filesystems.FileSystem; |
Lines 35-52
Link Here
|
35 |
import org.openide.filesystems.Repository; |
37 |
import org.openide.filesystems.Repository; |
36 |
import org.openide.filesystems.URLMapper; |
38 |
import org.openide.filesystems.URLMapper; |
37 |
import org.openide.modules.InstalledFileLocator; |
39 |
import org.openide.modules.InstalledFileLocator; |
38 |
import org.openide.options.SystemOption; |
40 |
import org.openide.nodes.BeanNode; |
39 |
import org.openide.util.NbBundle; |
41 |
import org.openide.util.NbBundle; |
40 |
import org.openide.util.SharedClassObject; |
42 |
import org.openide.util.NbPreferences; |
41 |
|
43 |
|
42 |
/** |
44 |
/** |
43 |
* |
45 |
* |
44 |
* @author Andrei Badea |
46 |
* @author Andrei Badea |
45 |
*/ |
47 |
*/ |
46 |
public class DerbyOptions extends SystemOption { |
48 |
public class DerbyOptions { |
47 |
|
49 |
private static DerbyOptions INSTANCE = null; |
48 |
private static final long serialVersionUID = 1101894610105398924L; |
|
|
49 |
|
50 |
/** |
50 |
/** |
51 |
* This system property allows setting a default value for the Derby system home directory. |
51 |
* This system property allows setting a default value for the Derby system home directory. |
52 |
* Its value will be returned by the {@link getSystemHome} method if the |
52 |
* Its value will be returned by the {@link getSystemHome} method if the |
Lines 74-82
Link Here
|
74 |
private static final String DRIVER_NAME_EMBEDDED = "apache_derby_embedded"; // NOI18N |
74 |
private static final String DRIVER_NAME_EMBEDDED = "apache_derby_embedded"; // NOI18N |
75 |
|
75 |
|
76 |
public static DerbyOptions getDefault() { |
76 |
public static DerbyOptions getDefault() { |
77 |
return (DerbyOptions)SharedClassObject.findObject(DerbyOptions.class, true); |
77 |
if (INSTANCE == null) { |
|
|
78 |
INSTANCE = new DerbyOptions(); |
79 |
} |
80 |
return INSTANCE; |
78 |
} |
81 |
} |
79 |
|
82 |
|
|
|
83 |
protected final String putProperty(String key, String value, boolean notify) { |
84 |
String retval = NbPreferences.forModule(DerbyOptions.class).get(key, null); |
85 |
if (value != null) { |
86 |
NbPreferences.forModule(DerbyOptions.class).put(key, value); |
87 |
} else { |
88 |
NbPreferences.forModule(DerbyOptions.class).remove(key); |
89 |
} |
90 |
return retval; |
91 |
} |
92 |
|
93 |
protected final String getProperty(String key) { |
94 |
return NbPreferences.forModule(DerbyOptions.class).get(key, null); |
95 |
} |
96 |
|
80 |
public String displayName() { |
97 |
public String displayName() { |
81 |
return NbBundle.getMessage(DerbyOptions.class, "LBL_DerbyOptions"); |
98 |
return NbBundle.getMessage(DerbyOptions.class, "LBL_DerbyOptions"); |
82 |
} |
99 |
} |
Lines 126-141
Link Here
|
126 |
} |
143 |
} |
127 |
} |
144 |
} |
128 |
|
145 |
|
129 |
synchronized (getLock()) { |
146 |
synchronized (this) { |
130 |
if (!isReadExternal()) { |
147 |
stopDerbyServer(); |
131 |
stopDerbyServer(); |
|
|
132 |
} |
133 |
if (location != null && location.length() <= 0) { |
148 |
if (location != null && location.length() <= 0) { |
134 |
location = getDefaultInstallLocation(); |
149 |
location = getDefaultInstallLocation(); |
135 |
} |
150 |
} |
136 |
if (!isReadExternal()) { |
151 |
registerDrivers(location); |
137 |
registerDrivers(location); |
|
|
138 |
} |
139 |
putProperty(PROP_DERBY_LOCATION, location, true); |
152 |
putProperty(PROP_DERBY_LOCATION, location, true); |
140 |
} |
153 |
} |
141 |
} |
154 |
} |
Lines 172-181
Link Here
|
172 |
} |
185 |
} |
173 |
} |
186 |
} |
174 |
|
187 |
|
175 |
synchronized (getLock()) { |
188 |
synchronized (this) { |
176 |
if (!isReadExternal()) { |
189 |
stopDerbyServer(); |
177 |
stopDerbyServer(); |
|
|
178 |
} |
179 |
putProperty(PROP_DERBY_SYSTEM_HOME, derbySystemHome, true); |
190 |
putProperty(PROP_DERBY_SYSTEM_HOME, derbySystemHome, true); |
180 |
} |
191 |
} |
181 |
} |
192 |
} |
Lines 280-283
Link Here
|
280 |
} |
291 |
} |
281 |
} |
292 |
} |
282 |
} |
293 |
} |
|
|
294 |
|
295 |
public static BeanNode createViewNode() throws java.beans.IntrospectionException { |
296 |
return new BeanNode(DerbyOptions.getDefault()); |
297 |
} |
283 |
} |
298 |
} |