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
ResourceCollectionLifecycle
s. 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 T
createLifecycle
(RuntimeResourceCollection collection) Create an instance ofResourceCollectionLifecycle
that can manage runtime and lifecycle forcollection
.getLifecycle
(String name) Get theResourceCollectionLifecycle
forname
, if it exists.final com.google.common.collect.ImmutableList<T>
Get an immutable copy of the currentResourceCollectionLifecycle
s.Return aPredicate
that indicates whether a collection should have aResourceCollectionLifecycle
created for it.protected abstract ResourceFilter
Get theResourceFilter
to apply when getting matching resources this lifecycle is interested in.protected final void
protected final void
void
We 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:
onStartup
in classAbstractLifecycle
-
onShutdown
protected final void onShutdown()- Specified by:
onShutdown
in classAbstractLifecycle
-
getLifecycle
Get theResourceCollectionLifecycle
forname
, if it exists.- Parameters:
name
- the resource collection name the lifecycle belongs to.- Returns:
- the
ResourceCollectionLifecycle
forname
, if it exists.
-
getLifecycles
Get an immutable copy of the currentResourceCollectionLifecycle
s.- Returns:
- an immutable copy of the current
ResourceCollectionLifecycle
s.
-
createLifecycle
Create an instance ofResourceCollectionLifecycle
that can manage runtime and lifecycle forcollection
.- Parameters:
collection
- theRuntimeResourceCollection
that will be run.- Returns:
- a
ResourceCollectionLifecycle
that 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 theResourceFilter
to apply when getting matching resources this lifecycle is interested in.- Returns:
- the
ResourceFilter
to apply when matching resources this lifecycle is interested in.
-
getResourceCollectionFilter
Return aPredicate
that indicates whether a collection should have aResourceCollectionLifecycle
created for it.For example, if the collection doesn't contain any resources of a certain type then this predicate could return
false
to 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
ResourceCollectionLifecycleFactory
ensures a lifecycle will have a chance to be created at that time.The default implementation is RuntimeResourceCollection::isRunnable
- Returns:
- a
Predicate
that indicates whether a resource collection should have aResourceCollectionLifecycle
created for it.
-