CLOUDSTACK-3433: Relax the same package restriction for Command and its derived classes in ArrayTypeAdaptor<T>

This commit is contained in:
Kelven Yang 2013-07-09 17:24:19 -07:00
parent e86a9ae151
commit 73a6aa7885
1 changed files with 2 additions and 6 deletions

View File

@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.Map;
import com.cloud.agent.api.Command;
import com.cloud.utils.exception.CloudRuntimeException;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
@ -38,9 +37,6 @@ public class ArrayTypeAdaptor<T> implements JsonDeserializer<T[]>, JsonSerialize
protected Gson _gson = null;
private static final String s_pkg = Command.class.getPackage().getName() + ".";
public ArrayTypeAdaptor() {
}
@ -53,7 +49,7 @@ public class ArrayTypeAdaptor<T> implements JsonDeserializer<T[]>, JsonSerialize
JsonArray array = new JsonArray();
for (T cmd : src) {
JsonObject obj = new JsonObject();
obj.add(cmd.getClass().getName().substring(s_pkg.length()), _gson.toJsonTree(cmd));
obj.add(cmd.getClass().getName(), _gson.toJsonTree(cmd));
array.add(obj);
}
@ -71,7 +67,7 @@ public class ArrayTypeAdaptor<T> implements JsonDeserializer<T[]>, JsonSerialize
JsonObject element = (JsonObject)it.next();
Map.Entry<String, JsonElement> entry = element.entrySet().iterator().next();
String name = s_pkg + entry.getKey();
String name = entry.getKey();
Class<?> clazz;
try {
clazz = Class.forName(name);