Class PushNotificationEngineProvider

java.lang.Object
com.iizix.push.PushNotificationEngineProvider

public final class PushNotificationEngineProvider extends Object
The seam through which the push engine implementation reaches com.iizix.core.

The engine lives in the com.iizix.server.push bundle, which requires com.iizix.server, which requires com.iizix.core, where IPushNotificationService lives. Core can therefore not name the engine class and IServer.getPushNotificationEngine() cannot construct it. Instead the engine bundle registers its engine here when its server module is initialized, and unregisters it when the module is disposed; the default accessor on IPushNotificationService reads it back. No server class needs to know the engine's name.

At most one engine is registered at a time: registering a second, live engine is an error, because two engines would each own a spool file, a subscription table and the HTTP endpoints. A disposed engine may be replaced.

Author:
Christopher Mindus
  • Method Details

    • register

      public static void register(IPushNotificationEngine newEngine)
      Registers the engine of this server.
      Parameters:
      newEngine - The engine.
      Throws:
      NullPointerException - If newEngine is null.
      IllegalStateException - If another engine is registered and not disposed.
    • unregister

      public static boolean unregister(IPushNotificationEngine oldEngine)
      Unregisters an engine. Does nothing when another engine is registered.
      Parameters:
      oldEngine - The engine that was registered.
      Returns:
      true if it was the registered engine and is now unregistered, false otherwise.
    • getEngine

      public static IPushNotificationEngine getEngine()
      Gets the registered engine.
      Returns:
      The engine, or null when none is registered.