*
* @param listener listener
* @param safe safe mode
*/
public void distributeFiles(ListenerSupport<FileDistributionListener> listener, final boolean safe) {
final FileDistribution fileDistribution = getConsoleComponent(FileDistribution.class);
final AgentCacheState agentCacheState = fileDistribution.getAgentCacheState();
final Condition cacheStateCondition = new Condition();
agentCacheState.addListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ignored) {
synchronized (cacheStateCondition) {
cacheStateCondition.notifyAll();
}
}
});
final MutableBoolean safeDist = new MutableBoolean(safe);
ConsoleProperties consoleComponent = getConsoleComponent(ConsoleProperties.class);
final File file = consoleComponent.getDistributionDirectory().getFile();
if (listener != null) {
listener.apply(new Informer<FileDistributionListener>() {
@Override
public void inform(FileDistributionListener listener) {
safeDist.setValue(listener.start(file, safe));
}
});
}
final FileDistributionHandler distributionHandler = fileDistribution.getHandler();
// When cancel is called.. stop processing.
int fileCount = 0;
while (!cancel) {
try {
final FileDistributionHandler.Result result = distributionHandler.sendNextFile();