我已经从使用 gwt rpc 切换到为所有内容请求工厂,主要是因为我现在可以将任何对象传输到客户端,而无需修改第三方类来实现可序列化。您不必有一个定位器,您可以简单地使用带有静态方法的实现。如果您不希望使它们成为静态,您可以简单地在您的服务器包中实现ServiceLocator并将 locator=WhateverYourServiceIs.class 添加到 @Service 注释
这是我用于从服务器访问石英调度程序对象的版本。
客户代码
@Service(value = SchedulerService.class)
public interface SchedulerRequest extends RequestContext {
Request<List<QuartzTriggerProxy>> getScheduledJobs();
Request<List<QuartzTriggerProxy>> searchSchedules(String searchString);
Request<Void> unscheduleJob(String keyName, String groupName);
Request<Void> pauseTrigger(QuartzTriggerKeyProxy triggerKey);
Request<Void> resumeTrigger(QuartzTriggerKeyProxy triggerKey);
Request<QuartzTriggerProxy> getTrigger(String keyName, String groupName);
Request<Void> fireTriggerNow(QuartzTriggerKeyProxy triggerKey);
Request<Void> fireJobNow(QuartzJobKeyProxy jobKey);
Request<Date> rescheduleJob(QuartzTriggerKeyProxy triggerKey, QuartzTriggerProxy trigger);
Request<AnalyticsTaskProxy> getTaskForTrigger(QuartzJobKeyProxy jobKey);
Request<String> getTriggerState(QuartzTriggerKeyProxy triggerKey);
}
服务代码
public class SchedulerService {
public static void pauseTrigger(TriggerKey triggerKey) throws AnalyticsTaskException, SchedulerException {
getTaskEngine().pauseTrigger(triggerKey);
}
public static void resumeTrigger(TriggerKey triggerKey) throws AnalyticsTaskException, SchedulerException {
getTaskEngine().resumeTrigger(triggerKey);
}
public static Trigger getTrigger(String keyName, String groupName) throws AnalyticsTaskException, SchedulerException {
return getTaskEngine().getTrigger(TriggerKey.triggerKey(keyName, groupName));
}
public static void fireTriggerNow(TriggerKey triggerKey) throws AnalyticsTaskException, SchedulerException {
getTaskEngine().fireTriggerNow(triggerKey);
}
public static void fireJobNow(JobKey jobKey) throws AnalyticsTaskException, SchedulerException {
getTaskEngine().fireJobNow(jobKey);
}
}