AbstractEvent.java

mudlibs/tinylib/src/net/sourceforge/pain/tinylib/logic/event/AbstractEvent.java · 1.1 KB

From the archive pain_0_45.tgz

Download the archive   « Back to the archive contents

package net.sourceforge.pain.tinylib.logic.event;

import net.sourceforge.pain.*;
import net.sourceforge.pain.db.*;
import net.sourceforge.pain.logic.*;

/**
 * AbstractEvent is a base class for any Event, this class is a first reloadable class in Events hierarchy
 */
public abstract class AbstractEvent implements Event {

    public Object processEvent(final Object param) throws Exception {
        final DbTransaction t = new DbTransaction() {
            public Object execute(Object[] params) throws Exception {
                return AbstractEvent.this.execute(param);
            }
        };
        Codebase.getDB().execute(t);
        return null;
    }

    public AbstractEvent() {
        // debug check
        ClassLoader loader = Codebase.getLogicLoader().getActiveClassLoader();
        if (loader != getClass().getClassLoader()) {
            throw new RuntimeException("BUG: all Act subclasses MUST be loaded via Codebase.createAct() method!");
        }
    }

    public abstract Object execute(Object param) throws Exception;

}

Site Stats

Snippets: 1791
Codebases: 571