![JAR search and dependency download from the Maven repository](/logo.png)
de.tsl2.nano.execution.VolatileResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tsl2.nano.common Show documentation
Show all versions of tsl2.nano.common Show documentation
TSL2 Framework Commons (Collections, Actions/Excecution, Readers, Xml, Print, Mail, FuzzyFinder, Proxies, Network-Structure)
The newest version!
/*
* File: $HeadURL$
* Id : $Id$
*
* created by: Tom
* created on: 16.07.2016
*
* Copyright: (c) Thomas Schneider 2016, all rights reserved
*/
package de.tsl2.nano.execution;
import java.io.Serializable;
import java.util.Map;
import de.tsl2.nano.core.ManagedException;
import de.tsl2.nano.historize.Volatile;
/**
* A Runner (see {@link IPRunnable}) that checks, if it is already running - or (see {@link Volatile} the result already
* expired.
*
* @author Tom
* @version $Revision$
*/
public class VolatileResult extends Volatile {
IPRunnable> runner;
boolean isRunning;
public VolatileResult(long period, IPRunnable> runner) {
super(period, null);
this.runner = runner;
}
public T get(Map context, Object... extArgs) {
return get(runner, context, extArgs);
}
public T get(IPRunnable> runner, Map context, Object... extArgs) {
if (expired() && !isRunning)
try {
set(runner.run(context, extArgs));
} catch(Exception ex) {
//on errors , the expired should be set, too
activate();
ManagedException.forward(ex);
} finally {
isRunning = false;
}
return get();
}
public String getName() {
return runner.getName();
}
public Map getParameter() {
return runner.getParameter();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy