ScheduleManager优化
This commit is contained in:
@@ -19,7 +19,7 @@ import org.redkale.util.Utility;
|
|||||||
*
|
*
|
||||||
* @since 2.8.0
|
* @since 2.8.0
|
||||||
*/
|
*/
|
||||||
public class ScheduleEvent {
|
public final class ScheduleEvent {
|
||||||
|
|
||||||
private final Map<String, Object> map;
|
private final Map<String, Object> map;
|
||||||
|
|
||||||
@@ -71,6 +71,6 @@ public class ScheduleEvent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return JsonConvert.root().convertTo(this);
|
return JsonConvert.root().convertTo(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ public class ScheduleManagerService implements ScheduleManager, Service {
|
|||||||
}
|
}
|
||||||
methodKeys.add(mk);
|
methodKeys.add(mk);
|
||||||
if (method.getParameterCount() != 0
|
if (method.getParameterCount() != 0
|
||||||
&& (method.getParameterCount() == 1 && method.getParameterTypes()[0] == ScheduleEvent.class)) {
|
&& !(method.getParameterCount() == 1 && method.getParameterTypes()[0] == ScheduleEvent.class)) {
|
||||||
throw new RedkaleException("@" + Scheduled.class.getSimpleName() + " must be on non-parameter or "
|
throw new RedkaleException("@" + Scheduled.class.getSimpleName() + " must be on non-parameter or "
|
||||||
+ ScheduleEvent.class.getSimpleName() + "-parameter method, but on " + method);
|
+ ScheduleEvent.class.getSimpleName() + "-parameter method, but on " + method);
|
||||||
}
|
}
|
||||||
@@ -247,12 +247,15 @@ public class ScheduleManagerService implements ScheduleManager, Service {
|
|||||||
if (event == null) {
|
if (event == null) {
|
||||||
rs = mh.invoke(obj);
|
rs = mh.invoke(obj);
|
||||||
} else {
|
} else {
|
||||||
rs = mh.invoke(obj, event.clear());
|
rs = mh.invoke(obj, event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
logger.log(Level.SEVERE, "schedule task error", t);
|
logger.log(Level.SEVERE, "schedule task error", t);
|
||||||
}
|
}
|
||||||
|
if (event != null) {
|
||||||
|
event.clear();
|
||||||
|
}
|
||||||
return rs;
|
return rs;
|
||||||
};
|
};
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user