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
FieldsModifier and TypeFieldDescriptionprivate final WrapperConfigurationprivate static final VarHandleprivate eu.cloudnetservice.driver.service.ServiceInfoSnapshotprivate final eu.cloudnetservice.driver.event.EventManagerprivate static final VarHandleprivate eu.cloudnetservice.driver.service.ServiceInfoSnapshot -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateWrapperServiceInfoHolder(@NonNull eu.cloudnetservice.driver.event.EventManager eventManager, @NonNull WrapperConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescription@NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshotCreates 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 theServiceInfoSnapshotConfigureEvent.private voidconfigureServiceInfoSnapshot(@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.ServiceInfoSnapshotCreates a new service snapshot of this service, copying over the properties of the current service info snapshot.@NonNull eu.cloudnetservice.driver.service.ServiceInfoSnapshotcreateServiceInfoSnapshot(@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.ServiceInfoSnapshotGets the last service info snapshot before the current one was created.voidCreates 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.voidpublishServiceInfoUpdate(@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.ServiceInfoSnapshotGet the current service info snapshot which is synced to all components in the network.voidsetup()Setups the initial service information, this method can only be called once per lifecycle.
-
Field Details
-
LAST_INFO_VAR_HANDLE
-
CURRENT_INFO_VARHANDLE
-
eventManager
private final eu.cloudnetservice.driver.event.EventManager eventManager -
configuration
-
lastServiceInfoSnapshot
private eu.cloudnetservice.driver.service.ServiceInfoSnapshot lastServiceInfoSnapshot -
currentServiceInfoSnapshot
private eu.cloudnetservice.driver.service.ServiceInfoSnapshot currentServiceInfoSnapshot
-
-
Constructor Details
-
WrapperServiceInfoHolder
@Inject private WrapperServiceInfoHolder(@NonNull @NonNull eu.cloudnetservice.driver.event.EventManager eventManager, @NonNull @NonNull WrapperConfiguration configuration)
-
-
Method Details
-
setup
public void setup()Setups the initial service information, this method can only be called once per lifecycle.- Specified by:
setupin interfaceServiceInfoHolder
-
serviceInfo
Get the current service info snapshot which is synced to all components in the network.- Specified by:
serviceInfoin interfaceServiceInfoHolder- Returns:
- the current service info snapshot.
-
lastServiceInfo
Gets the last service info snapshot before the current one was created.- Specified by:
lastServiceInfoin interfaceServiceInfoHolder- 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:
createServiceInfoSnapshotin interfaceServiceInfoHolder- 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:
createServiceInfoSnapshotin interfaceServiceInfoHolder- 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 theServiceInfoSnapshotConfigureEvent.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
createServiceInfoSnapshotmethod) change the current and old service snapshot to the newly created and configured one.- Specified by:
configureServiceInfoSnapshotin interfaceServiceInfoHolder- 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:
publishServiceInfoUpdatein interfaceServiceInfoHolder
-
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:
publishServiceInfoUpdatein interfaceServiceInfoHolder- 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.
-