| | |
| | | * |
| | | * |
| | | * Copyright 2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2016 ForgeRock AS |
| | | */ |
| | | package org.opends.server.util.cli; |
| | | |
| | |
| | | |
| | | import com.forgerock.opendj.cli.ConsoleApplication; |
| | | |
| | | /** |
| | | * Class used to add points periodically to the end of the output. |
| | | */ |
| | | /** Class used to add points periodically to the end of the output. */ |
| | | public class PointAdder implements Runnable |
| | | { |
| | | private final ConsoleApplication app; |
| | |
| | | private boolean stopPointAdder; |
| | | private boolean pointAdderStopped; |
| | | private long periodTime = DEFAULT_PERIOD_TIME; |
| | | private final boolean isError; |
| | | private final ProgressMessageFormatter formatter; |
| | | |
| | | |
| | | /** |
| | | * The default period time used to write points in the output. |
| | | */ |
| | | /** The default period time used to write points in the output. */ |
| | | public static final long DEFAULT_PERIOD_TIME = 3000; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public PointAdder(ConsoleApplication app) |
| | | { |
| | | this(app, DEFAULT_PERIOD_TIME, false, |
| | | new PlainTextProgressMessageFormatter()); |
| | | this(app, DEFAULT_PERIOD_TIME, new PlainTextProgressMessageFormatter()); |
| | | } |
| | | |
| | | /** |
| | |
| | | * The console application to be used. |
| | | * @param periodTime |
| | | * The time between printing two points. |
| | | * @param isError |
| | | * Whether the points must be printed in error stream or output |
| | | * stream. |
| | | * @param formatter |
| | | * The text formatter. |
| | | */ |
| | | public PointAdder(ConsoleApplication app, |
| | | long periodTime, boolean isError, |
| | | ProgressMessageFormatter formatter) |
| | | public PointAdder(ConsoleApplication app, long periodTime, ProgressMessageFormatter formatter) |
| | | { |
| | | this.app = app; |
| | | this.periodTime = periodTime; |
| | | this.isError = isError; |
| | | this.formatter = formatter; |
| | | } |
| | | |
| | | /** |
| | | * Starts the PointAdder: points are added at the end of the logs |
| | | * periodically. |
| | | */ |
| | | /** Starts the PointAdder: points are added at the end of the logs periodically. */ |
| | | public void start() |
| | | { |
| | | LocalizableMessageBuilder mb = new LocalizableMessageBuilder(); |
| | |
| | | t.start(); |
| | | } |
| | | |
| | | /** |
| | | * Stops the PointAdder: points are no longer added at the end of the logs |
| | | * periodically. |
| | | */ |
| | | /** Stops the PointAdder: points are no longer added at the end of the logs periodically. */ |
| | | public synchronized void stop() |
| | | { |
| | | stopPointAdder = true; |
| | |
| | | } |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void run() |
| | | { |
| | | while (!stopPointAdder) |