io.vlingo.common.pool.AbstractResourcePool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vlingo-common Show documentation
Show all versions of vlingo-common Show documentation
These are just a few common tools shared across various vlingo projects.
// Copyright © 2012-2020 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.
package io.vlingo.common.pool;
/**
* An abstract {@link ResourcePool} that implements {@link ResourcePool#acquire()}
* using the default arguments from {@link ResourceFactory#defaultArguments()}.
*
* @param the type of the pooled resource
* @param the type of the arguments to the acquire method
*/
abstract class AbstractResourcePool implements ResourcePool {
final ResourceFactory factory;
AbstractResourcePool(ResourceFactory factory) {
this.factory = factory;
}
/**
* Uses {@link ResourceFactory#defaultArguments()} to {@link ResourcePool#acquire(Object)} a resource object.
*
* @return a resource object with default arguments
* @see ResourceFactory#defaultArguments()
*/
@Override
public Resource acquire() {
return acquire(factory.defaultArguments());
}
}