class CompositeItemWriteListener<S> implements ItemWriteListener<S> {

	private final OrderedComposite<ItemWriteListener<? super S>> listeners = new OrderedComposite<>();

	/**
	 * Public setter for the listeners.
	 * @param itemWriteListeners list of {@link ItemWriteListener}s to be called when
	 * write events occur.
	 */
	public void setListeners(List<? extends ItemWriteListener<? super S>> itemWriteListeners) {
		this.listeners.setItems(itemWriteListeners);
	}

	/**
	 * Register additional listener.
	 * @param itemWriteListener list of {@link ItemWriteListener}s to be registered.
	 */
	public void register(ItemWriteListener<? super S> itemWriteListener) {
		listeners.add(itemWriteListener);
	}

	/**
	 * Call the registered listeners in reverse order, respecting and prioritising those
	 * that implement {@link Ordered}.
	 * @see ItemWriteListener#afterWrite(Chunk)
	 */
	@Override
	public void afterWrite(Chunk<? extends S> items) {
		for (Iterator<ItemWriteListener<? super S>> iterator = listeners.reverse(); iterator.hasNext();) {
			ItemWriteListener<? super S> listener = iterator.next();
			listener.afterWrite(items);
		}
	}

	/**
	 * Call the registered listeners in order, respecting and prioritising those that
	 * implement {@link Ordered}.
	 * @see ItemWriteListener#beforeWrite(Chunk)
	 */
	@Override
	public void beforeWrite(Chunk<? extends S> items) {
		for (Iterator<ItemWriteListener<? super S>> iterator = listeners.iterator(); iterator.hasNext();) {
			ItemWriteListener<? super S> listener = iterator.next();
			listener.beforeWrite(items);
		}
	}

	/**
	 * Call the registered listeners in reverse order, respecting and prioritising those
	 * that implement {@link Ordered}.
	 * @see ItemWriteListener#onWriteError(Exception, Chunk)
	 */
	@Override
	public void onWriteError(Exception ex, Chunk<? extends S> items) {<FILL_FUNCTION_BODY>}

}

		for (Iterator<ItemWriteListener<? super S>> iterator = listeners.reverse(); iterator.hasNext();) {
			ItemWriteListener<? super S> listener = iterator.next();
			listener.onWriteError(ex, items);
		}
	
<no_super_class>