Skip to content

Commit ea21f8e

Browse files
committed
Add more javadoc.
Signed-off-by: Hiram Chirino <hiram@hiramchirino.com>
1 parent 1cec34c commit ea21f8e

File tree

17 files changed

+384
-7
lines changed

17 files changed

+384
-7
lines changed

proxy-wasm-java-host/src/main/java/io/roastedroot/proxywasm/SimpleMetricsHandler.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
*/
1717
public class SimpleMetricsHandler implements MetricsHandler {
1818

19+
/**
20+
* Default constructor.
21+
*/
22+
public SimpleMetricsHandler() {
23+
// Default constructor for SimpleMetricsHandler
24+
}
25+
1926
/**
2027
* Represents an individual metric managed by {@link SimpleMetricsHandler}.
2128
* Stores the metric's ID, type, name, and its current value.
@@ -42,27 +49,35 @@ public Metric(int id, MetricType type, String name) {
4249
}
4350

4451
/**
52+
* Gets the unique integer ID of the metric.
53+
*
4554
* @return The unique integer ID of the metric.
4655
*/
4756
public int id() {
4857
return id;
4958
}
5059

5160
/**
61+
* Gets the type of the metric.
62+
*
5263
* @return The {@link MetricType} of the metric.
5364
*/
5465
public MetricType type() {
5566
return type;
5667
}
5768

5869
/**
70+
* Gets the name of the metric.
71+
*
5972
* @return The name of the metric.
6073
*/
6174
public String name() {
6275
return name;
6376
}
6477

6578
/**
79+
* Gets the current value of the metric.
80+
*
6681
* @return The current value of the metric.
6782
*/
6883
public long getValue() {

proxy-wasm-java-host/src/main/java/io/roastedroot/proxywasm/SimpleSharedDataHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
*/
1616
public class SimpleSharedDataHandler implements SharedDataHandler {
1717

18+
/**
19+
* Default constructor.
20+
*/
21+
public SimpleSharedDataHandler() {
22+
// Default constructor for SimpleSharedDataHandler
23+
}
24+
1825
private final HashMap<String, SharedData> sharedData = new HashMap<>();
1926

2027
/**

proxy-wasm-java-host/src/main/java/io/roastedroot/proxywasm/SimpleSharedQueueHandler.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
*/
1717
public class SimpleSharedQueueHandler implements SharedQueueHandler {
1818

19+
/**
20+
* Default constructor.
21+
*/
22+
public SimpleSharedQueueHandler() {
23+
// Default constructor for SimpleSharedQueueHandler
24+
}
25+
1926
/**
2027
* Represents an individual shared queue managed by {@link SimpleSharedQueueHandler}.
2128
* Each queue has a unique name (within its VM), a host-assigned ID, and holds its data

quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/App.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,37 @@
55
import com.dylibso.chicory.wasm.WasmModule;
66
import io.roastedroot.proxywasm.Plugin;
77
import io.roastedroot.proxywasm.PluginFactory;
8-
import io.roastedroot.proxywasm.StartException;
98
import jakarta.enterprise.context.ApplicationScoped;
109
import jakarta.enterprise.inject.Produces;
1110
import java.nio.file.Path;
1211

12+
/**
13+
* Application configuration class for the proxy-wasm JAX-RS example.
14+
* Sets up the Wasm PluginFactory for the example plugin.
15+
*/
1316
@ApplicationScoped
1417
public class App {
1518

19+
/**
20+
* Default constructor.
21+
*/
22+
public App() {
23+
// Default constructor
24+
}
25+
1626
private static WasmModule module =
1727
Parser.parse(
1828
Path.of("../proxy-wasm-java-host/src/test/go-examples/unit_tester/main.wasm"));
1929

20-
// configure the the example wasm plugin
30+
/**
31+
* Produces the PluginFactory for the example Wasm plugin.
32+
* Configures the plugin with necessary settings like name, shared status,
33+
* plugin configuration, and machine factory.
34+
*
35+
* @return A configured PluginFactory for the example plugin.
36+
*/
2137
@Produces
22-
public PluginFactory example() throws StartException {
38+
public PluginFactory example() {
2339
return () ->
2440
Plugin.builder(module)
2541
.withName("example")

quarkus-proxy-wasm-example/src/main/java/io/roastedroot/proxywasm/jaxrs/example/Resources.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,26 @@
44
import jakarta.ws.rs.GET;
55
import jakarta.ws.rs.Path;
66

7+
/**
8+
* JAX-RS resource class for the proxy-wasm example.
9+
* Defines endpoints for testing the Wasm plugin.
10+
*/
711
@Path("/")
812
public class Resources {
913

14+
/**
15+
* Default constructor.
16+
*/
17+
public Resources() {
18+
// Default constructor
19+
}
20+
21+
/**
22+
* Handles GET requests to the /test path.
23+
* Applies the "example" Wasm plugin.
24+
*
25+
* @return A simple "Hello World" string.
26+
*/
1027
@Path("/test")
1128
@GET
1229
@WasmPlugin("example") // filter with example wasm plugin

quarkus-proxy-wasm/integration-tests/src/main/java/io/quarkiverse/proxywasm/it/App.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,43 @@
1313
import java.nio.file.Path;
1414
import java.util.Map;
1515

16+
/**
17+
* Application configuration for integration tests.
18+
* Provides CDI producers for various {@link PluginFactory} configurations used in tests.
19+
*/
1620
@ApplicationScoped
1721
public class App {
1822

23+
/**
24+
* Default constructor.
25+
*/
26+
public App() {
27+
// Default constructor
28+
}
29+
30+
/**
31+
* Directory containing the example Wasm modules used for testing.
32+
*/
1933
public static final String EXAMPLES_DIR = "../../proxy-wasm-java-host/src/test";
34+
2035
private static final Gson gson = new Gson();
2136

37+
/**
38+
* Parses a Wasm module from the specified file path relative to the examples directory.
39+
*
40+
* @param file The relative path to the Wasm module file.
41+
* @return The parsed {@link WasmModule}.
42+
*/
2243
public static WasmModule parseTestModule(String file) {
2344
return Parser.parse(Path.of(EXAMPLES_DIR + file));
2445
}
2546

47+
/**
48+
* Produces a {@link PluginFactory} for header manipulation tests (shared instance).
49+
*
50+
* @return A configured {@link PluginFactory}.
51+
* @throws StartException If plugin initialization fails.
52+
*/
2653
@Produces
2754
public PluginFactory headerTests() throws StartException {
2855
return () ->
@@ -34,6 +61,12 @@ public PluginFactory headerTests() throws StartException {
3461
.build();
3562
}
3663

64+
/**
65+
* Produces a {@link PluginFactory} for header manipulation tests (non-shared instances).
66+
*
67+
* @return A configured {@link PluginFactory}.
68+
* @throws StartException If plugin initialization fails.
69+
*/
3770
@Produces
3871
public PluginFactory headerTestsNotShared() throws StartException {
3972
return () ->
@@ -45,6 +78,12 @@ public PluginFactory headerTestsNotShared() throws StartException {
4578
.build();
4679
}
4780

81+
/**
82+
* Produces a {@link PluginFactory} for tick-based tests.
83+
*
84+
* @return A configured {@link PluginFactory}.
85+
* @throws StartException If plugin initialization fails.
86+
*/
4887
@Produces
4988
public PluginFactory tickTests() throws StartException {
5089
return () ->
@@ -57,6 +96,12 @@ public PluginFactory tickTests() throws StartException {
5796
.build();
5897
}
5998

99+
/**
100+
* Produces a {@link PluginFactory} for Foreign Function Interface (FFI) tests.
101+
*
102+
* @return A configured {@link PluginFactory}.
103+
* @throws StartException If plugin initialization fails.
104+
*/
60105
@Produces
61106
public PluginFactory ffiTests() throws StartException {
62107
return () ->
@@ -70,6 +115,12 @@ public PluginFactory ffiTests() throws StartException {
70115
.build();
71116
}
72117

118+
/**
119+
* Reverses the byte order of the input data. Used as an FFI function in tests.
120+
*
121+
* @param data The byte array to reverse.
122+
* @return A new byte array with the reversed content.
123+
*/
73124
public static byte[] reverse(byte[] data) {
74125
byte[] reversed = new byte[data.length];
75126
for (int i = 0; i < data.length; i++) {
@@ -78,6 +129,12 @@ public static byte[] reverse(byte[] data) {
78129
return reversed;
79130
}
80131

132+
/**
133+
* Produces a {@link PluginFactory} for HTTP call tests.
134+
*
135+
* @return A configured {@link PluginFactory}.
136+
* @throws StartException If plugin initialization fails.
137+
*/
81138
@Produces
82139
public PluginFactory httpCallTests() throws StartException {
83140
return () ->

quarkus-proxy-wasm/integration-tests/src/main/java/io/quarkiverse/proxywasm/it/MockLogger.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@
44
import io.roastedroot.proxywasm.LogLevel;
55
import java.util.ArrayList;
66

7+
/**
8+
* A mock implementation of {@link LogHandler} for testing purposes.
9+
* Stores logged messages in memory and optionally prints them to the console if DEBUG is enabled.
10+
*/
711
public class MockLogger implements LogHandler {
812

913
static final boolean DEBUG = "true".equals(System.getenv("DEBUG"));
1014

1115
final ArrayList<String> loggedMessages = new ArrayList<>();
1216
private final String name;
1317

18+
/**
19+
* Constructs a new MockLogger with the given name.
20+
*
21+
* @param name The name to associate with logged messages.
22+
*/
1423
public MockLogger(String name) {
1524
this.name = name;
1625
}
@@ -28,6 +37,11 @@ public synchronized LogLevel getLogLevel() {
2837
return LogLevel.TRACE;
2938
}
3039

40+
/**
41+
* Retrieves a copy of all messages logged by this instance.
42+
*
43+
* @return A new {@link ArrayList} containing the logged messages.
44+
*/
3145
public synchronized ArrayList<String> loggedMessages() {
3246
return new ArrayList<>(loggedMessages);
3347
}

0 commit comments

Comments
 (0)