shz.spring.cron.DefaultCronDelayQueue Maven / Gradle / Ivy
package shz.spring.cron;
import shz.core.AccessibleHelp;
import shz.core.NullHelp;
import shz.spring.BeanContainer;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class DefaultCronDelayQueue extends CronDelayQueue {
public static final class DefaultCronEntry extends CronDelayQueue.CronDelayEntry {
private static final long serialVersionUID = -5481521284803678113L;
private final String id;
private final Class> cls;
private final String methodName;
private transient Object receiver;
public DefaultCronEntry(String expression, String id, Class> cls, String methodName) {
super(expression);
this.id = NullHelp.isBlank(id) ? null : id;
this.cls = cls;
this.methodName = methodName;
receiver = BeanContainer.get(cls, () -> AccessibleHelp.newInstance(cls));
}
public DefaultCronEntry(String expression, Class> cls, String methodName) {
this(expression, null, cls, methodName);
}
@Override
public String getId() {
return id;
}
@Override
protected void action0() {
AccessibleHelp.invoke(receiver, methodName);
}
@Override
protected void writeObject(ObjectOutputStream oos) throws IOException {
super.writeObject(oos);
}
@Override
protected void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
super.readObject(ois);
receiver = BeanContainer.get(cls, () -> AccessibleHelp.newInstance(cls));
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy