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


Java ScheduledMethodRunnable.getMethod方法代码示例

本文整理汇总了Java中org.springframework.scheduling.support.ScheduledMethodRunnable.getMethod方法的典型用法代码示例。如果您正苦于以下问题:Java ScheduledMethodRunnable.getMethod方法的具体用法?Java ScheduledMethodRunnable.getMethod怎么用?Java ScheduledMethodRunnable.getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.scheduling.support.ScheduledMethodRunnable的用法示例。


在下文中一共展示了ScheduledMethodRunnable.getMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fixedDelayTask

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void fixedDelayTask() {
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(FixedDelayTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();

	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedDelayTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedDelayTasks");
	assertEquals(1, fixedDelayTasks.size());
	IntervalTask task = fixedDelayTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedDelay", targetMethod.getName());
	assertEquals(0L, task.getInitialDelay());
	assertEquals(5000L, task.getInterval());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例2: fixedRateTask

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void fixedRateTask() {
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(FixedRateTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();

	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedRateTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedRateTasks");
	assertEquals(1, fixedRateTasks.size());
	IntervalTask task = fixedRateTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedRate", targetMethod.getName());
	assertEquals(0L, task.getInitialDelay());
	assertEquals(3000L, task.getInterval());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例3: fixedRateTaskWithInitialDelay

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void fixedRateTaskWithInitialDelay() {
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(FixedRateWithInitialDelayTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();

	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedRateTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedRateTasks");
	assertEquals(1, fixedRateTasks.size());
	IntervalTask task = fixedRateTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedRate", targetMethod.getName());
	assertEquals(1000L, task.getInitialDelay());
	assertEquals(3000L, task.getInterval());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例4: metaAnnotationWithFixedRate

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void metaAnnotationWithFixedRate() {
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(MetaAnnotationFixedRateTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();

	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedRateTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedRateTasks");
	assertEquals(1, fixedRateTasks.size());
	IntervalTask task = fixedRateTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("checkForUpdates", targetMethod.getName());
	assertEquals(5000L, task.getInterval());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例5: metaAnnotationWithCronExpression

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void metaAnnotationWithCronExpression() {
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(MetaAnnotationCronTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();

	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<CronTask> cronTasks = (List<CronTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("cronTasks");
	assertEquals(1, cronTasks.size());
	CronTask task = cronTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("generateReport", targetMethod.getName());
	assertEquals("0 0 * * * ?", task.getExpression());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例6: findAnnotation

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
SchedulerLock findAnnotation(ScheduledMethodRunnable task) {
    Method method = task.getMethod();
    SchedulerLock annotation = findAnnotation(method);
    if (annotation != null) {
        return annotation;
    } else {
        // Try to find annotation on proxied class
        Class<?> targetClass = AopUtils.getTargetClass(task.getTarget());
        if (targetClass != null && !task.getTarget().getClass().equals(targetClass)) {
            try {
                Method methodOnTarget = targetClass
                    .getMethod(method.getName(), method.getParameterTypes());
                return findAnnotation(methodOnTarget);
            } catch (NoSuchMethodException e) {
                return null;
            }
        } else {
            return null;
        }
    }
}
 
开发者ID:lukas-krecan,项目名称:ShedLock,代码行数:22,代码来源:SpringLockConfigurationExtractor.java

示例7: fixedDelayTask

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void fixedDelayTask() {
	StaticApplicationContext context = new StaticApplicationContext();
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(FixedDelayTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();
	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedDelayTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedDelayTasks");
	assertEquals(1, fixedDelayTasks.size());
	IntervalTask task = fixedDelayTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedDelay", targetMethod.getName());
	assertEquals(0L, task.getInitialDelay());
	assertEquals(5000L, task.getInterval());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例8: fixedRateTask

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void fixedRateTask() {
	StaticApplicationContext context = new StaticApplicationContext();
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(
			ScheduledAnnotationBeanPostProcessorTests.FixedRateTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();
	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedRateTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedRateTasks");
	assertEquals(1, fixedRateTasks.size());
	IntervalTask task = fixedRateTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedRate", targetMethod.getName());
	assertEquals(0L, task.getInitialDelay());
	assertEquals(3000L, task.getInterval());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:27,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例9: fixedRateTaskWithInitialDelay

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void fixedRateTaskWithInitialDelay() {
	StaticApplicationContext context = new StaticApplicationContext();
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(FixedRateWithInitialDelayTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();
	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedRateTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedRateTasks");
	assertEquals(1, fixedRateTasks.size());
	IntervalTask task = fixedRateTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedRate", targetMethod.getName());
	assertEquals(1000L, task.getInitialDelay());
	assertEquals(3000L, task.getInterval());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例10: metaAnnotationWithFixedRate

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void metaAnnotationWithFixedRate() {
	StaticApplicationContext context = new StaticApplicationContext();
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(MetaAnnotationFixedRateTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();
	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedRateTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedRateTasks");
	assertEquals(1, fixedRateTasks.size());
	IntervalTask task = fixedRateTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("checkForUpdates", targetMethod.getName());
	assertEquals(5000L, task.getInterval());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例11: metaAnnotationWithCronExpression

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void metaAnnotationWithCronExpression() {
	StaticApplicationContext context = new StaticApplicationContext();
	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(
			ScheduledAnnotationBeanPostProcessorTests.MetaAnnotationCronTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();
	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<CronTask> cronTasks = (List<CronTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("cronTasks");
	assertEquals(1, cronTasks.size());
	CronTask task = cronTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("generateReport", targetMethod.getName());
	assertEquals("0 0 * * * ?", task.getExpression());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例12: assertScheduledTask

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
private void assertScheduledTask(String taskType, Object targetObject, String methodName, Object time) {
    Map<Runnable, String> fixedDelayTasks = (Map<Runnable, String>) ReflectionUtil.getField(scheduledTaskRegistrar, taskType);
    boolean matchFound = false;
    for (Runnable runnable : fixedDelayTasks.keySet()) {
        if (runnable instanceof ScheduledMethodRunnable) {
            ScheduledMethodRunnable scheduledMethodRunnable = (ScheduledMethodRunnable) runnable;
            Object target = scheduledMethodRunnable.getTarget();
            if (target.equals(targetObject)) {
                matchFound = true;
                Method method = scheduledMethodRunnable.getMethod();
                assertThat(method.getName(), Is.is(methodName));
                assertThat(fixedDelayTasks.get(runnable), is(time));
            }
        }
    }
    assertThat("Could not find a scheduled job for configRepositoryGCWarningService.checkRepoAndAddWarningIfRequired", matchFound, Is.is(true));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:18,代码来源:ScheduledTasksIntegrationTest.java

示例13: findRunnableKey

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
public String findRunnableKey(Runnable runnable) {
    logger.info("findRunnableKey : {}", runnable);

    if (runnable instanceof ScheduledMethodRunnable) {
        ScheduledMethodRunnable scheduledMethodRunnable = (ScheduledMethodRunnable) runnable;
        Method method = scheduledMethodRunnable.getMethod();
        Class clz = method.getDeclaringClass();

        logger.info("{}.{}", clz.getCanonicalName(), method.getName());

        return clz.getCanonicalName() + "." + method.getName();
    } else {
        return runnable.toString();
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:16,代码来源:ProxyTaskScheduler.java

示例14: severalFixedRates

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
private void severalFixedRates(StaticApplicationContext context,
		BeanDefinition processorDefinition, BeanDefinition targetDefinition) {

	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();

	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<IntervalTask> fixedRateTasks = (List<IntervalTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("fixedRateTasks");
	assertEquals(2, fixedRateTasks.size());
	IntervalTask task1 = fixedRateTasks.get(0);
	ScheduledMethodRunnable runnable1 = (ScheduledMethodRunnable) task1.getRunnable();
	Object targetObject = runnable1.getTarget();
	Method targetMethod = runnable1.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedRate", targetMethod.getName());
	assertEquals(0, task1.getInitialDelay());
	assertEquals(4000L, task1.getInterval());
	IntervalTask task2 = fixedRateTasks.get(1);
	ScheduledMethodRunnable runnable2 = (ScheduledMethodRunnable) task2.getRunnable();
	targetObject = runnable2.getTarget();
	targetMethod = runnable2.getMethod();
	assertEquals(target, targetObject);
	assertEquals("fixedRate", targetMethod.getName());
	assertEquals(2000L, task2.getInitialDelay());
	assertEquals(4000L, task2.getInterval());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:33,代码来源:ScheduledAnnotationBeanPostProcessorTests.java

示例15: cronTask

import org.springframework.scheduling.support.ScheduledMethodRunnable; //导入方法依赖的package包/类
@Test
public void cronTask() throws InterruptedException {
	Assume.group(TestGroup.LONG_RUNNING);

	BeanDefinition processorDefinition = new RootBeanDefinition(ScheduledAnnotationBeanPostProcessor.class);
	BeanDefinition targetDefinition = new RootBeanDefinition(CronTestBean.class);
	context.registerBeanDefinition("postProcessor", processorDefinition);
	context.registerBeanDefinition("target", targetDefinition);
	context.refresh();

	Object postProcessor = context.getBean("postProcessor");
	Object target = context.getBean("target");
	ScheduledTaskRegistrar registrar = (ScheduledTaskRegistrar)
			new DirectFieldAccessor(postProcessor).getPropertyValue("registrar");
	@SuppressWarnings("unchecked")
	List<CronTask> cronTasks = (List<CronTask>)
			new DirectFieldAccessor(registrar).getPropertyValue("cronTasks");
	assertEquals(1, cronTasks.size());
	CronTask task = cronTasks.get(0);
	ScheduledMethodRunnable runnable = (ScheduledMethodRunnable) task.getRunnable();
	Object targetObject = runnable.getTarget();
	Method targetMethod = runnable.getMethod();
	assertEquals(target, targetObject);
	assertEquals("cron", targetMethod.getName());
	assertEquals("*/7 * * * * ?", task.getExpression());
	Thread.sleep(10000);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:ScheduledAnnotationBeanPostProcessorTests.java


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