view src/main/java/alice/topology/node/ExecuteEvent.java @ 473:041ec04d4d45 dispose

refactor
author sugi
date Sun, 30 Nov 2014 00:00:48 +0900
parents 780ae843cdac
children cf345b10a21a
line wrap: on
line source

package alice.topology.node;

import java.util.List;

import alice.codesegment.CloseEventCodeSegment;
import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;

public class ExecuteEvent<T> extends CodeSegment {

    public Receiver info = ids.create(CommandType.TAKE);
    public Receiver info1 = ids.create(CommandType.TAKE);

    public ExecuteEvent() {
        info.setKey("_DEVENTLIST");
        info1.setKey("_DISCONNECT");
    }

    @SuppressWarnings("unchecked")
    @Override
    public void run() {
        List<Class<T>> eventList = info.asClass(List.class);
        try {
            for (Class<T> clazz : eventList){
                // set MetaInfo
                if ("CloseEventCodeSegment".equals(clazz.getSuperclass().getSimpleName())) {
                    CloseEventCodeSegment obj = (CloseEventCodeSegment) clazz.newInstance();
                    obj.metaInfo = info;
                    obj.ids.setKey();
                    obj.ids.receive();
                } else if ("CodeSegment".equals(clazz.getSuperclass().getSimpleName())){
                    clazz.newInstance();
                }
            }
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        }
        ods.put(info.key, info.getReceiveData());
    }

}