package com.dy.pipIrrParamSet; 
 | 
  
 | 
import com.dy.pipIrrParamSet.console.CommandConsole; 
 | 
import org.springframework.beans.factory.annotation.Autowired; 
 | 
import org.springframework.stereotype.Component; 
 | 
  
 | 
import java.io.Console; 
 | 
  
 | 
/** 
 | 
 * @Author: liurunyu 
 | 
 * @Date: 2025/5/28 15:36 
 | 
 * @Description 
 | 
 */ 
 | 
@Component 
 | 
public class Server { 
 | 
  
 | 
    private CommandConsole mwConsole ; 
 | 
  
 | 
    @Autowired 
 | 
    public void setBean(CommandConsole console){ 
 | 
        this.mwConsole = console; 
 | 
    } 
 | 
  
 | 
    public void startServer() throws Exception{ 
 | 
        Console console = System.console(); 
 | 
        if (console == null) { 
 | 
            throw new Exception("严重错误,未能得到控制台对象!"); 
 | 
        } 
 | 
        mwConsole.init(console); 
 | 
        boolean exit = mwConsole.execute() ; 
 | 
        if(exit){ 
 | 
            System.exit(-1); 
 | 
        } 
 | 
    } 
 | 
} 
 |