From cfa7216facedfb2b3ef5a0886451ce9b52615800 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 13 Oct 2009 21:52:44 +0000 Subject: [PATCH] deprecated scheduling support for JDK 1.3 Timer --- .../SimpleApplicationEventMulticaster.java | 1 - .../ScheduledExecutorFactoryBean.java | 4 ---- .../concurrent/ScheduledExecutorTask.java | 6 +----- .../support/MethodInvokingRunnable.java | 14 +------------- .../scheduling/timer/DelegatingTimerTask.java | 5 ++++- .../MethodInvokingTimerTaskFactoryBean.java | 3 +++ .../scheduling/timer/ScheduledTimerTask.java | 5 ++++- .../scheduling/timer/TimerFactoryBean.java | 3 +++ .../scheduling/timer/TimerTaskExecutor.java | 3 +++ .../core/task/SimpleAsyncTaskExecutor.java | 3 +-- .../core/task/SyncTaskExecutor.java | 17 ++++++++--------- 11 files changed, 28 insertions(+), 36 deletions(-) diff --git a/org.springframework.context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java b/org.springframework.context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java index 1ca1235db1..d84d0d17b0 100644 --- a/org.springframework.context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java +++ b/org.springframework.context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java @@ -68,7 +68,6 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM * transaction association) unless the TaskExecutor explicitly supports this. * @see org.springframework.core.task.SyncTaskExecutor * @see org.springframework.core.task.SimpleAsyncTaskExecutor - * @see org.springframework.scheduling.timer.TimerTaskExecutor */ public void setTaskExecutor(Executor taskExecutor) { this.taskExecutor = taskExecutor; diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java index 8b152235f8..61915d2c76 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBean.java @@ -52,10 +52,6 @@ import org.springframework.util.ObjectUtils; * {@link #setContinueScheduledExecutionAfterException "continueScheduledExecutionAfterException"} * property to "true". * - *

This class is analogous to the - * {@link org.springframework.scheduling.timer.TimerFactoryBean} - * class for the JDK 1.3 {@link java.util.Timer} facility. - * * @author Juergen Hoeller * @since 2.0 * @see #setPoolSize diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorTask.java b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorTask.java index 756019ede6..a0a658a05d 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorTask.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/concurrent/ScheduledExecutorTask.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,14 +31,10 @@ import java.util.concurrent.TimeUnit; * uses a {@link Runnable} instance that is shared between repeated executions, * in contrast to Quartz which creates a new Job instance for each execution. * - *

This class is analogous to the {@link org.springframework.scheduling.timer.ScheduledTimerTask} - * class for the JDK 1.3 {@link java.util.Timer} facility. - * * @author Juergen Hoeller * @since 2.0 * @see java.util.concurrent.ScheduledExecutorService#scheduleWithFixedDelay(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit) * @see java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate(java.lang.Runnable, long, long, java.util.concurrent.TimeUnit) - * @see org.springframework.scheduling.timer.ScheduledTimerTask */ public class ScheduledExecutorTask { diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/support/MethodInvokingRunnable.java b/org.springframework.context/src/main/java/org/springframework/scheduling/support/MethodInvokingRunnable.java index 18f77798b9..142b832e3c 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/support/MethodInvokingRunnable.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/support/MethodInvokingRunnable.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,18 +33,6 @@ import org.springframework.util.ClassUtils; *

Inherits common configuration properties from * {@link org.springframework.util.MethodInvoker}. * - *

Useful to generically encapsulate a method invocation as timer task - * for java.util.Timer, in combination with a - * {@link org.springframework.scheduling.timer.DelegatingTimerTask} adapter. - * Can also be used with JDK 1.5's java.util.concurrent.Executor - * abstraction, which works with plain Runnables. - * - *

Extended by Spring's - * {@link org.springframework.scheduling.timer.MethodInvokingTimerTaskFactoryBean} - * adapter for java.util.TimerTask. Note that you can populate a - * ScheduledTimerTask object with a plain MethodInvokingRunnable instance - * as well, which will automatically get wrapped with a DelegatingTimerTask. - * * @author Juergen Hoeller * @since 1.2.4 * @see org.springframework.scheduling.timer.ScheduledTimerTask#setRunnable(Runnable) diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/DelegatingTimerTask.java b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/DelegatingTimerTask.java index ba8d365d1d..68880c1796 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/DelegatingTimerTask.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/DelegatingTimerTask.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,10 @@ import org.springframework.util.Assert; * * @author Juergen Hoeller * @since 1.2.4 + * @deprecated as of Spring 3.0, in favor of the scheduling.concurrent + * package which is based on Java 5's java.util.concurrent.ExecutorService */ +@Deprecated public class DelegatingTimerTask extends TimerTask { private static final Log logger = LogFactory.getLog(DelegatingTimerTask.class); diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/MethodInvokingTimerTaskFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/MethodInvokingTimerTaskFactoryBean.java index 98513a281e..f387a0e704 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/MethodInvokingTimerTaskFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/MethodInvokingTimerTaskFactoryBean.java @@ -37,7 +37,10 @@ import org.springframework.scheduling.support.MethodInvokingRunnable; * @see ScheduledTimerTask#setRunnable * @see org.springframework.scheduling.support.MethodInvokingRunnable * @see org.springframework.beans.factory.config.MethodInvokingFactoryBean + * @deprecated as of Spring 3.0, in favor of the scheduling.concurrent + * package which is based on Java 5's java.util.concurrent.ExecutorService */ +@Deprecated public class MethodInvokingTimerTaskFactoryBean extends MethodInvokingRunnable implements FactoryBean { private TimerTask timerTask; diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/ScheduledTimerTask.java b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/ScheduledTimerTask.java index d043fbba1f..05b68a4acf 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/ScheduledTimerTask.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/ScheduledTimerTask.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,10 @@ import java.util.TimerTask; * @see java.util.TimerTask * @see java.util.Timer#schedule(TimerTask, long, long) * @see java.util.Timer#scheduleAtFixedRate(TimerTask, long, long) + * @deprecated as of Spring 3.0, in favor of the scheduling.concurrent + * package which is based on Java 5's java.util.concurrent.ExecutorService */ +@Deprecated public class ScheduledTimerTask { private TimerTask timerTask; diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerFactoryBean.java b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerFactoryBean.java index 6fed79af6b..38c4f8c23a 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerFactoryBean.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerFactoryBean.java @@ -46,7 +46,10 @@ import org.springframework.util.StringUtils; * @see ScheduledTimerTask * @see java.util.Timer * @see java.util.TimerTask + * @deprecated as of Spring 3.0, in favor of the scheduling.concurrent + * package which is based on Java 5's java.util.concurrent.ExecutorService */ +@Deprecated public class TimerFactoryBean implements FactoryBean, BeanNameAware, InitializingBean, DisposableBean { protected final Log logger = LogFactory.getLog(getClass()); diff --git a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerTaskExecutor.java b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerTaskExecutor.java index 21bf1d382f..9603e95c3d 100644 --- a/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerTaskExecutor.java +++ b/org.springframework.context/src/main/java/org/springframework/scheduling/timer/TimerTaskExecutor.java @@ -39,7 +39,10 @@ import org.springframework.util.StringUtils; * @author Juergen Hoeller * @since 2.0 * @see java.util.Timer + * @deprecated as of Spring 3.0, in favor of the scheduling.concurrent + * package which is based on Java 5's java.util.concurrent.ExecutorService */ +@Deprecated public class TimerTaskExecutor implements SchedulingTaskExecutor, BeanNameAware, InitializingBean, DisposableBean { protected final Log logger = LogFactory.getLog(getClass()); diff --git a/org.springframework.core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java b/org.springframework.core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java index 56ded1323d..e92efb8ca3 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java +++ b/org.springframework.core/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java @@ -27,7 +27,7 @@ import org.springframework.util.ConcurrencyThrottleSupport; import org.springframework.util.CustomizableThreadCreator; /** - * TaskExecutor implementation that fires up a new Thread for each task, + * {@link TaskExecutor} implementation that fires up a new Thread for each task, * executing it asynchronously. * *

Supports limiting concurrent threads through the "concurrencyLimit" @@ -41,7 +41,6 @@ import org.springframework.util.CustomizableThreadCreator; * @since 2.0 * @see #setConcurrencyLimit * @see SyncTaskExecutor - * @see org.springframework.scheduling.timer.TimerTaskExecutor * @see org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor * @see org.springframework.scheduling.commonj.WorkManagerTaskExecutor */ diff --git a/org.springframework.core/src/main/java/org/springframework/core/task/SyncTaskExecutor.java b/org.springframework.core/src/main/java/org/springframework/core/task/SyncTaskExecutor.java index 857edf1f44..4830730c75 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/task/SyncTaskExecutor.java +++ b/org.springframework.core/src/main/java/org/springframework/core/task/SyncTaskExecutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2006 the original author or authors. + * Copyright 2002-2009 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,16 +16,16 @@ package org.springframework.core.task; -import org.springframework.util.Assert; - import java.io.Serializable; +import org.springframework.util.Assert; + /** - * TaskExecutor implementation that executes each task - * synchronously in the calling thread. - * + * {@link TaskExecutor} implementation that executes each task synchronously + * in the calling thread. + * *

Mainly intended for testing scenarios. - * + * *

Execution in the calling thread does have the advantage of participating * in it's thread context, for example the thread context class loader or the * thread's current transaction association. That said, in many cases, @@ -33,9 +33,8 @@ import java.io.Serializable; * TaskExecutor instead for such scenarios. * * @author Juergen Hoeller - * @see SimpleAsyncTaskExecutor - * @see org.springframework.scheduling.timer.TimerTaskExecutor * @since 2.0 + * @see SimpleAsyncTaskExecutor */ public class SyncTaskExecutor implements TaskExecutor, Serializable {