Class WrapperServiceInfoHolder

java.lang.Object
eu.cloudnetservice.wrapper.holder.WrapperServiceInfoHolder
All Implemented Interfaces:
ServiceInfoHolder

@Singleton @Provides(ServiceInfoHolder.class) public final class WrapperServiceInfoHolder extends Object implements ServiceInfoHolder
The default implementation of a service info holder for the wrapper.
Since:
4.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final WrapperConfiguration
     
    private static final VarHandle
     
    private eu.cloudnetservice.driver.service.ServiceInfoSnapshot
     
    private final eu.cloudnetservice.driver.event.EventManager
     
    private static final VarHandle
     
    private eu.cloudnetservice.driver.service.ServiceInfoSnapshot
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    WrapperServiceInfoHolder(@NonNull eu.cloudnetservice.driver.event.EventManager eventManager, @NonNull WrapperConfiguration configuration)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot
    Creates a new service snapshot of this service, copying over the properties of the current service info snapshot, then configuring it using the registered listeners of the ServiceInfoSnapshotConfigureEvent.
    private void
    configureServiceInfoSnapshot(@NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot serviceInfoSnapshot)
    Configures the given service info snapshot and updates the current and old service snapshot.
    @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot
    Creates a new service snapshot of this service, copying over the properties of the current service info snapshot.
    @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot
    createServiceInfoSnapshot(@NonNull eu.cloudnetservice.driver.document.Document properties)
    Creates a new service snapshot of this service using the provided properties for the new snapshot.
    @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot
    Gets the last service info snapshot before the current one was created.
    void
    Creates a new service snapshot, configures it, updates the current and old one and sends an update to all components which are currently registered within the CloudNet network.
    void
    publishServiceInfoUpdate(@NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot serviceInfoSnapshot)
    Updates the given service snapshot to all components which are currently registered within the CloudNet network.
    @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot
    Get the current service info snapshot which is synced to all components in the network.
    void
    Setups the initial service information, this method can only be called once per lifecycle.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LAST_INFO_VAR_HANDLE

      private static final VarHandle LAST_INFO_VAR_HANDLE
    • CURRENT_INFO_VARHANDLE

      private static final VarHandle CURRENT_INFO_VARHANDLE
    • eventManager

      private final eu.cloudnetservice.driver.event.EventManager eventManager
    • configuration

      private final WrapperConfiguration configuration
    • lastServiceInfoSnapshot

      private eu.cloudnetservice.driver.service.ServiceInfoSnapshot lastServiceInfoSnapshot
    • currentServiceInfoSnapshot

      private eu.cloudnetservice.driver.service.ServiceInfoSnapshot currentServiceInfoSnapshot
  • Constructor Details

  • Method Details

    • setup

      public void setup()
      Setups the initial service information, this method can only be called once per lifecycle.
      Specified by:
      setup in interface ServiceInfoHolder
    • serviceInfo

      @NonNull public @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot serviceInfo()
      Get the current service info snapshot which is synced to all components in the network.
      Specified by:
      serviceInfo in interface ServiceInfoHolder
      Returns:
      the current service info snapshot.
    • lastServiceInfo

      @NonNull public @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot lastServiceInfo()
      Gets the last service info snapshot before the current one was created.
      Specified by:
      lastServiceInfo in interface ServiceInfoHolder
      Returns:
      the last service info snapshot.
    • createServiceInfoSnapshot

      @NonNull public @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot createServiceInfoSnapshot()
      Creates a new service snapshot of this service, copying over the properties of the current service info snapshot. Only the creation time and process snapshot of the new snapshot differ from the old snapshot.
      Specified by:
      createServiceInfoSnapshot in interface ServiceInfoHolder
      Returns:
      the newly created service snapshot for this service.
    • createServiceInfoSnapshot

      @NonNull public @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot createServiceInfoSnapshot(@NonNull @NonNull eu.cloudnetservice.driver.document.Document properties)
      Creates a new service snapshot of this service using the provided properties for the new snapshot. Only the creation time, process snapshot and properties of the new snapshot differ from the old snapshot.

      Changes made to the current service snapshot (like modifying the properties of it) will not reflect into the snapshot returned by this method.

      Specified by:
      createServiceInfoSnapshot in interface ServiceInfoHolder
      Parameters:
      properties - the properties to apply to the new snapshot.
      Returns:
      the newly created service snapshot for this service.
    • configureServiceInfoSnapshot

      @NonNull public @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot configureServiceInfoSnapshot()
      Creates a new service snapshot of this service, copying over the properties of the current service info snapshot, then configuring it using the registered listeners of the ServiceInfoSnapshotConfigureEvent.

      Changes made to the current service snapshot (like modifying the properties of it) will not reflect into the snapshot returned by this method.

      This method will (unlike the createServiceInfoSnapshot method) change the current and old service snapshot to the newly created and configured one.

      Specified by:
      configureServiceInfoSnapshot in interface ServiceInfoHolder
      Returns:
      the newly created service snapshot for this service.
    • publishServiceInfoUpdate

      public void publishServiceInfoUpdate()
      Creates a new service snapshot, configures it, updates the current and old one and sends an update to all components which are currently registered within the CloudNet network.
      Specified by:
      publishServiceInfoUpdate in interface ServiceInfoHolder
    • publishServiceInfoUpdate

      public void publishServiceInfoUpdate(@NonNull @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot serviceInfoSnapshot)
      Updates the given service snapshot to all components which are currently registered within the CloudNet network. This method will configure the given snapshot if it belongs to the current wrapper instance.
      Specified by:
      publishServiceInfoUpdate in interface ServiceInfoHolder
      Parameters:
      serviceInfoSnapshot - the service snapshot to update.
    • configureServiceInfoSnapshot

      private void configureServiceInfoSnapshot(@NonNull @NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshot serviceInfoSnapshot)
      Configures the given service info snapshot and updates the current and old service snapshot.
      Parameters:
      serviceInfoSnapshot - the service snapshot to configure.
      Throws:
      NullPointerException - if the given snapshot is null.