| /** |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You 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 org.apache.camel.impl; |
| |
| import java.util.concurrent.RejectedExecutionHandler; |
| import java.util.concurrent.TimeUnit; |
| |
| import org.apache.camel.ThreadPoolRejectedPolicy; |
| import org.apache.camel.spi.ThreadPoolProfile; |
| |
| /** |
| * @version $Revision$ |
| */ |
| public class ThreadPoolProfileSupport implements ThreadPoolProfile { |
| |
| private final String id; |
| private Boolean defaultProfile; |
| private Integer poolSize; |
| private Integer maxPoolSize; |
| private Long keepAliveTime; |
| private TimeUnit timeUnit = TimeUnit.SECONDS; |
| private Integer maxQueueSize; |
| private ThreadPoolRejectedPolicy rejectedPolicy; |
| |
| public ThreadPoolProfileSupport(String id) { |
| this.id = id; |
| } |
| |
| public String getId() { |
| return id; |
| } |
| |
| public Boolean isDefaultProfile() { |
| return defaultProfile != null && defaultProfile; |
| } |
| |
| public void setDefaultProfile(Boolean defaultProfile) { |
| this.defaultProfile = defaultProfile; |
| } |
| |
| public Integer getPoolSize() { |
| return poolSize; |
| } |
| |
| public void setPoolSize(Integer poolSize) { |
| this.poolSize = poolSize; |
| } |
| |
| public Integer getMaxPoolSize() { |
| return maxPoolSize; |
| } |
| |
| public void setMaxPoolSize(Integer maxPoolSize) { |
| this.maxPoolSize = maxPoolSize; |
| } |
| |
| public Long getKeepAliveTime() { |
| return keepAliveTime; |
| } |
| |
| public void setKeepAliveTime(Long keepAliveTime) { |
| this.keepAliveTime = keepAliveTime; |
| } |
| |
| public TimeUnit getTimeUnit() { |
| return timeUnit; |
| } |
| |
| public void setTimeUnit(TimeUnit timeUnit) { |
| this.timeUnit = timeUnit; |
| } |
| |
| public Integer getMaxQueueSize() { |
| return maxQueueSize; |
| } |
| |
| public void setMaxQueueSize(Integer maxQueueSize) { |
| this.maxQueueSize = maxQueueSize; |
| } |
| |
| public ThreadPoolRejectedPolicy getRejectedPolicy() { |
| return rejectedPolicy; |
| } |
| |
| public RejectedExecutionHandler getRejectedExecutionHandler() { |
| if (rejectedPolicy != null) { |
| return rejectedPolicy.asRejectedExecutionHandler(); |
| } |
| return null; |
| } |
| |
| public void setRejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy) { |
| this.rejectedPolicy = rejectedPolicy; |
| } |
| |
| @Override |
| public String toString() { |
| return "ThreadPoolProfile[" + id + ", " + defaultProfile + ", " + poolSize + ", " + maxPoolSize + ", " |
| + keepAliveTime + " " + timeUnit + ", " + maxPoolSize + ", " + rejectedPolicy + "]"; |
| } |
| } |