// Path: porcupine/src/main/java/com/airhacks/porcupine/configuration/control/ExecutorConfigurator.java
// public class ExecutorConfigurator {
// 
//     /**
//      *
//      * @param name the name used within the {@link Dedicated} qualifier.
//      * @return a default configuration, unless overridden
//      */
//     public ExecutorConfiguration forPipeline(String name) {
//         return defaultConfigurator();
//     }
// 
//     /**
//      *
//      * @return the default configuration for all injected
//      * {@link ExecutorService} instances (unless overridden and specialized
//      * {@link Specializes})
//      */
//     public ExecutorConfiguration defaultConfigurator() {
//         return ExecutorConfiguration.defaultConfiguration();
//     }
// 
// }
// 
// Path: porcupine/src/main/java/com/airhacks/porcupine/execution/control/ExecutorConfiguration.java
// public class ExecutorConfiguration {
// 
//     private int corePoolSize;
//     private int keepAliveTime;
//     private int maxPoolSize;
//     private int queueCapacity;
//     private RejectedExecutionHandler rejectedExecutionHandler;
// 
//     private ExecutorConfiguration() {
//         int availableProcessors = Runtime.getRuntime().availableProcessors();
//         this.corePoolSize = availableProcessors;
//         this.maxPoolSize = availableProcessors * 2;
//         this.keepAliveTime = 1;
//         this.queueCapacity = 100;
// 
//     }
// 
//     public final static class Builder {
// 
//         ExecutorConfiguration configuration = new ExecutorConfiguration();
// 
//         public Builder corePoolSize(int corePoolSize) {
//             configuration.corePoolSize = corePoolSize;
//             return this;
//         }
// 
//         public Builder keepAliveTime(int keepAliveTime) {
//             configuration.keepAliveTime = keepAliveTime;
//             return this;
//         }
// 
//         public Builder maxPoolSize(int maxPoolSize) {
//             configuration.maxPoolSize = maxPoolSize;
//             return this;
//         }
// 
//         public Builder queueCapacity(int queueCapacity) {
//             configuration.queueCapacity = queueCapacity;
//             return this;
//         }
// 
//         public Builder abortPolicy() {
//             configuration.rejectedExecutionHandler = new ThreadPoolExecutor.AbortPolicy();
//             return this;
//         }
// 
//         public Builder callerRunsPolicy() {
//             configuration.rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
//             return this;
//         }
// 
//         public Builder discardPolicy() {
//             configuration.rejectedExecutionHandler = new ThreadPoolExecutor.DiscardPolicy();
//             return this;
//         }
// 
//         public Builder discardOldestPolicy() {
//             configuration.rejectedExecutionHandler = new ThreadPoolExecutor.DiscardOldestPolicy();
//             return this;
//         }
// 
//         public Builder customRejectedExecutionHandler(RejectedExecutionHandler reh) {
//             configuration.rejectedExecutionHandler = reh;
//             return this;
//         }
// 
//         void validateConfiguration() {
//             if (this.configuration.keepAliveTime < 0) {
//                 throw new IllegalStateException("keepAliveTime is: " + this.configuration.keepAliveTime + " but should be > 0");
//             }
// 
//             if (this.configuration.queueCapacity < 0) {
//                 throw new IllegalStateException("queueCapacity is: " + this.configuration.queueCapacity + " but should be > 0");
//             }
//             if (this.configuration.corePoolSize > this.configuration.maxPoolSize) {
//                 throw new IllegalStateException("corePoolSize(" + this.configuration.corePoolSize + ") is larger than maxPoolSize(" + this.configuration.maxPoolSize + ")");
//             }
//         }
// 
//         public ExecutorConfiguration build() {
//             validateConfiguration();
//             return configuration;
// 
//         }
//     }
// 
//     /**
//      *
//      * @return default configuration. corePoolSize is the amount of cores, the
//      * maxPoolSize twice the amount of cores, keepAliveTime is one second and
//      * the queueCapacity is 100.
//      */
//     public static final ExecutorConfiguration defaultConfiguration() {
//         return new ExecutorConfiguration();
//     }
// 
//     public int getCorePoolSize() {
//         return corePoolSize;
//     }
// 
//     public int getKeepAliveTime() {
//         return keepAliveTime;
//     }
// 
//     public int getMaxPoolSize() {
//         return maxPoolSize;
//     }
// 
//     public int getQueueCapacity() {
//         return queueCapacity;
//     }
// 
//     public RejectedExecutionHandler getRejectedExecutionHandler() {
//         return rejectedExecutionHandler;
//     }
// 
// }


import com.airhacks.porcupine.configuration.control.ExecutorConfigurator;
import com.airhacks.porcupine.execution.control.ExecutorConfiguration;
import javax.enterprise.inject.Specializes;
/*
 * Copyright 2016 Adam Bien.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.airhacks.porcupine.execution.boundary;


/**
 *
 * @author airhacks.com
 */
@Specializes
public class OverloadedConfiguration extends ExecutorConfigurator {

