From ded286c7eb9fa65dd2bc8b753ab292ae1414784d Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 21 May 2020 10:46:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=B2=E7=AA=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fr/learn/Leaner.java | 32 ++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/fr/learn/Leaner.java b/src/main/java/com/fr/learn/Leaner.java index c35f2ab..57f8090 100644 --- a/src/main/java/com/fr/learn/Leaner.java +++ b/src/main/java/com/fr/learn/Leaner.java @@ -1,8 +1,11 @@ package com.fr.learn; -import com.fr.start.Designer; +import com.fr.log.FineLoggerFactory; -public class Leaner extends Designer { +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class Leaner { static { // 这段代码让插件能支持远程设计的时候的调试 @@ -10,7 +13,28 @@ public class Leaner extends Designer { System.setProperty("fine.plugin.home", workDir + "/webroot/WEB-INF/plugins"); } - public Leaner(String[] strings) { - super(strings); + public static void main(String[] args) { + try { + Class mainClass = Class.forName("com.fr.start.MainDesigner"); + invokeMain(mainClass, args); + } catch (ClassNotFoundException e) { + // MainDesigner找不到,走以前的Designer + try { + Class oldMainClass = Class.forName("com.fr.start.Designer"); + invokeMain(oldMainClass, args); + } catch (ClassNotFoundException ex) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + } + + private static void invokeMain(Class clazz, String[] args) { + try { + Method method = clazz.getMethod("main", String[].class); + Object[] param = new Object[] {args}; + method.invoke(clazz, param); + } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } } }