当前位置: 首页>>代码示例>>Java>>正文


Java SchedulerContext类代码示例

本文整理汇总了Java中org.quartz.SchedulerContext的典型用法代码示例。如果您正苦于以下问题:Java SchedulerContext类的具体用法?Java SchedulerContext怎么用?Java SchedulerContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SchedulerContext类属于org.quartz包,在下文中一共展示了SchedulerContext类的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);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:ScheduledJob.java

示例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();
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:17,代码来源:IndexStaticJob.java

示例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);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:CamelJob.java

示例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();
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:27,代码来源:ChannelStaticJob.java

示例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());
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:24,代码来源:PollingJob.java

示例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;
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:28,代码来源:BaseJob.java

示例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);
  }
}
 
开发者ID:Concursive,项目名称:concourseconnect-community,代码行数:24,代码来源:CleanupTempFilesJob.java

示例8: execute

import org.quartz.SchedulerContext; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * @param context
 */
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    this.context = context;
    SchedulerContext schedulerContext = null;
    try {
        log.debug("Executing quartz job");
        schedulerContext = context.getScheduler().getContext();
        initProperties(schedulerContext);

        WebResource.Builder resourceBuilder = getBuilder();
        ClientResponse response = getResponse(resourceBuilder);

        if (response != null) {
            String responseAsString = response.getEntity(String.class);
            final List<Event> events = restSourceHandler
                    .getEvents(responseAsString, responseToHeaders(response.getHeaders()));
            queue.addAll(events);
            urlHandler.updateFilterParameters(getLastEvent(events));
        }

    } catch (Exception e) {
        log.error("Error getting Response: " + e.getMessage());
    }
}
 
开发者ID:Stratio,项目名称:ingestion,代码行数:30,代码来源:RequestJob.java

示例9: 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());
}
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:10,代码来源:MonitoringJob.java

示例10: getContext

import org.quartz.SchedulerContext; //导入依赖的package包/类
/**
 * <p>
 * Returns the <code>SchedulerContext</code> of the <code>Scheduler</code>.
 * </p>
 */
public SchedulerContext getContext() throws SchedulerException {
    try {
        return getRemoteScheduler().getSchedulerContext();
    } catch (RemoteException re) {
        throw invalidateHandleCreateException(
                "Error communicating with remote scheduler.", re);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:RemoteScheduler.java

示例11: initAutomaticScheduler

import org.quartz.SchedulerContext; //导入依赖的package包/类
/**
 * 初始化自动的调度器数据
 *
 * @param scheduler 调度器
 * @param jobBeanFactory JobBean工厂
 */
static void initAutomaticScheduler(Scheduler scheduler, JobBeanFactory jobBeanFactory) {
    try {
        SchedulerContext schedulerContext = scheduler.getContext();
        schedulerContext.put(JOB_BEAN_FACTORY_KEY, jobBeanFactory);
        schedulerContext.put(SCHEDULE_MODE_KEY, ScheduleMode.AUTOMATIC);
    } catch (SchedulerException e) {
        LoggerHelper.error("get schedule context failed.", e);
        throw new NiubiException(e);
    }
}
 
开发者ID:xiaolongzuo,项目名称:niubi-job,代码行数:17,代码来源:JobDataMapManager.java

示例12: initManualScheduler

import org.quartz.SchedulerContext; //导入依赖的package包/类
/**
 * 初始化手动的调度器数据
 *
 * @param scheduler 调度器
 */
static void initManualScheduler(Scheduler scheduler) {
    try {
        SchedulerContext schedulerContext = scheduler.getContext();
        schedulerContext.put(SCHEDULE_MODE_KEY, ScheduleMode.MANUAL);
    } catch (SchedulerException e) {
        LoggerHelper.error("get schedule context failed.", e);
        throw new NiubiException(e);
    }
}
 
开发者ID:xiaolongzuo,项目名称:niubi-job,代码行数:15,代码来源:JobDataMapManager.java

示例13: schedulerFactoryBeanWithApplicationContext

import org.quartz.SchedulerContext; //导入依赖的package包/类
@Test
public void schedulerFactoryBeanWithApplicationContext() throws Exception {
	TestBean tb = new TestBean("tb", 99);
	StaticApplicationContext ac = new StaticApplicationContext();

	final Scheduler scheduler = mock(Scheduler.class);
	SchedulerContext schedulerContext = new SchedulerContext();
	given(scheduler.getContext()).willReturn(schedulerContext);

	SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() {
		@Override
		protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) {
			return scheduler;
		}
	};
	schedulerFactoryBean.setJobFactory(null);
	Map<String, Object> schedulerContextMap = new HashMap<String, Object>();
	schedulerContextMap.put("testBean", tb);
	schedulerFactoryBean.setSchedulerContextAsMap(schedulerContextMap);
	schedulerFactoryBean.setApplicationContext(ac);
	schedulerFactoryBean.setApplicationContextSchedulerContextKey("appCtx");
	try {
		schedulerFactoryBean.afterPropertiesSet();
		schedulerFactoryBean.start();
		Scheduler returnedScheduler = schedulerFactoryBean.getObject();
		assertEquals(tb, returnedScheduler.getContext().get("testBean"));
		assertEquals(ac, returnedScheduler.getContext().get("appCtx"));
	}
	finally {
		schedulerFactoryBean.destroy();
	}

	verify(scheduler).start();
	verify(scheduler).shutdown(false);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:36,代码来源:QuartzSupportTests.java

示例14: 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);
    }
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:31,代码来源:InspectorJob.java

示例15: 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);
    }
    
}
 
开发者ID:sohutv,项目名称:cachecloud,代码行数:13,代码来源:SystemConfigRefreshJob.java


注:本文中的org.quartz.SchedulerContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。