container/src/main/java/com/streamsets/datacollector/creation/PipelineBeanCreator.java
public StageBean createStageBean(
      boolean forExecution,
      StageLibraryTask library,
      StageConfiguration stageConf,
      boolean validateAnnotations,
      boolean errorStage,
      boolean pipelineLifecycleStage,
      Map<String, Object> constants,
      InterceptorCreatorContextBuilder interceptorContextBuilder,
      List<Issue> errors
  ) {
    IssueCreator issueCreator = IssueCreator.getStage(stageConf.getInstanceName());
    StageBean bean = null;
    StageDefinition stageDef = library.getStage(stageConf.getLibrary(), stageConf.getStageName(),
                                                forExecution);
    if (stageDef != null) {
      // Pipeline lifecycle events validation must match, whether it's also marked as error stage does not matter
      if(validateAnnotations) {
        if (pipelineLifecycleStage) {
          if (!stageDef.isPipelineLifecycleStage()) {
            errors.add(issueCreator.create(
              CreationError.CREATION_018,
              stageDef.getLibraryLabel(),
              stageDef.getLabel(),
              stageConf.getStageVersion())
            );
          }
          // For non pipeline lifecycle stages, the error stage annotation must match
        } else if (stageDef.isErrorStage() != errorStage) {
          if (stageDef.isErrorStage()) {
            errors.add(issueCreator.create(CreationError.CREATION_007, stageDef.getLibraryLabel(), stageDef.getLabel(),
              stageConf.getStageVersion()));
          } else {
            errors.add(issueCreator.create(CreationError.CREATION_008, stageDef.getLibraryLabel(), stageDef.getLabel(),
              stageConf.getStageVersion()));
          }
        }
      }

      bean = createStage(
        library,
        stageDef,
        library,
        stageConf,
        serviceClass -> library.getServiceDefinition(serviceClass, true),
        interceptorContextBuilder,
        constants,
        errors
      );
    } else {
      errors.add(issueCreator.create(CreationError.CREATION_006, stageConf.getLibrary(), stageConf.getStageName(),
                                     stageConf.getStageVersion()));
    }
    return bean;
  }
public StageBean createStageBean(
      boolean forExecution,
      StageLibraryTask library,
      StageConfiguration stageConf,
      boolean validateAnnotations,
      boolean errorStage,
      boolean pipelineLifecycleStage,
      Map<String, Object> constants,
      InterceptorCreatorContextBuilder interceptorContextBuilder,
      List<Issue> errors
  ) {
    IssueCreator issueCreator = IssueCreator.getStage(stageConf.getInstanceName());
    StageBean bean = null;
    StageDefinition stageDef = library.getStage(stageConf.getLibrary(), stageConf.getStageName(),
                                                forExecution);
    if (stageDef != null) {
      // Pipeline lifecycle events validation must match, whether it's also marked as error stage does not matter
      if(validateAnnotations) {
        if (pipelineLifecycleStage) {
          if (!stageDef.isPipelineLifecycleStage()) {
            errors.add(issueCreator.create(
              CreationError.CREATION_018,
              stageDef.getLibraryLabel(),
              stageDef.getLabel(),
              stageConf.getStageVersion())
            );
          }
          // For non pipeline lifecycle stages, the error stage annotation must match
        } else if (stageDef.isErrorStage() != errorStage) {
          if (stageDef.isErrorStage()) {
            errors.add(issueCreator.create(CreationError.CREATION_007, stageDef.getLibraryLabel(), stageDef.getLabel(),
              stageConf.getStageVersion()));
          } else {
            errors.add(issueCreator.create(CreationError.CREATION_008, stageDef.getLibraryLabel(), stageDef.getLabel(),
              stageConf.getStageVersion()));
          }
        }
      }

      bean = createStage(
        library,
        stageDef,
        library,
        stageConf,
        serviceClass -> library.getServiceDefinition(serviceClass, true),
        interceptorContextBuilder,
        constants,
        errors
      );
    } else {
      errors.add(issueCreator.create(CreationError.CREATION_006, stageConf.getLibrary(), stageConf.getStageName(),
                                     stageConf.getStageVersion()));
    }
    return bean;
  }
Create new instance of StageBean.

This method can be used outside of pipeline context (for example for detached stage).

@param forExecution If the instance is going to be used for execution (and for example private classloaders must be respected)
@param library Stage Library from which a definition will be loaded
@param stageConf Stage configuration
@param errorStage True if the stage needs to be declared as error stage
@param pipelineLifecycleStage True if the stage needs to be declared as pipeline lifecycle stage
@param constants Pipeline constants (runtime parameters)
@param errors List where all errors will be persisted
@return New StageBean instance or null on any error