Class Spawnery

java.lang.Object
cloud.spawnery.agent.api.Spawnery

public final class Spawnery extends Object
How a plugin gets a SpawneryApi, in one line and the same line on both platforms.

A static holder rather than each platform's service registry. The agent calls install(cloud.spawnery.agent.api.SpawneryApi) once as it enables; everybody else calls api().

  • Method Details

    • api

      public static SpawneryApi api()
      The API this server's agent installed.
      Throws:
      SpawneryUnavailableException - if no agent has installed one -- see that type for the two ways that happens.
    • isAvailable

      public static boolean isAvailable()
      Whether api() would return rather than throw.
    • install

      public static void install(SpawneryApi api)
      Installs the implementation. Called by the agent and by nothing else.

      Refuses a second install rather than replacing the first, which would leave plugins holding a handle to a dead agent.

      Throws:
      IllegalStateException - if one is already installed
    • uninstall

      public static void uninstall()
      Removes the installed API. For the agent's own shutdown, and for tests.