zj
2025-10-05 fc68aa452e2fd56441128d1d5a4b32f254c6191d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package kernel.util;
 
import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
 
 
public class RejectExecutionHandlerDelegator implements RejectedExecutionHandler {
    
    private static final Logger logger = LoggerFactory.getLogger(RejectExecutionHandlerDelegator.class);
    
    private Collection<RejectedExecutionHandler> rejectExecutionHandlers = new ArrayList<RejectedExecutionHandler>();
    /* (non-Javadoc)
     * @see java.util.concurrent.RejectedExecutionHandler#rejectedExecution(java.lang.Runnable, java.util.concurrent.ThreadPoolExecutor)
     */
    public void rejectedExecution(Runnable runner, ThreadPoolExecutor executor) {
        logger.warn("do rejected Execution with runner[" + runner + "], executor[" + executor + "]");
        for(RejectedExecutionHandler rejectExecutionHandler : rejectExecutionHandlers){
            rejectExecutionHandler.rejectedExecution(runner, executor);
        }
    }
    
    public void setRejectExecutionHandlers(Collection<RejectedExecutionHandler> rejectExecutionHandlers) {
        Assert.notEmpty(rejectExecutionHandlers);
        this.rejectExecutionHandlers = rejectExecutionHandlers;
    }
 
}