Index: trunk/src/main/java/omq/common/util/Environment.java
===================================================================
--- trunk/src/main/java/omq/common/util/Environment.java	(revision 44)
+++ 	(revision )
@@ -1,41 +1,0 @@
-package omq.common.util;
-
-import java.util.Properties;
-
-import omq.exception.EnvironmentException;
-
-/**
- * 
- * @author Sergi Toda <sergi.toda@estudiants.urv.cat>
- * 
- */
-public class Environment {
-	private static Properties env = null;
-
-	/**
-	 * This method return the environment of the middleware
-	 * 
-	 * @return Environment to use in the middleware
-	 * @throws EnvironmentException
-	 *             will be thrown whether the environment is null
-	 */
-	public static Properties getEnvironment() throws EnvironmentException {
-		if (env == null) {
-			throw new EnvironmentException();
-		}
-		return env;
-	}
-
-	/**
-	 * This method sets the environment of the middleware
-	 * 
-	 * @param environment
-	 */
-	public static void setEnvironment(Properties environment) {
-		env = environment;
-	}
-
-	public static boolean isVoid() {
-		return env == null;
-	}
-}
Index: trunk/src/main/java/omq/common/util/Log.java
===================================================================
--- trunk/src/main/java/omq/common/util/Log.java	(revision 44)
+++ trunk/src/main/java/omq/common/util/Log.java	(revision 47)
@@ -7,64 +7,74 @@
 import java.util.Properties;
 
-import omq.exception.EnvironmentException;
+import omq.common.broker.Broker;
 
 public class Log {
 
 	public static void saveLog(String processName, byte[] bytesResponse) throws IOException {
-		try {
-			Properties env = Environment.getEnvironment();
 
-			String debugPath = env.getProperty(ParameterQueue.DEBUGFILE, "");
-			if (debugPath.length() > 0) {
-				long timeNow = (new Date()).getTime();
+		Properties env = Broker.getEnvironment();
 
-				File outputFolder = new File(debugPath + File.separator);
-				outputFolder.mkdirs();
-				
-//				File outputFolder = new File(debugPath + File.separator + processName);
-//				outputFolder.mkdirs();
+		String debugPath = env.getProperty(ParameterQueue.DEBUGFILE, "");
+		if (debugPath.length() > 0) {
+			long timeNow = (new Date()).getTime();
 
-//				File outputFileContent = new File(outputFolder.getAbsoluteFile() + File.separator + "content_" + timeNow);
-//				FileOutputStream outputStream = new FileOutputStream(outputFileContent);
-//				IOUtils.write(bytesResponse, outputStream);
-//				outputStream.close();
+			File outputFolder = new File(debugPath + File.separator);
+			outputFolder.mkdirs();
 
-				File outputFileLog = new File(debugPath + File.separator + "log");
-				boolean exist = outputFileLog.exists();
-				
-				FileWriter fw = new FileWriter(outputFileLog, true); // the true will append the new data
-				if(!exist){
-					fw.write("#ProcessName\t\tFile\t\t\t\t\tDate\t\t\tSize\n");
-				}
-				fw.write(processName + "\t" + "content_" + timeNow + "\t" + timeNow + "\t" + bytesResponse.length + "\tbytes\n");
-				fw.close();
+			// File outputFolder = new File(debugPath + File.separator +
+			// processName);
+			// outputFolder.mkdirs();
+
+			// File outputFileContent = new
+			// File(outputFolder.getAbsoluteFile() + File.separator +
+			// "content_" + timeNow);
+			// FileOutputStream outputStream = new
+			// FileOutputStream(outputFileContent);
+			// IOUtils.write(bytesResponse, outputStream);
+			// outputStream.close();
+
+			File outputFileLog = new File(debugPath + File.separator + "log");
+			boolean exist = outputFileLog.exists();
+
+			FileWriter fw = new FileWriter(outputFileLog, true); // the true
+																	// will
+																	// append
+																	// the
+																	// new
+																	// data
+			if (!exist) {
+				fw.write("#ProcessName\t\tFile\t\t\t\t\tDate\t\t\tSize\n");
 			}
-		} catch (EnvironmentException e) {
-			throw new IOException(e.getMessage(), e);
+			fw.write(processName + "\t" + "content_" + timeNow + "\t" + timeNow + "\t" + bytesResponse.length + "\tbytes\n");
+			fw.close();
 		}
+
 	}
-	
+
 	public static void saveTimeSendRequestLog(String processName, String coorId, String method, long timeNow) throws IOException {
-		try {
-			Properties env = Environment.getEnvironment();
 
-			String debugPath = env.getProperty(ParameterQueue.DEBUGFILE, "");
-			if (debugPath.length() > 0) {			
-				File outputFolder = new File(debugPath + File.separator + processName);
-				outputFolder.mkdirs();
-				
-				File outputFileLog = new File(outputFolder + File.separator + "log");
-				boolean exist = outputFileLog.exists();
-				
-				FileWriter fw = new FileWriter(outputFileLog, true); // the true will append the new data
-				if(!exist){
-					fw.write("#CoorId\tMethod\tDate\n");
-				}
-				fw.write(coorId + "\t" + method + "\t" + timeNow + "\n");
-				fw.close();
+		Properties env = Broker.getEnvironment();
+
+		String debugPath = env.getProperty(ParameterQueue.DEBUGFILE, "");
+		if (debugPath.length() > 0) {
+			File outputFolder = new File(debugPath + File.separator + processName);
+			outputFolder.mkdirs();
+
+			File outputFileLog = new File(outputFolder + File.separator + "log");
+			boolean exist = outputFileLog.exists();
+
+			FileWriter fw = new FileWriter(outputFileLog, true); // the true
+																	// will
+																	// append
+																	// the
+																	// new
+																	// data
+			if (!exist) {
+				fw.write("#CoorId\tMethod\tDate\n");
 			}
-		} catch (EnvironmentException e) {
-			throw new IOException(e.getMessage(), e);
+			fw.write(coorId + "\t" + method + "\t" + timeNow + "\n");
+			fw.close();
 		}
-	}	
+
+	}
 }
Index: trunk/src/main/java/omq/common/util/Serializer.java
===================================================================
--- trunk/src/main/java/omq/common/util/Serializer.java	(revision 44)
+++ trunk/src/main/java/omq/common/util/Serializer.java	(revision 47)
@@ -4,4 +4,5 @@
 import java.util.Properties;
 
+import omq.common.broker.Broker;
 import omq.common.event.Event;
 import omq.common.message.Request;
@@ -11,5 +12,4 @@
 import omq.common.util.Serializers.JavaImp;
 import omq.common.util.Serializers.KryoImp;
-import omq.exception.EnvironmentException;
 import omq.exception.SerializerException;
 import omq.server.RemoteObject;
@@ -21,20 +21,19 @@
  */
 public class Serializer {
-	public static String kryo = KryoImp.class.getCanonicalName();
-	public static String java = JavaImp.class.getCanonicalName();
-	public static String gson = GsonImp.class.getCanonicalName();
+	public static String kryo = "kryo";
+	public static String java = "java";
+	public static String gson = "gson";
 
+	// Client serializer
 	public static ISerializer serializer;
 
+	// Server serializers
+	private static ISerializer kryoSerializer;
+	private static ISerializer javaSerializer;
+	private static ISerializer gsonSerializer;
+
 	private static Boolean getEnableCompression() {
-		Boolean enableCompression = false;
-		try {
-			Properties env = Environment.getEnvironment();
-			enableCompression = Boolean.valueOf(env.getProperty(ParameterQueue.ENABLECOMPRESSION, "false"));
-		} catch (EnvironmentException e) {
-			e.printStackTrace();
-		}
-
-		return enableCompression;
+		Properties env = Broker.getEnvironment();
+		return Boolean.valueOf(env.getProperty(ParameterQueue.ENABLECOMPRESSION, "false"));
 	}
 
@@ -42,5 +41,5 @@
 		if (serializer == null) {
 			try {
-				Properties env = Environment.getEnvironment();
+				Properties env = Broker.getEnvironment();
 				String className = env.getProperty(ParameterQueue.SERIALIZER_NAME, Serializer.java);
 
@@ -49,5 +48,5 @@
 				}
 
-				serializer = (ISerializer) Class.forName(className).newInstance();
+				serializer = getInstance(className);
 			} catch (Exception ex) {
 				throw new SerializerException(ex.getMessage(), ex);
@@ -58,4 +57,40 @@
 	}
 
+	public static ISerializer getInstance(String type) throws SerializerException {
+		if (kryo.equals(type)) {
+			if (kryoSerializer == null) {
+				kryoSerializer = new KryoImp();
+			}
+			return kryoSerializer;
+		} else if (gson.endsWith(type)) {
+			if (gsonSerializer == null) {
+				gsonSerializer = new GsonImp();
+			}
+			return gsonSerializer;
+		} else {
+			if (javaSerializer == null) {
+				javaSerializer = new JavaImp();
+			}
+			return javaSerializer;
+		}
+	}
+
+	public static byte[] serialize(String type, Object obj) throws SerializerException {
+		ISerializer instance = getInstance(type);
+
+		Boolean enableCompression = getEnableCompression();
+		if (enableCompression) {
+			byte[] objSerialized = instance.serialize(obj);
+			try {
+				return Zipper.zip(objSerialized);
+			} catch (IOException e) {
+				throw new SerializerException(e.getMessage(), e);
+			}
+		} else {
+			return instance.serialize(obj);
+		}
+	}
+
+	// TODO: remove this function and think about the event serialization
 	public static byte[] serialize(Object obj) throws SerializerException {
 		ISerializer instance = getInstance();
@@ -74,6 +109,6 @@
 	}
 
-	public static Request deserializeRequest(byte[] bytes, RemoteObject obj) throws SerializerException {
-		ISerializer instance = getInstance();
+	public static Request deserializeRequest(String type, byte[] bytes, RemoteObject obj) throws SerializerException {
+		ISerializer instance = getInstance(type);
 
 		Boolean enableCompression = getEnableCompression();
@@ -121,3 +156,10 @@
 		}
 	}
+
+	public static void removeSerializers() {
+		serializer = null;
+		kryoSerializer = null;
+		javaSerializer = null;
+		gsonSerializer = null;
+	}
 }
