{
SanityManager.ASSERT(serviceName.equals(getCanonicalServiceName(serviceName)), serviceName);
}
if( ! (sf instanceof WritableStorageFactory))
throw StandardException.newException(SQLState.READ_ONLY_SERVICE);
final WritableStorageFactory storageFactory = (WritableStorageFactory) sf;
try
{
AccessController.doPrivileged(
new PrivilegedExceptionAction()
{
public Object run() throws StandardException
{
StorageFile backupFile = null;
StorageFile servicePropertiesFile = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME);
if (replace)
{
backupFile = storageFactory.newStorageFile( PersistentService.PROPERTIES_NAME.concat("old"));
try
{
if(!servicePropertiesFile.renameTo(backupFile))
throw StandardException.newException(SQLState.UNABLE_TO_RENAME_FILE,
servicePropertiesFile, backupFile);
}
catch (SecurityException se) { throw Monitor.exceptionStartingModule(se); }
}
OutputStream os = null;
try
{
os = servicePropertiesFile.getOutputStream();
properties.store( os, serviceName + MessageService.getTextMessage(MessageId.SERVICE_PROPERTIES_DONT_EDIT));
storageFactory.sync( os, false);
os.close();
os = null;
}
catch (IOException ioe)
{