package com.graphicsengine.io.gson;

import java.lang.reflect.Type;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.nucleus.common.TypeResolver;
import com.nucleus.component.Component;
import com.nucleus.io.gson.NucleusDeserializer;
import com.nucleus.system.ComponentHandler;
import com.nucleus.system.System;

/**
 * Deserializes the specified {@linkplain Component} from JSON.
 * Returns the correct subclass of {@linkplain Component}
 * 
 */
public class ComponentDeserializer extends NucleusDeserializer implements JsonDeserializer<Component> {

    @Override
    public Component deserialize(JsonElement json, Type type, JsonDeserializationContext context)
            throws JsonParseException {
        JsonObject obj = json.getAsJsonObject();
        String typeName = obj.get(Component.TYPE).getAsString();
        Component c = (Component) gson.fromJson(json, TypeResolver.getInstance().getTypeClass(typeName));
        ComponentHandler handler = ComponentHandler.getInstance();
        try {
            handler.registerComponent(c, (System) TypeResolver.getInstance().create(c.getSystem()));
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
            return null;
        }
        return c;
    }

}

@@ -1178,16 +1178,32 @@
         
+ System system =
  handler
@@ -1207,86 +1207,64 @@
 ler.
+c
 re
-gisterComponent(c, (System) TypeResolver.getInstance().create(c.getSystem())
+ateSystem(c);%0A            handler.registerComponent(c
 );%0A 

Use updated componenthandler in ComponentNodeDeserializer