Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Using the branch handler in your component is quite easy.

1. Declare a member variable for the BranchHandler:

Code Block
languagejava
themeEclipse
BranchHandler branchHandler = null;

2. Initialize the branch handler in your initialize() method based on your component's configuration:

Code Block
languagejava
themeEclipse
branchHandler = BranchHandlerFactory.newInstance(config, this); 

3. If you have some branch events which are required, check that they exist and throw an exception if they don't. This is also typically in your initialize() method:

Code Block
languagejava
themeEclipse
if(!branchHandler.canEnqueueOrProcess("onPublish")) {
     throw new AspireException(this, "aspire.framework.FeedOne.missing-branch-with-pipelinemanager",
         "The FeedOne component needs to be configured with a branches/branch that specifies a pipeline manager. Either the branches or branch tags are missing, or a pipeline manager is not specified with the @pipelineManager attribute.");
}

4. For new jobs or sub-jobs only(!), you can use the [enqueue()] method to queue the job on a pipeline manager queue:

Code Block
languagejava
themeEclipse
branchHandler.enqueue(j, "onPublish");

...