package data; import java.io.File; import java.io.IOException; import java.net.ServerSocket; import org.apache.log4j.xml.DOMConfigurator; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import data.util.Location; public class Entrance { /** * @属性 locationpath: 获取程序工作目录 */ private static Location locationpath = new Location(); /** * @属性 context: 应用程序上下文 */ private static ApplicationContext context; /** * @属性 serverSocket: 用来绑定端口 */ public static ServerSocket serverSocket; public static void main(String[] args) throws IOException { // 验证输入参数个数 if(args.length != 3){ System.out.println("Import Process needs 3 arguments."); return; } try { // 将进程绑定到输入参数指定的端口 serverSocket = new ServerSocket(Integer.parseInt(args[2])); } catch (NumberFormatException e) { System.out.println("The argument(port) must be a number!"); System.exit(0); } catch (IOException e) { System.out.println("There has already been a running import process!"); System.exit(0); } //初始化配置文件 DOMConfigurator.configure(locationpath.getPath() + File.separator + args[1]); //通过配置文件,初始化Spring配置文件中指定的配置 if (context == null) { context = new FileSystemXmlApplicationContext(args[0]); } } }

qiuyuqiuyuqiuyu
2023年5月25日
暂无贡献等级
Irene777 LV1
2022年2月24日
2898369623 LV1
2021年10月12日
1798672867 LV21
2021年7月18日
哎呀 LV1
2021年5月15日
2018ly
2021年5月13日
暂无贡献等级
FshfshFsh LV2
2021年3月7日
2196316269 LV10
2021年2月24日
litaosb LV5
2020年12月14日
532069753 LV3
2020年5月1日