Matt Foster ha scritto:
> Andrea Aime wrote:
>> If you want to put the database in a location that is not repeatedly
>> cleaned up by your OS you can also force it manually by setting
>> a System variable:
>>
>> System.setProperty(ThreadedHsqlEpsgFactory.DIRECTORY_KEY,
>> "/path/to/your/safe/directory");
>>
>> Hope this helps
>> Cheers
>> Andrea
>>
> Thanks Andrea, this is very useful to me, as my applications are
> typically shared via NFS to multiple workstations. Now I can have them
> all share the same EPSG database.
>
> The problem is, however, that I can't seem to make it work. I set the
> DIRECTORY_KEY to a safe path (that does exist), but it still uses the
> temporary path for the database. Under what circumstances would it fail
> to use the path that I specified?
The code is:
/**
* Returns the default directory for the EPSG database. If the
{...@value #DIRECTORY_KEY}
* {...@linkplain System#getProperty(String) system property} is
defined and contains the
* name of a directory with a valid {...@linkplain File#getParent
parent}, then the
* {...@value #DATABASE_NAME} database will be saved in that
directory. Otherwise,
* a temporary directory will be used.
*/
private static File getDirectory() {
try {
final String property = System.getProperty(DIRECTORY_KEY);
if (property != null) {
final File directory = new File(property);
/*
* Creates the directory if needed (mkdir), but NOT the
parent directories (mkdirs)
* because a missing parent directory may be a symptom
of an installation problem.
* For example if 'directory' is a subdirectory in the
temporary directory (~/tmp/),
* this temporary directory should already exists. If
it doesn't, an administrator
* should probably looks at this problem.
*/
if (directory.isDirectory() || directory.mkdir()) {
return directory;
}
}
} catch (SecurityException e) {
/*
* Can't fetch the base directory from system properties.
* Fallback on the default temporary directory.
*/
}
return getTemporaryDirectory();
}
So it would fail if the DIRECTORY_KEY has not been set,
or if the specified directory cannot be created, or if
the parent directories aren't existing, or if access to
the system properties is forbidden by a security manager.
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users