Net traffic compressing. Enabled by default. Can be disabled by -Dnocompress on server.

This commit is contained in:
magenoxx 2011-06-08 18:45:57 +04:00
parent 41546cf7d3
commit 05759b2966
3 changed files with 34 additions and 6 deletions

View file

@ -8,15 +8,39 @@ import java.io.ObjectOutputStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
/**
* Utility class to save an object on disk.
*
* @author ayrat
*/
public class SaveObjectUtil {
/**
* Defines should data be saved or not.
* Read from system property:
*/
private static boolean saveIncomeData = false;
/**
* Defines the system property name to get {@link #saveIncomeData} value from.
*/
private static final String SAVE_DATA_PROPERTY = "saveObjects";
/**
* Date pattern used to form filename to save object to.
*/
private static final String DATE_PATTERN = "[yyyy_MM_dd][H-mm-ss]";
static {
saveIncomeData = System.getProperty("saveObjects") != null;
saveIncomeData = System.getProperty(SAVE_DATA_PROPERTY) != null;
}
/**
* Save object on disk.
*
* @param object Object to save.
* @param name Part of name that will be used to form original filename to save object to.
*/
public static void saveObject(Object object, String name) {
if (saveIncomeData) {
ObjectOutputStream oos = null;
@ -28,7 +52,7 @@ public class SaveObjectUtil {
return;
}
}
String time = now("[yyyy_MM_dd][H-mm-ss]");
String time = now(DATE_PATTERN);
File f = new File("income" + File.separator + name + "_" + time + ".save");
if (!f.exists()) {
f.createNewFile();