All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vlingo.common.pool.AbstractResourcePool Maven / Gradle / Ivy

There is a newer version: 1.7.5
Show newest version
// 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());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy