diff --git a/src/main/java/com/insigma/service/Database.java b/src/main/java/com/insigma/service/Database.java index eff03eb..e9dc6a8 100644 --- a/src/main/java/com/insigma/service/Database.java +++ b/src/main/java/com/insigma/service/Database.java @@ -35,10 +35,21 @@ public interface Database { } /*** * 清除 应用 缓存 + * @param sql 需要执行脚本集合 + * @param tabColObjs 索引对象列表 * @return */ default boolean cleanDbCache(List sql, List tabColObjs) { System.out.println("进行缓存清除,但是未检测到实现应用调用此方法!"); return false; } + + /** + * 实现注册服务 + * @return + */ + default boolean registrationDbService(){ + System.out.println("进行数据库注册服务,但是未检测到实现应用调用此方法!"); + return false; + } } diff --git a/src/main/java/com/insigma/service/Middleware.java b/src/main/java/com/insigma/service/Middleware.java index 65ba402..a465696 100644 --- a/src/main/java/com/insigma/service/Middleware.java +++ b/src/main/java/com/insigma/service/Middleware.java @@ -29,4 +29,13 @@ public interface Middleware { System.out.printf("设置应用参数:%d,但是未检测到实现应用调用此方法!", size); return false; } + + /** + * 实现注册服务 + * @return + */ + default boolean registrationMwService(){ + System.out.println("进行中间件注册服务,但是未检测到实现应用调用此方法!"); + return false; + } } diff --git a/src/main/java/com/insigma/service/impl/LinuxTongWebKingBase.java b/src/main/java/com/insigma/service/impl/LinuxTongWebKingBase.java new file mode 100644 index 0000000..0603d79 --- /dev/null +++ b/src/main/java/com/insigma/service/impl/LinuxTongWebKingBase.java @@ -0,0 +1,67 @@ +package com.insigma.service.impl; + +import com.insigma.entry.IndexObj; +import com.insigma.entry.TabColObj; +import com.insigma.service.Computer; +import com.insigma.service.Database; +import com.insigma.service.Middleware; +import com.insigma.utils.LinuxCommandUtil; +import lombok.extern.slf4j.Slf4j; + +import java.util.List; + +/** + * (LinuxTongWebKingBase 类) linux 下 东方通 + 金昌 + * + * @author zhangxianwei + * @since 16:43 2022/4/19 + */ +@Slf4j +public class LinuxTongWebKingBase extends Computer implements Database, Middleware { + + @Override + public boolean runShell(String shell) { + try { + new LinuxCommandUtil(shell).run(); + }catch (Exception e){ + log.error("执行发生异常:{}", e.getMessage()); + return false; + } + return true; + } + + @Override + public boolean rebuildIndex(List index) { + return Database.super.rebuildIndex(index); + } + + @Override + public boolean setDbSize(int size) { + return Database.super.setDbSize(size); + } + + @Override + public boolean cleanDbCache(List sql, List tabColObjs) { + return Database.super.cleanDbCache(sql, tabColObjs); + } + + @Override + public boolean registrationDbService() { + return Database.super.registrationDbService(); + } + + @Override + public boolean cleanMwCache() { + return Middleware.super.cleanMwCache(); + } + + @Override + public boolean setMwSize(int size) { + return Middleware.super.setMwSize(size); + } + + @Override + public boolean registrationMwService() { + return Middleware.super.registrationMwService(); + } +} diff --git a/src/main/java/com/insigma/service/impl/WindowsTomcatMysql.java b/src/main/java/com/insigma/service/impl/WindowsTomcatMysql.java index a32b09e..3c8967f 100644 --- a/src/main/java/com/insigma/service/impl/WindowsTomcatMysql.java +++ b/src/main/java/com/insigma/service/impl/WindowsTomcatMysql.java @@ -17,7 +17,7 @@ import java.util.List; /** - * (CuWindows 类) windows + tomcat + mysql + * (CuWindows 类) windows 环境下 tomcat + mysql * * @author zhangxianwei * @since 23:30 2022/4/17 @@ -29,7 +29,8 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware public boolean runShell(String shell) { try { new WinCommandUtil(shell).run(); - }catch (Exception ignored){ + }catch (Exception e){ + log.error("执行发生异常:{}", e.getMessage()); return false; } return true; @@ -94,6 +95,11 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware return true; } + @Override + public boolean registrationDbService() { + return true; + } + @Override public boolean cleanMwCache() { log.info("停止 中间件 服务..."); @@ -128,6 +134,11 @@ public class WindowsTomcatMysql extends Computer implements Database, Middleware return true; } + @Override + public boolean registrationMwService() { + return true; + } + public void openServer(){ runShell("SERVICES.MSC"); log.info("打开本地服务完成!"); diff --git a/src/main/java/com/insigma/utils/LinuxCommandUtil.java b/src/main/java/com/insigma/utils/LinuxCommandUtil.java index ce974d7..2ae1607 100644 --- a/src/main/java/com/insigma/utils/LinuxCommandUtil.java +++ b/src/main/java/com/insigma/utils/LinuxCommandUtil.java @@ -14,6 +14,7 @@ import java.io.InputStreamReader; * @author admin */ @Slf4j +@SuppressWarnings("DuplicatedCode") public class LinuxCommandUtil implements Runnable { private String command; diff --git a/src/main/java/com/insigma/utils/RegisterUtil.java b/src/main/java/com/insigma/utils/RegisterUtil.java deleted file mode 100644 index a83992a..0000000 --- a/src/main/java/com/insigma/utils/RegisterUtil.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.insigma.utils; - -/** - * (RegisterUtil 类) - * - * @author zhangxianwei - * @since 18:02 2022/4/18 - */ -public class RegisterUtil { - - -} diff --git a/src/main/java/com/insigma/utils/WinCommandUtil.java b/src/main/java/com/insigma/utils/WinCommandUtil.java index 08f7ef0..72daba0 100644 --- a/src/main/java/com/insigma/utils/WinCommandUtil.java +++ b/src/main/java/com/insigma/utils/WinCommandUtil.java @@ -4,6 +4,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; import java.io.*; +import java.util.prefs.Preferences; /** * CommandImpUtil @@ -11,6 +12,7 @@ import java.io.*; * @author admin */ @Slf4j +@SuppressWarnings("DuplicatedCode") public class WinCommandUtil implements Runnable { private String command; @@ -71,4 +73,22 @@ public class WinCommandUtil implements Runnable { } } } + + public static class RegisterUtil { + + String[] keys = {"version", "initial", "creator"}; + String[] values = {"1.3", "ini.mp3", "caokai1818@sina.com"}; + //把相应的值储存到变量中去 + public void writeValue() { + // HKEY_LOCAL_MACHINE\Software\JavaSoft\prefs下写入注册表值. + Preferences pre = Preferences.systemRoot().node("/javaplayer"); + for (int i = 0; i < keys.length; i++) { + pre.put(keys[i], values[i]); + } + } + public static void main(String[] args) { + RegisterUtil reg = new RegisterUtil(); + reg.writeValue(); + } + } } \ No newline at end of file