package it.mice.voila.runtime.taskexecutor;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.ThreadPoolExecutor.AbortPolicy;
import java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy;
import java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy;
import java.util.concurrent.ThreadPoolExecutor.DiscardPolicy;

import org.apache.log4j.Logger;

public class ThreadPoolTaskExecutor extends org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor {
	private static Logger log = Logger.getLogger(ThreadPoolTaskExecutor.class);
	private static final long serialVersionUID = 1L;
	class CustomAbortPolicy extends AbortPolicy {
		@Override
		public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
			log.debug(r.toString() + " : has been rejected");
			super.rejectedExecution(r, e);
		}
		
	}
	class CustomDiscardPolicy extends DiscardPolicy {
		@Override
		public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
			log.debug(r.toString() + " : has been rejected");
			super.rejectedExecution(r, e);
		}
		
	}
	class CustomDiscardOldestPolicy extends DiscardOldestPolicy {
		@Override
		public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
			log.debug(r.toString() + " : has been rejected");
			super.rejectedExecution(r, e);
		}
		
	}
	class CustomCallerRunsPolicy extends CallerRunsPolicy {
		@Override
		public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
			log.debug(r.toString() + " : has been rejected");
			super.rejectedExecution(r, e);
		}
		
	}

	@Override
	public void setRejectedExecutionHandler(
			RejectedExecutionHandler customRejectedExecutionHandler) {
		super.setRejectedExecutionHandler(customRejectedExecutionHandler);
	}

	
	
}
