diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/InitializePipelineOptionsFactory.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/InitializePipelineOptionsFactory.java new file mode 100644 index 000000000000..7d1cffacea51 --- /dev/null +++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/InitializePipelineOptionsFactory.java @@ -0,0 +1,29 @@ +package org.apache.beam.sdk.options; + +import java.util.Iterator; +import java.util.ServiceLoader; +import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Iterators; +import org.checkerframework.checker.initialization.qual.Initialized; +import org.checkerframework.checker.nullness.qual.Nullable; + + +@SuppressWarnings("rawtypes") +/** + * Interface to support offspring wire-in for Li: if input class meets some requirements, + * the customized pipelineOptions will be initialized. + * + */ +public interface InitializePipelineOptionsFactory { + T initializePipelineOptions(T pipelineOptions, Class clazz); + + interface Registrar { + InitializePipelineOptionsFactory create(); + } + + + static @Initialized @Nullable InitializePipelineOptionsFactory getFactory() { + final Iterator + factories = ServiceLoader.load(InitializePipelineOptionsFactory.Registrar.class).iterator(); + return factories.hasNext() ? Iterators.getOnlyElement(factories).create() : null; + } +} diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/InvokePipelineOptionsFactory.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/InvokePipelineOptionsFactory.java deleted file mode 100644 index 9e643a1aa762..000000000000 --- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/InvokePipelineOptionsFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.apache.beam.sdk.options; - -import java.util.Iterator; -import java.util.ServiceLoader; -import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Iterators; -import org.checkerframework.checker.initialization.qual.Initialized; -import org.checkerframework.checker.nullness.qual.Nullable; - - -@SuppressWarnings("rawtypes") -/** - * Interface to support offspring wire-in for Li - */ -public interface InvokePipelineOptionsFactory { - T getPipelineOptions(T pipelineOptions, Class clazz); - - interface Registrar { - InvokePipelineOptionsFactory create(); - } - - - static @Initialized @Nullable InvokePipelineOptionsFactory getFactory() { - final Iterator - factories = ServiceLoader.load(InvokePipelineOptionsFactory.Registrar.class).iterator(); - return factories.hasNext() ? Iterators.getOnlyElement(factories).create() : null; - } -} diff --git a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java index c67300eff23b..a82563ef340e 100644 --- a/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java +++ b/sdks/java/core/src/main/java/org/apache/beam/sdk/options/ProxyInvocationHandler.java @@ -305,8 +305,8 @@ T as(Class iface, PipelineOptions pipelineOptions computedProperties = computedProperties.updated(iface, existingOption, propertyDescriptors); // Linkedin specific change: initialize the offspring generator - if (pipelineOptions != null && InvokePipelineOptionsFactory.getFactory() != null) { - InvokePipelineOptionsFactory.getFactory().getPipelineOptions(existingOption, iface); + if (pipelineOptions != null && InitializePipelineOptionsFactory.getFactory() != null) { + InitializePipelineOptionsFactory.getFactory().initializePipelineOptions(existingOption, iface); } } }