Coverage Report - org.apache.shiro.concurrent.SubjectAwareScheduledExecutorService
 
Classes in this File Line Coverage Branch Coverage Complexity
SubjectAwareScheduledExecutorService
0%
0/27
0%
0/4
1.4
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.shiro.concurrent;
 20  
 
 21  
 import java.util.concurrent.*;
 22  
 
 23  
 /**
 24  
  * Same concept as the {@link SubjectAwareExecutorService} but additionally supports the
 25  
  * {@link ScheduledExecutorService} interface.
 26  
  */
 27  
 public class SubjectAwareScheduledExecutorService extends SubjectAwareExecutorService implements ScheduledExecutorService {
 28  
 
 29  
     private ScheduledExecutorService targetScheduledExecutorService;
 30  
 
 31  0
     public SubjectAwareScheduledExecutorService() {
 32  0
     }
 33  
 
 34  0
     public SubjectAwareScheduledExecutorService(ScheduledExecutorService target) {
 35  0
         setTargetScheduledExecutorService(target);
 36  0
     }
 37  
 
 38  
     public ScheduledExecutorService getTargetScheduledExecutorService() {
 39  0
         return targetScheduledExecutorService;
 40  
     }
 41  
 
 42  
     public void setTargetScheduledExecutorService(ScheduledExecutorService targetScheduledExecutorService) {
 43  0
         super.setTargetExecutorService(targetScheduledExecutorService);
 44  0
         this.targetScheduledExecutorService = targetScheduledExecutorService;
 45  0
     }
 46  
 
 47  
     @Override
 48  
     public void setTargetExecutor(Executor targetExecutor) {
 49  0
         if (!(targetExecutor instanceof ScheduledExecutorService)) {
 50  0
             String msg = "The " + getClass().getName() + " implementation only accepts " +
 51  
                     ScheduledExecutorService.class.getName() + " target instances.";
 52  0
             throw new IllegalArgumentException(msg);
 53  
         }
 54  0
         super.setTargetExecutorService((ScheduledExecutorService) targetExecutor);
 55  0
     }
 56  
 
 57  
     @Override
 58  
     public void setTargetExecutorService(ExecutorService targetExecutorService) {
 59  0
         if (!(targetExecutorService instanceof ScheduledExecutorService)) {
 60  0
             String msg = "The " + getClass().getName() + " implementation only accepts " +
 61  
                     ScheduledExecutorService.class.getName() + " target instances.";
 62  0
             throw new IllegalArgumentException(msg);
 63  
         }
 64  0
         super.setTargetExecutorService(targetExecutorService);
 65  0
     }
 66  
 
 67  
     public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
 68  0
         Runnable work = associateWithSubject(command);
 69  0
         return this.targetScheduledExecutorService.schedule(work, delay, unit);
 70  
     }
 71  
 
 72  
     public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
 73  0
         Callable<V> work = associateWithSubject(callable);
 74  0
         return this.targetScheduledExecutorService.schedule(work, delay, unit);
 75  
     }
 76  
 
 77  
     public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
 78  0
         Runnable work = associateWithSubject(command);
 79  0
         return this.targetScheduledExecutorService.scheduleAtFixedRate(work, initialDelay, period, unit);
 80  
     }
 81  
 
 82  
     public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
 83  0
         Runnable work = associateWithSubject(command);
 84  0
         return this.targetScheduledExecutorService.scheduleWithFixedDelay(work, initialDelay, delay, unit);
 85  
     }
 86  
 }