You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lh...@apache.org on 2010/02/23 18:16:02 UTC
svn commit: r915442 - in
/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent:
SubjectAwareExecutorService.java SubjectAwareScheduledExecutorService.java
Author: lhazlewood
Date: Tue Feb 23 17:16:02 2010
New Revision: 915442
URL: http://svn.apache.org/viewvc?rev=915442&view=rev
Log:
SHIRO-140: overrode parent classes setter methods to ensure that only a required target instance could be set.
Modified:
incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutorService.java
incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareScheduledExecutorService.java
Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutorService.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutorService.java?rev=915442&r1=915441&r2=915442&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutorService.java (original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareExecutorService.java Tue Feb 23 17:16:02 2010
@@ -72,10 +72,20 @@
}
public void setTargetExecutorService(ExecutorService targetExecutorService) {
- setTargetExecutor(targetExecutorService);
+ super.setTargetExecutor(targetExecutorService);
this.targetExecutorService = targetExecutorService;
}
+ @Override
+ public void setTargetExecutor(Executor targetExecutor) {
+ if (!(targetExecutor instanceof ExecutorService)) {
+ String msg = "The " + getClass().getName() + " implementation only accepts " +
+ ExecutorService.class.getName() + " target instances.";
+ throw new IllegalArgumentException(msg);
+ }
+ super.setTargetExecutor(targetExecutor);
+ }
+
public void shutdown() {
this.targetExecutorService.shutdown();
}
Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareScheduledExecutorService.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareScheduledExecutorService.java?rev=915442&r1=915441&r2=915442&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareScheduledExecutorService.java (original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/concurrent/SubjectAwareScheduledExecutorService.java Tue Feb 23 17:16:02 2010
@@ -18,10 +18,7 @@
*/
package org.apache.shiro.concurrent;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
/**
* Same concept as the {@link SubjectAwareExecutorService} but additionally supports the
@@ -43,8 +40,28 @@
}
public void setTargetScheduledExecutorService(ScheduledExecutorService targetScheduledExecutorService) {
+ super.setTargetExecutorService(targetScheduledExecutorService);
this.targetScheduledExecutorService = targetScheduledExecutorService;
- setTargetExecutorService(targetScheduledExecutorService);
+ }
+
+ @Override
+ public void setTargetExecutor(Executor targetExecutor) {
+ if (!(targetExecutor instanceof ScheduledExecutorService)) {
+ String msg = "The " + getClass().getName() + " implementation only accepts " +
+ ScheduledExecutorService.class.getName() + " target instances.";
+ throw new IllegalArgumentException(msg);
+ }
+ super.setTargetExecutorService((ScheduledExecutorService) targetExecutor);
+ }
+
+ @Override
+ public void setTargetExecutorService(ExecutorService targetExecutorService) {
+ if (!(targetExecutorService instanceof ScheduledExecutorService)) {
+ String msg = "The " + getClass().getName() + " implementation only accepts " +
+ ScheduledExecutorService.class.getName() + " target instances.";
+ throw new IllegalArgumentException(msg);
+ }
+ super.setTargetExecutorService(targetExecutorService);
}
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {