All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.opentext.ia.sdk.sip.BatchSipAssemblerWithCallback Maven / Gradle / Ivy

There is a newer version: 12.8.4
Show newest version
/*
 * Copyright (c) 2016-2017 by OpenText Corporation. All Rights Reserved.
 */
package com.opentext.ia.sdk.sip;

import java.io.File;
import java.util.function.Consumer;
import java.util.function.Supplier;

import com.opentext.ia.sdk.support.io.FileSupplier;


/**
 * {@linkplain BatchSipAssembler Assemble a batch of SIPs} and invoke a callback after each SIP is closed.
 * 
Warning:
This object is not thread-safe. If you want to use multiple threads to assemble SIPs, let * each use their own instance.
* * @param The type of domain objects to assemble */ public class BatchSipAssemblerWithCallback extends BatchSipAssembler { private Consumer callback; private final Object lock = new Object(); public BatchSipAssemblerWithCallback(SipAssembler assembler, SipSegmentationStrategy segmentationStrategy, Consumer callback) { this(assembler, segmentationStrategy, FileSupplier.fromTemporaryDirectory(), callback); } public BatchSipAssemblerWithCallback(SipAssembler assembler, SipSegmentationStrategy segmentationStrategy, File dir, Consumer callback) { this(assembler, segmentationStrategy, FileSupplier.fromDirectory(dir), callback); } public BatchSipAssemblerWithCallback(SipAssembler assembler, SipSegmentationStrategy segmentationStrategy, Supplier fileSupplier, Consumer callback) { super(assembler, segmentationStrategy, fileSupplier); this.callback = callback; } @Override protected void sipEnded(FileGenerationMetrics metrics) { synchronized (getLock()) { super.sipEnded(metrics); } getCallback().accept(metrics); } protected final Object getLock() { return lock; } protected Consumer getCallback() { return callback; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy