|
|
@ -1,17 +1,15 @@ |
|
|
|
package com.fr.design; |
|
|
|
package com.fr.design; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
|
|
|
import com.fr.design.os.impl.RestartAction; |
|
|
|
import com.fr.design.os.impl.RestartAction; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.os.OperatingSystem; |
|
|
|
|
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
import com.fr.stable.StableUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.os.support.OSBasedAction; |
|
|
|
import com.fr.stable.os.support.OSBasedAction; |
|
|
|
import com.fr.stable.os.support.OSSupportCenter; |
|
|
|
import com.fr.stable.os.support.OSSupportCenter; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileInputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
@ -19,8 +17,6 @@ import java.io.IOException; |
|
|
|
import java.io.RandomAccessFile; |
|
|
|
import java.io.RandomAccessFile; |
|
|
|
import java.nio.channels.FileChannel; |
|
|
|
import java.nio.channels.FileChannel; |
|
|
|
import java.nio.channels.FileLock; |
|
|
|
import java.nio.channels.FileLock; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Properties; |
|
|
|
import java.util.Properties; |
|
|
|
|
|
|
|
|
|
|
@ -33,8 +29,7 @@ public class RestartHelper { |
|
|
|
|
|
|
|
|
|
|
|
public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties"); |
|
|
|
public static final String RECORD_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "delete.properties"); |
|
|
|
public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties"); |
|
|
|
public static final String MOVE_FILE = StableUtils.pathJoin(StableUtils.getInstallHome(), "move.properties"); |
|
|
|
|
|
|
|
private static OSBasedAction osBasedAction; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 把要删除的文件都记录到delete.properties中 |
|
|
|
* 把要删除的文件都记录到delete.properties中 |
|
|
|
* |
|
|
|
* |
|
|
@ -171,11 +166,10 @@ public class RestartHelper { |
|
|
|
}catch (Exception e){ |
|
|
|
}catch (Exception e){ |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
OSBasedAction osBasedAction = OSSupportCenter.getAction(RestartAction.class); |
|
|
|
|
|
|
|
osBasedAction.execute(filesToBeDelete); |
|
|
|
osBasedAction.execute(filesToBeDelete); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
} finally { |
|
|
|
}finally { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (null != randomAccessFile) { |
|
|
|
if (null != randomAccessFile) { |
|
|
|
randomAccessFile.close(); |
|
|
|
randomAccessFile.close(); |
|
|
@ -185,41 +179,12 @@ public class RestartHelper { |
|
|
|
} |
|
|
|
} |
|
|
|
DesignerContext.getDesignerFrame().exit(); |
|
|
|
DesignerContext.getDesignerFrame().exit(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* private static void restartInMacOS(String installHome, String[] filesToBeDelete) throws Exception { |
|
|
|
|
|
|
|
ProcessBuilder builder = new ProcessBuilder(); |
|
|
|
|
|
|
|
List<String> commands = new ArrayList<String>(); |
|
|
|
|
|
|
|
commands.add("open"); |
|
|
|
|
|
|
|
commands.add(installHome + File.separator + "bin" + File.separator + "restart.app"); |
|
|
|
|
|
|
|
if (ArrayUtils.isNotEmpty(filesToBeDelete)) { |
|
|
|
|
|
|
|
commands.add("--args"); |
|
|
|
|
|
|
|
commands.add(StableUtils.join(filesToBeDelete, "+")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
builder.command(commands); |
|
|
|
|
|
|
|
builder.start(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
private static void restartInWindows(String installHome, String[] filesToBeDelete) throws Exception { |
|
|
|
* 提前初始化重启动作 |
|
|
|
ProcessBuilder builder = new ProcessBuilder(); |
|
|
|
*/ |
|
|
|
List<String> commands = new ArrayList<String>(); |
|
|
|
public static void initRestartAction(){ |
|
|
|
commands.add(installHome + File.separator + "bin" + File.separator + "restart.exe"); |
|
|
|
osBasedAction = OSSupportCenter.getAction(RestartAction.class); |
|
|
|
if (ArrayUtils.isNotEmpty(filesToBeDelete)) { |
|
|
|
|
|
|
|
commands.add(StableUtils.join(filesToBeDelete, "+")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
builder.command(commands); |
|
|
|
|
|
|
|
builder.start(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void restartInLinux(String installHome, String[] filesToBeDelete) throws Exception { |
|
|
|
|
|
|
|
ProcessBuilder builder = new ProcessBuilder(); |
|
|
|
|
|
|
|
List<String> commands = new ArrayList<String>(); |
|
|
|
|
|
|
|
//现在先写的是restart.sh
|
|
|
|
|
|
|
|
commands.add(installHome + File.separator + "bin" + File.separator + "restart.sh"); |
|
|
|
|
|
|
|
if (ArrayUtils.isNotEmpty(filesToBeDelete)) { |
|
|
|
|
|
|
|
commands.add(StableUtils.join(filesToBeDelete, "+")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
builder.command(commands); |
|
|
|
|
|
|
|
builder.start(); |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |