/****************************************************************************** * WebJavin - Java Web Framework. * * * * Copyright (c) 2011 - Sergey "Frosman" Lukjanov, me@frostman.ru * * * * 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 ru.frostman.web.config; import com.google.common.base.Objects; import java.util.concurrent.TimeUnit; /** * @author slukjanov aka Frostman */ public class PoolConfig { private int corePoolSize = Math.max(1, Runtime.getRuntime().availableProcessors() - 1); private int maximumPoolSize = Math.max(1, Runtime.getRuntime().availableProcessors() - 1); private long keepAliveTime = 2; private TimeUnit timeUnit = TimeUnit.MINUTES; public int getCorePoolSize() { return corePoolSize; } public void setCorePoolSize(int corePoolSize) { this.corePoolSize = corePoolSize; } public int getMaximumPoolSize() { return maximumPoolSize; } public void setMaximumPoolSize(int maximumPoolSize) { this.maximumPoolSize = maximumPoolSize; } 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; } @Override public boolean equals(Object obj) { if (obj instanceof PoolConfig) { PoolConfig config = (PoolConfig) obj; return corePoolSize == config.corePoolSize && maximumPoolSize == config.maximumPoolSize && keepAliveTime == config.keepAliveTime && Objects.equal(timeUnit, config.timeUnit); } return false; } @Override public int hashCode() { int result = corePoolSize; result = 31 * result + maximumPoolSize; result = 31 * result + (int) (keepAliveTime ^ (keepAliveTime >>> 32)); result = 31 * result + (timeUnit != null ? timeUnit.hashCode() : 0); return result; } }