container/src/main/java/com/streamsets/datacollector/creation/StageLibraryDelegateCreator.java
public <R> R createAndInitialize(
    StageLibraryTask stageLib,
    Configuration configuration,
    String stageLibraryName,
    Class<R> exportedInterface
  ) {
    StageLibraryDelegate instance = create(
      stageLib,
      stageLibraryName,
      exportedInterface
    );
    if(instance == null) {
      return null;
    }

    // Create & set context
    StageLibraryDelegateContext context = new StageLibraryDelegateContext(
      configuration
    );
    instance.setContext(context);

    return (R)new StageLibraryDelegateRuntime(
      instance.getClass().getClassLoader(),
      instance
    );
  }
public <R> R createAndInitialize(
    StageLibraryTask stageLib,
    Configuration configuration,
    String stageLibraryName,
    Class<R> exportedInterface
  ) {
    StageLibraryDelegate instance = create(
      stageLib,
      stageLibraryName,
      exportedInterface
    );
    if(instance == null) {
      return null;
    }

    // Create & set context
    StageLibraryDelegateContext context = new StageLibraryDelegateContext(
      configuration
    );
    instance.setContext(context);

    return (R)new StageLibraryDelegateRuntime(
      instance.getClass().getClassLoader(),
      instance
    );
  }
Create and initialize new delegate.

We usually have this functionality in a builder somewhere else (like a Pipeline.Builder), but
we put it here for now for simplicity. Since this is container-only class, we will be able to
move this logic somewhere else at a later time without difficulties.

@param stageLib Stage library task instance.
@param configuration SDC Configuration
@param stageLibraryName Name of the stage library from which the delegator should be loaded.
@param exportedInterface Interface describing which delegator is needed
@param <R>  Interface describing which delegator is needed
@return Wrapped new instance of the delegator or null on any issue