Class LoopedPlugin

java.lang.Object
net.storm.api.plugins.Plugin
net.storm.api.plugins.LoopedPlugin
All Implemented Interfaces:
com.google.inject.Module, org.pf4j.ExtensionPoint
Direct Known Subclasses:
LoopedPlugin, TaskPlugin

public abstract class LoopedPlugin extends Plugin
Abstract base class for plugins that execute in a continuous loop.

LoopedPlugin extends Plugin and provides a simple loop-based execution model. The loop() method is called repeatedly until the plugin is stopped. The return value of loop() determines the delay in milliseconds before the next iteration.

Example usage:


 @PluginDescriptor(
     name = "My Looped Plugin",
     description = "A plugin that runs in a loop"
 )
 public class MyLoopedPlugin extends LoopedPlugin {
     @Override
     public int loop() {
         // Perform some action
         doSomething();

         // Return delay in milliseconds before next iteration
         return 1000; // Wait 1 second
     }
 }
 

See Also:
  • Constructor Details

    • LoopedPlugin

      public LoopedPlugin()
  • Method Details

    • stop

      @Deprecated(forRemoval=true) public void stop()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use the plugin manager to stop plugins instead
      Stops the plugin execution.

      Sets the stopped flag to true, which will cause the loop to terminate.

    • loop

      public abstract int loop()
      The main loop method that is called repeatedly while the plugin is running.

      Implement this method to define the plugin's behavior. The method will be called continuously until the plugin is stopped.

      Returns:
      the delay in milliseconds before the next loop iteration. Return a positive value to add a delay, or 0 for immediate execution. Typical values range from 100-1000ms depending on the task.