-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
159 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 0 additions & 87 deletions
87
mybatis-idea-plugin/src/main/java/com/plugins/mybaitslog/rmi/RmiServer.java
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
mybatis-idea-plugin/src/main/java/com/plugins/mybaitslog/unix/UnixServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.plugins.mybaitslog.unix; | ||
|
||
import com.intellij.openapi.project.Project; | ||
import com.plugins.mybaitslog.Config; | ||
import com.plugins.mybaitslog.console.PrintlnUtil; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.net.StandardProtocolFamily; | ||
import java.net.UnixDomainSocketAddress; | ||
import java.nio.ByteBuffer; | ||
import java.nio.channels.ServerSocketChannel; | ||
import java.nio.channels.SocketChannel; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
/** | ||
* A <code>RmiServer</code> Class | ||
* | ||
* @author lk | ||
* @version 1.0 | ||
* <p><b>date: 2023/5/12 19:20</b></p> | ||
*/ | ||
public class UnixServer { | ||
|
||
public static Map<Project, String> RMISERVERID = new ConcurrentHashMap<Project, String>(); | ||
|
||
public static String getId(@NotNull Project project) { | ||
return RMISERVERID.get(project); | ||
} | ||
|
||
public static void boot(@NotNull Project project) { | ||
String id = UUID.randomUUID().toString().replace("-", ""); | ||
RMISERVERID.put(project, id); | ||
//无法支持到1.8后续再想办法 | ||
/* | ||
final boolean runRmi = Config.Idea.getRunRmi(); | ||
if (runRmi) { | ||
new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
try { | ||
String id = UUID.randomUUID().toString().replace("-", ""); | ||
RMISERVERID.put(project, id); | ||
Path socketPath = Path | ||
.of(System.getProperty("java.io.tmpdir")) | ||
.resolve(id + ".socket"); | ||
Files.deleteIfExists(socketPath); | ||
ServerSocketChannel serverSocketChannel = ServerSocketChannel.open(StandardProtocolFamily.UNIX); | ||
UnixDomainSocketAddress of = UnixDomainSocketAddress.of(socketPath); | ||
serverSocketChannel.bind(of); | ||
while (true) { | ||
SocketChannel socketChannel = serverSocketChannel.accept(); | ||
ByteBuffer buf = ByteBuffer.allocate(1024); | ||
int bytesRead = socketChannel.read(buf); | ||
while (bytesRead > 0) { | ||
buf.flip(); | ||
StringBuffer stringBuffer = new StringBuffer(); | ||
while (buf.hasRemaining()) { | ||
stringBuffer.append((char) buf.get()); | ||
} | ||
buf.clear(); | ||
PrintlnUtil.prints(project, stringBuffer.toString()); | ||
bytesRead = socketChannel.read(buf); | ||
} | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
}).start(); | ||
}*/ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
<vendor email="[email protected]" url="https://github.com/Link-Kou/intellij-mybaitslog">linkkou</vendor> | ||
|
||
<!-- 插件版本 --> | ||
<version>5.0.8.1</version> | ||
<version>5.0.8.2</version> | ||
<!-- please see https://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description --> | ||
<idea-version since-build="201"/> | ||
<!-- 插件的描述 --> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
mybatis-plugin/src/main/java/com/linkkou/mybatis/log/MyBatisLogRmi.java
This file was deleted.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
mybatis-plugin/src/main/java/com/linkkou/mybatis/log/PrintlnLog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.linkkou.mybatis.log; | ||
|
||
import com.google.gson.internal.JavaVersion; | ||
|
||
import java.net.StandardProtocolFamily; | ||
import java.net.UnixDomainSocketAddress; | ||
import java.nio.ByteBuffer; | ||
import java.nio.channels.SocketChannel; | ||
import java.nio.file.Path; | ||
import java.util.concurrent.locks.Lock; | ||
import java.util.concurrent.locks.ReentrantLock; | ||
|
||
/** | ||
* A <code>RmiLog</code> Class | ||
* | ||
* @author lk | ||
* @version 1.0 | ||
* <p><b>date: 2023/5/12 19:28</b></p> | ||
*/ | ||
public class PrintlnLog { | ||
|
||
private static SocketChannel socketChannel; | ||
private static boolean connect = false; | ||
|
||
private static SocketChannel client(String id) { | ||
return null; | ||
//目前无法支持到1.8 | ||
/*if (null == id) { | ||
return null; | ||
} | ||
if (socketChannel != null && connect) { | ||
return socketChannel; | ||
} | ||
Lock lock = new ReentrantLock(); //注意这个地方 | ||
lock.lock(); | ||
try { | ||
Path socketPath = Path.of(System.getProperty("java.io.tmpdir")).resolve(id + ".socket"); | ||
socketChannel = SocketChannel.open(StandardProtocolFamily.UNIX); | ||
UnixDomainSocketAddress of = UnixDomainSocketAddress.of(socketPath); | ||
connect = socketChannel.connect(of); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} finally { | ||
lock.unlock(); | ||
} | ||
return socketChannel;*/ | ||
} | ||
|
||
public static void log(String log, String id) { | ||
final SocketChannel client = client(id); | ||
if (!connect) { | ||
System.out.println(log); | ||
} else { | ||
try { | ||
ByteBuffer buf = ByteBuffer.allocate(log.length()); | ||
buf.clear(); | ||
buf.put(log.getBytes()); | ||
buf.flip(); | ||
while (buf.hasRemaining()) { | ||
client.write(buf); | ||
} | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.