[ 
https://issues.apache.org/jira/browse/TOMEE-382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13438116#comment-13438116
 ] 

David Blevins commented on TOMEE-382:
-------------------------------------

Configuration is effectively:


    public static AsynchronousPool create(AppContext appContext) {
        final Options options = appContext.getOptions();

        final String id = appContext.getId();
        final int corePoolSize = options.get("AsynchronousPool.CorePoolSize", 
10);
        final int maximumPoolSize = 
Math.max(options.get("AsynchronousPool.MaximumPoolSize", 20), corePoolSize);
        final Duration keepAliveTime = 
options.get("AsynchronousPool.KeepAliveTime", new Duration(60, 
TimeUnit.SECONDS));
        final BlockingQueue queue = options.get("AsynchronousPool.QueueType", 
QueueType.LINKED).create(options);

        return new AsynchronousPool(id, corePoolSize, maximumPoolSize, 
keepAliveTime, queue);
    }

    private static enum QueueType {
        ARRAY,
        DELAY,
        LINKED,
        PRIORITY,
        SYNCHRONOUS;

        public BlockingQueue create(Options options) {
            switch (this) {
                case ARRAY: {
                    return new 
ArrayBlockingQueue(options.get("AsynchronousPool.QueueSize", 100));
                }
                case DELAY: {
                    return new DelayQueue();
                }
                case LINKED: {
                    return new 
LinkedBlockingQueue(options.get("AsynchronousPool.QueueSize", 
Integer.MAX_VALUE));
                }
                case PRIORITY: {
                    return new PriorityBlockingQueue();
                }
                case SYNCHRONOUS: {
                    return new 
SynchronousQueue(options.get("AsynchronousPool.QueueFair", false));
                }
                default: {
                    // The Options class will throw an error if the user 
supplies an unknown enum string
                    // The only way we can reach this is if we add a new 
QueueType element and forget to
                    // implement it in the above switch statement.
                    throw new IllegalArgumentException("Unknown QueueType type: 
" + this);
                }
            }
        }
    }

                
> configuration for asynch task pool
> ----------------------------------
>
>                 Key: TOMEE-382
>                 URL: https://issues.apache.org/jira/browse/TOMEE-382
>             Project: TomEE
>          Issue Type: Improvement
>            Reporter: Romain Manni-Bucau
>             Fix For: 1.1.0
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to