    @Override
    public ExecutorConfiguration forPipeline(String name) {
        if ("overloaded".equalsIgnoreCase(name)) {
// Path: porcupine/src/main/java/com/airhacks/porcupine/configuration/control/ExecutorConfigurator.java
// public class ExecutorConfigurator {
// 
//     /**
//      *
//      * @param name the name used within the {@link Dedicated} qualifier.
//      * @return a default configuration, unless overridden
//      */
//     public ExecutorConfiguration forPipeline(String name) {
//         return defaultConfigurator();
//     }
// 
//     /**
//      *
//      * @return the default configuration for all injected
//      * {@link ExecutorService} instances (unless overridden and specialized
//      * {@link Specializes})
//      */
//     public ExecutorConfiguration defaultConfigurator() {
//         return ExecutorConfiguration.defaultConfiguration();
//     }
// 
// }
// 
// Path: porcupine/src/main/java/com/airhacks/porcupine/execution/control/ExecutorConfiguration.java
// public class ExecutorConfiguration {
// 
//     private int corePoolSize;
//     private int keepAliveTime;
//     private int maxPoolSize;
//     private int queueCapacity;
//     private RejectedExecutionHandler rejectedExecutionHandler;
// 
//     private ExecutorConfiguration() {
//         int availableProcessors = Runtime.getRuntime().availableProcessors();
//         this.corePoolSize = availableProcessors;
//         this.maxPoolSize = availableProcessors * 2;
//         this.keepAliveTime = 1;
//         this.queueCapacity = 100;
// 
//     }
// 
//     public final static class Builder {
// 
//         ExecutorConfiguration configuration = new ExecutorConfiguration();
// 
//         public Builder corePoolSize(int corePoolSize) {
//             configuration.corePoolSize = corePoolSize;
//             return this;
//         }
// 
//         public Builder keepAliveTime(int keepAliveTime) {
//             configuration.keepAliveTime = keepAliveTime;
//             return this;
//         }
// 
//         public Builder maxPoolSize(int maxPoolSize) {
//             configuration.maxPoolSize = maxPoolSize;
//             return this;
//         }
// 
//         public Builder queueCapacity(int queueCapacity) {
//             configuration.queueCapacity = queueCapacity;
//             return this;
//         }
// 
//         public Builder abortPolicy() {
//             configuration.rejectedExecutionHandler = new ThreadPoolExecutor.AbortPolicy();
//             return this;
//         }
// 
//         public Builder callerRunsPolicy() {
//             configuration.rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
//             return this;
//         }
// 
//         public Builder discardPolicy() {
//             configuration.rejectedExecutionHandler = new ThreadPoolExecutor.DiscardPolicy();
//             return this;
//         }
// 
//         public Builder discardOldestPolicy() {
//             configuration.rejectedExecutionHandler = new ThreadPoolExecutor.DiscardOldestPolicy();
//             return this;
//         }
// 
//         public Builder customRejectedExecutionHandler(RejectedExecutionHandler reh) {
//             configuration.rejectedExecutionHandler = reh;
//             return this;
//         }
// 
//         void validateConfiguration() {
//             if (this.configuration.keepAliveTime < 0) {
//                 throw new IllegalStateException("keepAliveTime is: " + this.configuration.keepAliveTime + " but should be > 0");
//             }
// 
//             if (this.configuration.queueCapacity < 0) {
//                 throw new IllegalStateException("queueCapacity is: " + this.configuration.queueCapacity + " but should be > 0");
//             }
//             if (this.configuration.corePoolSize > this.configuration.maxPoolSize) {
//                 throw new IllegalStateException("corePoolSize(" + this.configuration.corePoolSize + ") is larger than maxPoolSize(" + this.configuration.maxPoolSize + ")");
//             }
//         }
// 
//         public ExecutorConfiguration build() {
//             validateConfiguration();
//             return configuration;
// 
//         }
//     }
// 
//     /**
//      *
//      * @return default configuration. corePoolSize is the amount of cores, the
//      * maxPoolSize twice the amount of cores, keepAliveTime is one second and
//      * the queueCapacity is 100.
//      */
//     public static final ExecutorConfiguration defaultConfiguration() {
//         return new ExecutorConfiguration();
//     }
// 
//     public int getCorePoolSize() {
//         return corePoolSize;
//     }
// 
//     public int getKeepAliveTime() {
//         return keepAliveTime;
//     }
// 
//     public int getMaxPoolSize() {
//         return maxPoolSize;
//     }
// 
//     public int getQueueCapacity() {
//         return queueCapacity;
//     }
// 
//     public RejectedExecutionHandler getRejectedExecutionHandler() {
//         return rejectedExecutionHandler;
//     }
// 
// }


// Path: porcupine/src/test/java/com/airhacks/porcupine/execution/boundary/OverloadedConfiguration.java
import com.airhacks.porcupine.configuration.control.ExecutorConfigurator;
import com.airhacks.porcupine.execution.control.ExecutorConfiguration;
import javax.enterprise.inject.Specializes;

/*
 * Copyright 2016 Adam Bien.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.airhacks.porcupine.execution.boundary;


/**
 *
 * @author airhacks.com
 */
@Specializes
public class OverloadedConfiguration extends ExecutorConfigurator {

    @Override
    public ExecutorConfiguration forPipeline(String name) {
        if ("overloaded".equalsIgnoreCase(name)) {
            return new ExecutorConfiguration.Builder().