Class ResourceCollectionLifecycleFactory<T extends ResourceCollectionLifecycle>
java.lang.Object
com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
com.inductiveautomation.ignition.gateway.resourcecollection.ResourceCollectionLifecycleFactory<T>
- All Implemented Interfaces:
Lifecycle
- Direct Known Subclasses:
EventStreamProjectLifecycleFactory
public abstract class ResourceCollectionLifecycleFactory<T extends ResourceCollectionLifecycle>
extends AbstractLifecycle
A factory for creating and managing
ResourceCollectionLifecycles. Subclasses define some filtering logic to
determine which collections and which resources are relevant, and then a factory method to instantiate the resource
collection lifecycle objects. This class will then take care of listening for changes to the relevant collections,
and starting and stopping the lifecycle objects as necessary as collections are added, removed, or changed to match
or mismatch the getResourceCollectionFilter() predicate.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptionabstract TcreateLifecycle(RuntimeResourceCollection collection) Create an instance ofResourceCollectionLifecyclethat can manage runtime and lifecycle forcollection.getLifecycle(String name) Get theResourceCollectionLifecycleforname, if it exists.final com.google.common.collect.ImmutableList<T>Get an immutable copy of the currentResourceCollectionLifecycles.Return aPredicatethat indicates whether a collection should have aResourceCollectionLifecyclecreated for it.protected abstract ResourceFilterGet theResourceFilterto apply when getting matching resources this lifecycle is interested in.protected final voidprotected final voidvoidWe may need to restart all lifecycles of a type (such as scripting) if a module is installed, restarted or uninstalled.Methods inherited from class com.inductiveautomation.ignition.common.lifecycle.AbstractLifecycle
isRunning, shutdown, startup
-
Field Details
-
IS_RUNNABLE
-
-
Constructor Details
-
ResourceCollectionLifecycleFactory
-
-
Method Details
-
onStartup
protected final void onStartup()- Specified by:
onStartupin classAbstractLifecycle
-
onShutdown
protected final void onShutdown()- Specified by:
onShutdownin classAbstractLifecycle
-
getLifecycle
Get theResourceCollectionLifecycleforname, if it exists.- Parameters:
name- the resource collection name the lifecycle belongs to.- Returns:
- the
ResourceCollectionLifecycleforname, if it exists.
-
getLifecycles
Get an immutable copy of the currentResourceCollectionLifecycles.- Returns:
- an immutable copy of the current
ResourceCollectionLifecycles.
-
createLifecycle
Create an instance ofResourceCollectionLifecyclethat can manage runtime and lifecycle forcollection.- Parameters:
collection- theRuntimeResourceCollectionthat will be run.- Returns:
- a
ResourceCollectionLifecyclethat can manage runtime and lifecycle forcollection.
-
restartAll
public void restartAll()We may need to restart all lifecycles of a type (such as scripting) if a module is installed, restarted or uninstalled. Most LifecycleFactories will not override this. -
getResourceFilter
Get theResourceFilterto apply when getting matching resources this lifecycle is interested in.- Returns:
- the
ResourceFilterto apply when matching resources this lifecycle is interested in.
-
getResourceCollectionFilter
Return aPredicatethat indicates whether a collection should have aResourceCollectionLifecyclecreated for it.For example, if the collection doesn't contain any resources of a certain type then this predicate could return
falseto avoid creating a lifecycle that doesn't actually have any resources to run.Should resources of an interesting type later get added the machinery of
ResourceCollectionLifecycleFactoryensures a lifecycle will have a chance to be created at that time.The default implementation is RuntimeResourceCollection::isRunnable
- Returns:
- a
Predicatethat indicates whether a resource collection should have aResourceCollectionLifecyclecreated for it.
-