|
|
@ -126,32 +126,33 @@ public class AssetData { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized String getProperty(final String key) { |
|
|
|
public synchronized String getProperty(final String key) { |
|
|
|
|
|
|
|
readProperties(); |
|
|
|
return propsMutex.readAccess(new Action<String>() { |
|
|
|
return propsMutex.readAccess(new Action<String>() { |
|
|
|
public String run() { |
|
|
|
public String run() { |
|
|
|
readProperties(); |
|
|
|
|
|
|
|
return props.getProperty(key); |
|
|
|
return props.getProperty(key); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized String getProperty(final String key, final String defaultValue) { |
|
|
|
public synchronized String getProperty(final String key, final String defaultValue) { |
|
|
|
|
|
|
|
readProperties(); |
|
|
|
return propsMutex.readAccess(new Action<String>() { |
|
|
|
return propsMutex.readAccess(new Action<String>() { |
|
|
|
public String run() { |
|
|
|
public String run() { |
|
|
|
readProperties(); |
|
|
|
|
|
|
|
return props.getProperty(key, defaultValue); |
|
|
|
return props.getProperty(key, defaultValue); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public synchronized String setProperty(final String key, final String value) { |
|
|
|
public synchronized String setProperty(final String key, final String value) { |
|
|
|
return propsMutex.writeAccess(new Action<String>() { |
|
|
|
readProperties(); |
|
|
|
|
|
|
|
String ret = propsMutex.writeAccess(new Action<String>() { |
|
|
|
public String run() { |
|
|
|
public String run() { |
|
|
|
String ret = (String) props.setProperty(key, value); |
|
|
|
String ret = (String) props.setProperty(key, value); |
|
|
|
readProperties(); |
|
|
|
|
|
|
|
writeProperties(); |
|
|
|
|
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
writeProperties(); |
|
|
|
|
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Deprecated |
|
|
|
@Deprecated |
|
|
@ -163,7 +164,7 @@ public class AssetData { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void readProperties() { |
|
|
|
private void readProperties() { |
|
|
|
propsMutex.readAccess(new Runnable() { |
|
|
|
propsMutex.writeAccess(new Runnable() { |
|
|
|
public void run() { |
|
|
|
public void run() { |
|
|
|
final FileObject myFile = FileUtil.findBrother(file.getPrimaryFile(), extension); |
|
|
|
final FileObject myFile = FileUtil.findBrother(file.getPrimaryFile(), extension); |
|
|
|
if (myFile == null) { |
|
|
|
if (myFile == null) { |
|
|
@ -171,30 +172,26 @@ public class AssetData { |
|
|
|
} |
|
|
|
} |
|
|
|
final Date lastMod = myFile.lastModified(); |
|
|
|
final Date lastMod = myFile.lastModified(); |
|
|
|
if (!lastMod.equals(lastLoaded)) { |
|
|
|
if (!lastMod.equals(lastLoaded)) { |
|
|
|
propsMutex.writeAccess(new Runnable() { |
|
|
|
props.clear(); |
|
|
|
public void run() { |
|
|
|
lastLoaded = lastMod; |
|
|
|
props.clear(); |
|
|
|
InputStream in = null; |
|
|
|
lastLoaded = lastMod; |
|
|
|
try { |
|
|
|
InputStream in = null; |
|
|
|
in = new BufferedInputStream(myFile.getInputStream()); |
|
|
|
try { |
|
|
|
try { |
|
|
|
in = new BufferedInputStream(myFile.getInputStream()); |
|
|
|
props.load(in); |
|
|
|
try { |
|
|
|
} catch (IOException ex) { |
|
|
|
props.load(in); |
|
|
|
Exceptions.printStackTrace(ex); |
|
|
|
} catch (IOException ex) { |
|
|
|
|
|
|
|
Exceptions.printStackTrace(ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (FileNotFoundException ex) { |
|
|
|
|
|
|
|
Exceptions.printStackTrace(ex); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
in.close(); |
|
|
|
|
|
|
|
} catch (IOException ex) { |
|
|
|
|
|
|
|
Exceptions.printStackTrace(ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
logger.log(Level.INFO, "Read AssetData properties for {0}", file); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch (FileNotFoundException ex) { |
|
|
|
|
|
|
|
Exceptions.printStackTrace(ex); |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
in.close(); |
|
|
|
|
|
|
|
} catch (IOException ex) { |
|
|
|
|
|
|
|
Exceptions.printStackTrace(ex); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
logger.log(Level.INFO, "Read AssetData properties for {0}", file); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|