001    package railo.runtime.gateway;
002    
003    import org.opencfml.eventgateway.Gateway;
004    import org.opencfml.eventgateway.GatewayEngine;
005    
006    public class GatewayThread extends Thread {
007    
008                    public static final int START=0;
009                    public static final int STOP=1;
010                    public static final int RESTART=2;
011                    
012                    private GatewayEngine engine;
013                    private Gateway gateway;
014                    private int action;
015    
016                    public GatewayThread(GatewayEngine engine,Gateway gateway,int action){
017                            this.engine=engine;
018                            this.gateway=gateway;
019                            this.action=action;
020                    }
021                    
022                    public void run(){
023                            // MUST handle timout
024                            try {
025                            if(action==START) gateway.doStart();
026                            else if(action==STOP) gateway.doStop();
027                            else if(action==RESTART) gateway.doRestart();
028                            }
029                            catch(Throwable ge){
030                                    engine.log(gateway,GatewayEngine.LOGLEVEL_ERROR,ge.getMessage());
031                            }
032                    }
033            }