ScheduledBean, ScheduledServiceBean 추가

master
mjkhan21 1 year ago
parent c9b0a62375
commit cda6994f99

@ -0,0 +1,31 @@
package cokr.xit.foundation.component;
/** Bean.
* {@link ScheduledServiceBean} .
* @author mjkhan
*/
public abstract class ScheduledBean extends ManagedComponent {
private boolean busy;
/** Bean .<br />
* {@link ScheduledServiceBean} .
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public boolean isBusy() {
return busy;
}
/** Bean .<br />
* {@link ScheduledServiceBean} .
* @param busy
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public void setBusy(boolean busy) {
this.busy = busy;
}
}

@ -0,0 +1,40 @@
package cokr.xit.foundation.component;
import java.util.function.Supplier;
/** .
* quartz .
* @author mjkhan
*/
public class ScheduledServiceBean extends AbstractServiceBean {
/** . scheduled .
* @param scheduled Bean
* @param task Bean
*/
protected void execute(ScheduledBean scheduled, Runnable task) {
if (scheduled.isBusy()) return;
scheduled.setBusy(true);
try {
task.run();
} finally {
scheduled.setBusy(false);
}
}
/** . scheduled null .
* @param scheduled Bean
* @param task Bean
* @return
*/
protected <T> T execute(ScheduledBean scheduled, Supplier<T> task) {
if (scheduled.isBusy()) return null;
scheduled.setBusy(true);
try {
return task.get();
} finally {
scheduled.setBusy(false);
}
}
}
Loading…
Cancel
Save