PipelineRunnerRegistrar

PipelineRunnerRegistrar is a way for Beam developers to extend the Beam framework with a new PipelineRunner.

PipelineRunnerRegistrar uses java.util.ServiceLoader utility (with a corresponding META-INF/services directory).

Apache Beam recommends using @AutoService annotation to generate the necessary META-INF files automatically at build time.

Cache.register

void register(
  Class<? extends PipelineOptions> iface)

register is used to register a new PipelineOptions.

register is used when:

Cache.initializeRegistry

void initializeRegistry(
  ClassLoader loader)

initializeRegistry finds all PipelineOptionsRegistrars (in the given ClassLoader) and requests them for PipelineOptions.

initializeRegistry is used when the Cache is created (that happens in a static initialization block of PipelineOptionsFactory when requested to resetCache).

Cache.resetCache

resetCache resets the factory to the default state. That triggers searching the application’s classloader for [PipelineRunnerRegistrars](#PipelineRunnerRegistrar) (using [ReflectHelpers.loadServicesOrdered](#ReflectHelpers)). The PipelineRunnerRegistrars are requested for [PipelineRunners](#PipelineRunner). The PipelineRunners are requested for [PipelineOptions](#PipelineOptions).

With that, [PipelineRunners](#PipelineRunner) and [PipelineOptions](#PipelineOptions) are all registered with the [PipelineOptionsFactory](#PipelineOptionsFactory).

ReflectHelpers.loadServicesOrdered

loadServicesOrdered is used to discover PipelineRunnerRegistrars and PipelineOptionsRegistrars.