Class VirtualMachine
java.lang.Object
org.geysermc.conduit.VirtualMachine
Scans every jar in a
ConduitContext and dispatches matching calls to Intercept
handlers.
VirtualMachine vm = VirtualMachineFactory.create(context).await();
vm.intercept(ColorRegistry.class);
vm.capture(ColorRegistry.CAPTURE, color -> colors.add(color));
vm.execute();
Nothing in the scanned jars is loaded or run. Context jars are read to follow calls into them, but are not scanned themselves.
-
Method Summary
Modifier and TypeMethodDescription<T> VirtualMachinecapture(CaptureChannel<T> channel, Consumer<T> listener) Listens on a channel for the nextexecute()only.voidexecute()Scans the context, invoking handlers as matching calls are found.Runsexecute()on the common pool.Registers intercept handlers.
-
Method Details
-
intercept
Registers intercept handlers. Each must be annotated withIntercept, and anyIntercept.Capturefields on it are created if they are still null.- Parameters:
handlerClasses- the handlers- Returns:
- this machine
- Throws:
IllegalArgumentException- if a class has noInterceptannotation
-
capture
Listens on a channel for the nextexecute()only. Channels are static and shared between machines, so the listener is removed once the run finishes.- Type Parameters:
T- the type of item emitted- Parameters:
channel- the channel, usually a handler'sIntercept.Capturefieldlistener- the listener- Returns:
- this machine
-
execute
public void execute()Scans the context, invoking handlers as matching calls are found. -
executeUninterruptibly
Runsexecute()on the common pool.- Returns:
- a future completing when the scan finishes
-