本文整理汇总了Java中org.quartz.SchedulerContext.get方法的典型用法代码示例。如果您正苦于以下问题:Java SchedulerContext.get方法的具体用法?Java SchedulerContext.get怎么用?Java SchedulerContext.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.SchedulerContext
的用法示例。
在下文中一共展示了SchedulerContext.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
LOG.debug("Running ScheduledJob: jobExecutionContext={}", jobExecutionContext);
SchedulerContext schedulerContext = getSchedulerContext(jobExecutionContext);
ScheduledJobState state = (ScheduledJobState) schedulerContext.get(jobExecutionContext.getJobDetail().getKey().toString());
Action storedAction = state.getAction();
Route storedRoute = state.getRoute();
List<RoutePolicy> policyList = storedRoute.getRouteContext().getRoutePolicyList();
for (RoutePolicy policy : policyList) {
try {
if (policy instanceof ScheduledRoutePolicy) {
((ScheduledRoutePolicy)policy).onJobExecute(storedAction, storedRoute);
}
} catch (Exception e) {
throw new JobExecutionException("Failed to execute Scheduled Job for route " + storedRoute.getId()
+ " with trigger name: " + jobExecutionContext.getTrigger().getKey(), e);
}
}
}
示例2: executeInternal
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
protected void executeInternal(JobExecutionContext context)throws JobExecutionException {
try {
SchedulerContext schCtx = context.getScheduler().getContext();
JobDataMap jdm=context.getJobDetail().getJobDataMap();
//获取Spring中的上下文
ApplicationContext appCtx = (ApplicationContext)schCtx.get("applicationContext");
this.cmsSiteMng= (CmsSiteMng)appCtx.getBean("cmsSiteMng");
this.staticPageSvc= (StaticPageSvc)appCtx.getBean("staticPageSvc");
this.sessionFactory=(SessionFactory) appCtx.getBean("sessionFactory");
this.siteId=Integer.parseInt((String) jdm.get(CmsTask.TASK_PARAM_SITE_ID));
} catch (SchedulerException e1) {
// TODO 尚未处理异常
e1.printStackTrace();
}
staticIndex();
}
示例3: execute
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
String camelContextName = (String) context.getJobDetail().getJobDataMap().get(QuartzConstants.QUARTZ_CAMEL_CONTEXT_NAME);
String endpointUri = (String) context.getJobDetail().getJobDataMap().get(QuartzConstants.QUARTZ_ENDPOINT_URI);
SchedulerContext schedulerContext;
try {
schedulerContext = context.getScheduler().getContext();
} catch (SchedulerException e) {
throw new JobExecutionException("Failed to obtain scheduler context for job " + context.getJobDetail().getName());
}
CamelContext camelContext = (CamelContext) schedulerContext.get(QuartzConstants.QUARTZ_CAMEL_CONTEXT + "-" + camelContextName);
if (camelContext == null) {
throw new JobExecutionException("No CamelContext could be found with name: " + camelContextName);
}
Trigger trigger = context.getTrigger();
QuartzEndpoint endpoint = lookupQuartzEndpoint(camelContext, endpointUri, trigger);
if (endpoint == null) {
throw new JobExecutionException("No QuartzEndpoint could be found with endpointUri: " + endpointUri);
}
endpoint.onJobExecute(context);
}
示例4: executeInternal
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
protected void executeInternal(JobExecutionContext context)throws JobExecutionException {
try {
SchedulerContext schCtx = context.getScheduler().getContext();
//获取Spring中的上下文
ApplicationContext appCtx = (ApplicationContext)schCtx.get("applicationContext");
this.staticPageSvc= (StaticPageSvc)appCtx.getBean("staticPageSvc");
JobDataMap jdm=context.getJobDetail().getJobDataMap();
//获取栏目
String channelIdStr=(String) jdm.get(CmsTask.TASK_PARAM_CHANNEL_ID);
if(!StringUtils.isBlank(channelIdStr)){
this.channelId=Integer.parseInt(channelIdStr);
if(channelId.equals(0)){
channelId=null;
}
}
//获取站点
String siteIdStr=(String) jdm.get(CmsTask.TASK_PARAM_SITE_ID);
if(!StringUtils.isBlank(siteIdStr)){
this.siteId=Integer.parseInt(siteIdStr);
}
} catch (SchedulerException e1) {
// TODO 尚未处理异常
e1.printStackTrace();
}
staitcChannel();
}
示例5: execute
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
SchedulerContext schedulerContext = null;
try {
schedulerContext = jobExecutionContext.getScheduler().getContext();
} catch (SchedulerException e1) {
log.debug("Exception occurred while getting scheduler context", e1);
}
if (schedulerContext == null) {
log.error("Scheduler context is null");
return;
}
PollingServerConnector connector = (PollingServerConnector) schedulerContext.get("connector");
// Run the poll cycles
log.debug("Executing the polling task for server connector ID: " + connector.getId());
try {
connector.poll();
} catch (Exception e) {
log.error("Error executing the polling cycle for server connector ID: " + connector.getId(), e);
}
log.debug("Exit the polling task running loop for server connector ID: " + connector.getId());
}
示例6: getApplicationContext
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
/**
* Obtains Spring's application context.
*
* @param context job execution context
* @return application context
* @throws SchedulerException
*/
protected ApplicationContext getApplicationContext(JobExecutionContext context)
throws SchedulerException {
final SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
// show keys in context
if(applicationContext==null) {
logger.error(APPLICATION_CONTEXT_KEY+" is empty in "+ schedulerContext+":");
if(schedulerContext.getKeys()!=null) {
for (String key : schedulerContext.getKeys()) {
Object value = schedulerContext.get(key);
String valueText = value!=null ? value.toString() : "<NULL>";
logger.info(" {} = {}", key, valueText);
}
}
}
return applicationContext;
}
示例7: execute
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
public void execute(JobExecutionContext context) throws JobExecutionException {
SchedulerContext schedulerContext = null;
Connection db = null;
try {
schedulerContext = context.getScheduler().getContext();
ApplicationPrefs prefs = (ApplicationPrefs) schedulerContext.get(
"ApplicationPrefs");
String fs = System.getProperty("file.separator");
db = SchedulerUtils.getConnection(schedulerContext);
LOG.debug("Checking temporary files...");
FileItemList tempFiles = new FileItemList();
tempFiles.setLinkModuleId(Constants.TEMP_FILES);
tempFiles.setAlertRangeEnd(new Timestamp(System.currentTimeMillis() - (60L * 60L * 1000L)));
tempFiles.buildList(db);
tempFiles.delete(db,
prefs.get("FILELIBRARY") + "1" + fs + "projects" + fs);
} catch (Exception e) {
LOG.error("CleanupTempFilesJob Exception", e);
throw new JobExecutionException(e.getMessage());
} finally {
SchedulerUtils.freeConnection(schedulerContext, db);
}
}
示例8: getService
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
protected Object getService(JobExecutionContext context, String serviceName) throws JobExecutionException {
try {
SchedulerContext sc = context.getScheduler().getContext();
ApplicationContext cxt = (ApplicationContext) sc.get(MonitoringJob.CONTEXT_NAME);
return cxt.getBean(serviceName);
} catch (SchedulerException e) {
throw new JobExecutionException("Failed look up the " + serviceName + " " + e.toString());
}
}
示例9: action
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
@Override
public void action(JobExecutionContext context) {
try {
long start = System.currentTimeMillis();
SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
// 应用相关
InspectHandler inspectHandler;
JobDataMap jobDataMap = context.getMergedJobDataMap();
String inspectorType = MapUtils.getString(jobDataMap, "inspectorType");
if (StringUtils.isBlank(inspectorType)) {
logger.error("=====================InspectorJob:inspectorType is null=====================");
return;
} else if (inspectorType.equals("host")) {
inspectHandler = applicationContext.getBean("hostInspectHandler", InspectHandler.class);
} else if (inspectorType.equals("app")) {
inspectHandler = applicationContext.getBean("appInspectHandler", InspectHandler.class);
} else {
logger.error("=====================InspectorJob:inspectorType not match:{}=====================", inspectorType);
return;
}
inspectHandler.handle();
long end = System.currentTimeMillis();
logger.info("=====================InspectorJob {} Done! cost={} ms=====================",
inspectHandler.getClass().getSimpleName(), (end - start));
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new RuntimeException(e);
}
}
示例10: action
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
@Override
public void action(JobExecutionContext context) {
try {
SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
ConfigService configService = applicationContext.getBean("configService", ConfigService.class);
configService.reloadSystemConfig();
} catch (SchedulerException e) {
logger.error(e.getMessage(), e);
}
}
示例11: action
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
@Override
public void action(JobExecutionContext context) {
try {
JobDataMap dataMap = context.getMergedJobDataMap();
String ip = dataMap.getString(ConstUtils.HOST_KEY);
long hostId = dataMap.getLong(ConstUtils.HOST_ID_KEY);
SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
MachineCenter machineCenter = applicationContext.getBean("machineCenter", MachineCenter.class);
machineCenter.asyncMonitorMachineStats(hostId, ip);
} catch (SchedulerException e) {
logger.error(e.getMessage(), e);
}
}
示例12: action
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
@Override
public void action(JobExecutionContext context) {
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
SchedulerContext schedulerContext;
try {
schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
EmailComponent emailComponent = applicationContext.getBean("emailComponent", EmailComponent.class);
ErrorLoggerWatcherMBean errorLoggerWatcher = applicationContext.getBean("errorLoggerWatcher", ErrorLoggerWatcherMBean.class);
// if (errorLoggerWatcher.getTotalErrorCount() == 0L) {
// logger.warn("errorLoggerWatcher.totalErrorCount == 0 -o-");
// return;
// }
String title = "CacheCloud异常统计, 日期:" + dateFormat.format(date) + ";服务器:" + System.getProperty("local.ip") + ";总数:" + errorLoggerWatcher.getTotalErrorCount();
StringBuilder buffer = new StringBuilder();
buffer.append(title + ":<br/>");
for (Map.Entry<String, Long> entry : errorLoggerWatcher.getErrorInfos().entrySet()) {
Long num = entry.getValue();
if (num == 0L) {
continue;
}
String key = entry.getKey();
buffer.append(key + "=" + num + "<br/>");
}
emailComponent.sendMailToAdmin(title, buffer.toString());
//清理异常
errorLoggerWatcher.clear();
} catch (SchedulerException e) {
logger.error(e.getMessage(), e);
}
}
示例13: action
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
@Override
public void action(JobExecutionContext context) {
try {
long startTime = System.currentTimeMillis();
SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
InstanceAlertConfigService instanceAlertConfigService = applicationContext.getBean("instanceAlertConfigService", InstanceAlertConfigService.class);
instanceAlertConfigService.monitorLastMinuteAllInstanceInfo();
logger.info("InstanceAlertValueJob cost time {} ms", (System.currentTimeMillis() - startTime));
} catch (SchedulerException e) {
logger.error(e.getMessage(), e);
}
}
示例14: action
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
@Override
public void action(JobExecutionContext context) {
try {
SchedulerContext schedulerContext = context.getScheduler().getContext();
ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
AppDailyDataCenter appDailyDataCenter = applicationContext.getBean("appDailyDataCenter", AppDailyDataCenter.class);
appDailyDataCenter.sendAppDailyEmail();
} catch (SchedulerException e) {
logger.error(e.getMessage(), e);
}
}
示例15: getCamelContext
import org.quartz.SchedulerContext; //导入方法依赖的package包/类
protected CamelContext getCamelContext(JobExecutionContext context) throws JobExecutionException {
SchedulerContext schedulerContext = getSchedulerContext(context);
String camelContextName = context.getMergedJobDataMap().getString(QuartzConstants.QUARTZ_CAMEL_CONTEXT_NAME);
CamelContext result = (CamelContext)schedulerContext.get(QuartzConstants.QUARTZ_CAMEL_CONTEXT + "-" + camelContextName);
if (result == null) {
throw new JobExecutionException("No CamelContext could be found with name: " + camelContextName);
}
return result;
}