Skip to content

Commit 53fc909

Browse files
Initial commit
0 parents  commit 53fc909

70 files changed

Lines changed: 3510 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.gradle
2+
build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
!**/src/main/**/build/
5+
!**/src/test/**/build/
6+
.kotlin
7+
8+
### IntelliJ IDEA ###
9+
.idea/modules.xml
10+
.idea/jarRepositories.xml
11+
.idea/compiler.xml
12+
.idea/libraries/
13+
*.iws
14+
*.iml
15+
*.ipr
16+
out/
17+
!**/src/main/**/out/
18+
!**/src/test/**/out/
19+
20+
### Eclipse ###
21+
.apt_generated
22+
.classpath
23+
.factorypath
24+
.project
25+
.settings
26+
.springBeans
27+
.sts4-cache
28+
bin/
29+
!**/src/main/**/bin/
30+
!**/src/test/**/bin/
31+
32+
### NetBeans ###
33+
/nbproject/private/
34+
/nbbuild/
35+
/dist/
36+
/nbdist/
37+
/.nb-gradle/
38+
39+
### VS Code ###
40+
.vscode/
41+
42+
### Mac OS ###
43+
.DS_Store

build.gradle

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
group = 'com.artur114.bytecodegrab.main'
6+
archivesBaseName = "ByteCodeGrabber"
7+
version = '1.0-SNAPSHOT'
8+
9+
repositories {
10+
mavenCentral()
11+
}
12+
13+
configurations {
14+
include; implementation.extendsFrom(include)
15+
}
16+
17+
dependencies {
18+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
19+
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
20+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
21+
implementation files(getToolsJar())
22+
23+
include 'org.apache.logging.log4j:log4j-slf4j2-impl:2.20.0'
24+
include 'org.apache.logging.log4j:log4j-api:2.0-beta9'
25+
include 'com.google.code.gson:gson:2.8.9'
26+
include 'com.formdev:flatlaf:3.7'
27+
}
28+
29+
jar {
30+
manifest { attributes 'Main-Class': 'com.artur114.bytecodegrab.main.Main' }
31+
from { configurations.include.collect { it.isDirectory() ? it : zipTree(it) } }
32+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
33+
}
34+
35+
tasks.withType(JavaCompile).configureEach {
36+
options.encoding = 'UTF-8'
37+
}
38+
39+
test {
40+
useJUnitPlatform()
41+
}
42+
43+
def getToolsJar() {
44+
def jar = files(
45+
"${System.properties['java.home']}/../lib/tools.jar",
46+
"${System.properties['java.home']}/lib/tools.jar"
47+
).find { it.exists() }
48+
if (jar != null) {
49+
return jar
50+
}
51+
throw new GradleException()
52+
}

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'ByteCodeGrabber'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.artur114.bytecodegrab.agent;
2+
3+
import java.io.DataInputStream;
4+
import java.io.EOFException;
5+
import java.io.IOException;
6+
7+
public class AbortListener extends Thread {
8+
private final DataInputStream connection;
9+
private final IAgentLogger logger;
10+
private boolean aborted = false;
11+
12+
public AbortListener(IAgentLogger logger, SocketA connection) {
13+
try {
14+
this.connection = new DataInputStream(connection.getInputStream());
15+
this.logger = logger;
16+
} catch (IOException e) {
17+
throw new RuntimeException(e);
18+
}
19+
}
20+
21+
public boolean isAborted() {
22+
return this.aborted;
23+
}
24+
25+
public void shutdown() {
26+
this.interrupt();
27+
try {
28+
this.connection.close();
29+
} catch (IOException ignored) {}
30+
}
31+
32+
@Override
33+
public void run() {
34+
try {
35+
String message = this.connection.readUTF();
36+
37+
if ("ABORT".equals(message)) {
38+
this.aborted = true;
39+
} else {
40+
this.logger.warn("AbortListener listen not abort message {}!", message);
41+
}
42+
} catch (EOFException e) {
43+
this.aborted = true;
44+
} catch (IOException e) {
45+
e.printStackTrace(System.err);
46+
}
47+
}
48+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.artur114.bytecodegrab.agent;
2+
3+
public class AgentLoggerAsync implements IAgentLogger {
4+
private final AsyncTaskProcessor processor;
5+
private final IAgentLogger output;
6+
7+
public AgentLoggerAsync(IAgentLogger output) {
8+
this.output = output;
9+
10+
this.processor = new AsyncTaskProcessor();
11+
this.processor.setName("BCG Logging Thread");
12+
this.processor.start();
13+
}
14+
15+
public void shutdown() {
16+
this.processor.shutdown();
17+
}
18+
19+
@Override
20+
public void warn(String log) {
21+
this.processor.addTask(() -> this.output.warn(log));
22+
}
23+
24+
@Override
25+
public void info(String log) {
26+
this.processor.addTask(() -> this.output.info(log));
27+
}
28+
29+
@Override
30+
public void error(String log) {
31+
this.processor.addTask(() -> this.output.error(log));
32+
}
33+
34+
@Override
35+
public void warn(String log, Object arg) {
36+
this.processor.addTask(() -> this.output.warn(log, arg));
37+
}
38+
39+
@Override
40+
public void info(String log, Object arg) {
41+
this.processor.addTask(() -> this.output.info(log, arg));
42+
}
43+
44+
@Override
45+
public void error(String log, Object arg) {
46+
this.processor.addTask(() -> this.output.error(log, arg));
47+
}
48+
49+
@Override
50+
public void warn(String log, Object... args) {
51+
this.processor.addTask(() -> this.output.warn(log, args));
52+
}
53+
54+
@Override
55+
public void info(String log, Object... args) {
56+
this.processor.addTask(() -> this.output.info(log, args));
57+
}
58+
59+
@Override
60+
public void error(String log, Object... args) {
61+
this.processor.addTask(() -> this.output.error(log, args));
62+
}
63+
64+
@Override
65+
public void warn(String log, Object arg, Object arg1) {
66+
this.processor.addTask(() -> this.output.warn(log, arg, arg1));
67+
}
68+
69+
@Override
70+
public void info(String log, Object arg, Object arg1) {
71+
this.processor.addTask(() -> this.output.info(log, arg, arg1));
72+
}
73+
74+
@Override
75+
public void error(String log, Object arg, Object arg1) {
76+
this.processor.addTask(() -> this.output.error(log, arg, arg1));
77+
}
78+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.artur114.bytecodegrab.agent;
2+
3+
import org.apache.logging.log4j.LogManager;
4+
import org.apache.logging.log4j.Logger;
5+
6+
public class AgentLoggerLog4j implements IAgentLogger {
7+
private final Logger logger = LogManager.getLogger("BYTECODEGARB-AGENT");
8+
9+
@Override
10+
public void warn(String log) {
11+
this.logger.warn(log);
12+
}
13+
14+
@Override
15+
public void info(String log) {
16+
this.logger.info(log);
17+
}
18+
19+
@Override
20+
public void error(String log) {
21+
this.logger.error(log);
22+
}
23+
24+
@Override
25+
public void warn(String log, Object arg) {
26+
this.logger.warn(log, arg);
27+
}
28+
29+
@Override
30+
public void info(String log, Object arg) {
31+
this.logger.info(log, arg);
32+
}
33+
34+
@Override
35+
public void error(String log, Object arg) {
36+
this.logger.error(log, arg);
37+
}
38+
39+
@Override
40+
public void warn(String log, Object... args) {
41+
this.logger.warn(log, args);
42+
}
43+
44+
@Override
45+
public void info(String log, Object... args) {
46+
this.logger.info(log, args);
47+
}
48+
49+
@Override
50+
public void error(String log, Object... args) {
51+
this.logger.error(log, args);
52+
}
53+
54+
@Override
55+
public void warn(String log, Object arg, Object arg1) {
56+
this.logger.warn(log, arg, arg1);
57+
}
58+
59+
@Override
60+
public void info(String log, Object arg, Object arg1) {
61+
this.logger.info(log, arg, arg1);
62+
}
63+
64+
@Override
65+
public void error(String log, Object arg, Object arg1) {
66+
this.logger.error(log, arg, arg1);
67+
}
68+
}

0 commit comments

Comments
 (0)