org.ioc.commons.flowcontrol.operationmanager.impl.HasLoaderOperationHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ioc-commons-ext Show documentation
Show all versions of ioc-commons-ext Show documentation
Library which contains some extension classes for the library IOC-Commons.
It provides some interface definitions and some tool classes which are non-dependent from the used technology;
i.e. the classes and interfaces from this library do not depend on the choosen ioc-commons-implementation library.
package org.ioc.commons.flowcontrol.operationmanager.impl;
import org.ioc.commons.flowcontrol.operationmanager.IsOperation;
import org.ioc.commons.flowcontrol.operationmanager.OperationHandler;
import org.ioc.commons.ui.HasLoader;
import org.ioc.commons.utils.FormatterLogger;
/**
* It wraps an operation handler from some HasLoaders.
*
* Instanciated from {@link OperationHandlerFactory}
*
* @author Jesús Lunar Pérez
*
* @param
* Operation type
*/
public class HasLoaderOperationHandler & IsOperation> implements OperationHandler {
private static final FormatterLogger logger = FormatterLogger.getLogger(HasLoaderOperationHandler.class);
private HasLoader[] loaders;
private boolean logWhenNull;
HasLoaderOperationHandler(boolean logWhenNull, HasLoader... loaders) {
this.loaders = loaders;
this.logWhenNull = logWhenNull;
}
@Override
public void onOperationBeginning(Object sender, O operation) {
if (this.loaders != null) {
for (HasLoader loader : loaders) {
if (loader != null) {
loader.setLoading(true);
} else if (logWhenNull) {
logger.warn("Ignoring null loader component assigned");
}
}
}
}
@Override
public void onOperationFinished(Object sender, O operation, boolean success) {
if (this.loaders != null) {
for (HasLoader loader : loaders) {
if (loader != null) {
loader.setLoading(false);
} else if (logWhenNull) {
logger.warn("Ignoring null loader component assigned");
}
}
}
}
}