001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.executor;
016    
017    import com.liferay.portal.kernel.concurrent.ThreadPoolExecutor;
018    
019    import java.util.concurrent.Callable;
020    import java.util.concurrent.ExecutionException;
021    import java.util.concurrent.Future;
022    import java.util.concurrent.TimeUnit;
023    import java.util.concurrent.TimeoutException;
024    
025    /**
026     * @author Shuyang Zhou
027     */
028    public interface PortalExecutorManager {
029    
030            public <T> Future<T> execute(String name, Callable<T> callable);
031    
032            public <T> T execute(
033                            String name, Callable<T> callable, long timeout, TimeUnit timeUnit)
034                    throws ExecutionException, InterruptedException, TimeoutException;
035    
036            public ThreadPoolExecutor getPortalExecutor(String name);
037    
038            public ThreadPoolExecutor getPortalExecutor(
039                    String name, boolean createIfAbsent);
040    
041            public ThreadPoolExecutor registerPortalExecutor(
042                    String name, ThreadPoolExecutor threadPoolExecutor);
043    
044            public void shutdown();
045    
046            public void shutdown(boolean interrupt);
047    
048            public void shutdown(String name);
049    
050            public void shutdown(String name, boolean interrupt);
051    
052    }