Class ResourceCollectionLifecycle

java.lang.Object
com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
com.inductiveautomation.ignition.gateway.resourcecollection.ResourceCollectionLifecycle
All Implemented Interfaces:
Lifecycle
Direct Known Subclasses:
EventStreamProjectLifecycleFactory.Lifecycle

public abstract class ResourceCollectionLifecycle extends AbstractLifecycle
A resource collection lifecycle is a specialized AbstractLifecycle that is designed to make implementing lifecycle management for a RuntimeResourceCollection easier.

The way to use this class is to implement a subclass that is interested in a specific type or set of types of resource. Instances of this class will then be created by a ResourceCollectionLifecycleFactory and startup up for each relevant resource collection in the system.

Whenever the resource collection is changed, this class's listener methods will be invoked, in the following order.

Note that onBeforeChanges(ResourceChangeContext) and onAfterChanges() are guaranteed to be called once for each resource collection update.
  • Constructor Details

  • Method Details

    • initialize

      public final void initialize(ResourceFilter resourceFilter)
    • onStartup

      protected final void onStartup()
      Specified by:
      onStartup in class AbstractLifecycle
    • onShutdown

      protected final void onShutdown()
      Specified by:
      onShutdown in class AbstractLifecycle
    • getResourceCollection

      public final RuntimeResourceCollection getResourceCollection()
    • onStartup

      protected abstract void onStartup(List<Resource> resources)
      Parameters:
      resources - initial list of resources that match the scope and type interests of this lifecycle.
    • onShutdown

      protected abstract void onShutdown(List<ResourceId> resourceIds)
      Parameters:
      resourceIds - list of ResourceIds that match the scope and type interests of this lifecycle.
    • getResourceChangeFilter

      protected Predicate<Resource> getResourceChangeFilter()
      Get the filter that filters Resources provided to onResourcesCreated(List) and onResourcesModified(List).
      Returns:
      the filter
    • onBeforeChanges

      protected void onBeforeChanges(ResourceChangeContext context)
      Called before a series of calls to the resource modification methods begins.
    • onAfterChanges

      protected void onAfterChanges()
      Called after a series of calls to the resource modification methods is complete.
    • onManifestChanged

      protected void onManifestChanged(ResourceCollectionManifest manifest)
      The ResourceCollectionManifest for the Project managed by this lifecycle has changed.
      Parameters:
      manifest - the updated ResourceCollectionManifest.
    • onResourcesCreated

      protected abstract void onResourcesCreated(List<Resource> resources)
      Resources matching the interests of this lifecycle were created.

      This is a chance for subclasses to do something of interest with these new resources, e.g. "run" them.

      Parameters:
      resources - Resources matching the interests of this lifecycle.
    • onResourcesModified

      protected abstract void onResourcesModified(List<Resource> resources)
      Resources matching the interests of this lifecycle were modified.

      This is a chance for subclasses to do something of interest with these modified resources, e.g. stop "running" something based on the old resource and start "running" something based on the newly modified resource.

      Parameters:
      resources - Resources matching the interests of this lifecycle.
    • onResourcesDeleted

      protected abstract void onResourcesDeleted(List<ResourceId> resourceIds)
      Resources matching the interests of this lifecycle were deleted.

      This is a chance for subclasses to do something of interest with these deleted resources, e.g. stop "running" something based on the resource.

      Parameters:
      resourceIds - ResourceIds matching the interests of this lifecycle.