Class VirtualMachine

java.lang.Object
org.geysermc.conduit.VirtualMachine

public class VirtualMachine extends Object
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 Details

    • intercept

      public VirtualMachine intercept(Class<?>... handlerClasses)
      Registers intercept handlers. Each must be annotated with Intercept, and any Intercept.Capture fields on it are created if they are still null.
      Parameters:
      handlerClasses - the handlers
      Returns:
      this machine
      Throws:
      IllegalArgumentException - if a class has no Intercept annotation
    • capture

      public <T> VirtualMachine capture(CaptureChannel<T> channel, Consumer<T> listener)
      Listens on a channel for the next execute() 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's Intercept.Capture field
      listener - the listener
      Returns:
      this machine
    • execute

      public void execute()
      Scans the context, invoking handlers as matching calls are found.
    • executeUninterruptibly

      public CompletableFuture<Void> executeUninterruptibly()
      Runs execute() on the common pool.
      Returns:
      a future completing when the scan finishes