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

org.apache.camel.spi.ServicePool Maven / Gradle / Ivy

There is a newer version: 4.6.0
Show newest version
/**
 * 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.spi;

/**
 * A service pool is like a connection pool but can pool any kind of objects.
 * 

* Services that is capable of being pooled should implement the marker interface * {@link org.apache.camel.ServicePoolAware}. *

* Notice the capacity is per key which means that each key can contain at most * (the capacity) services. The pool can contain an unbounded number of keys. *

* By default the capacity is set to 100. * * @version */ public interface ServicePool { /** * Sets the capacity, which is capacity per key. * * @param capacity the capacity per key */ void setCapacity(int capacity); /** * Gets the capacity per key. * * @return the capacity per key */ int getCapacity(); /** * Adds the given service to the pool and acquires it. * * @param key the key * @param service the service * @return the acquired service, is newer null * @throws IllegalStateException if the queue is full (capacity has been reached) */ Service addAndAcquire(Key key, Service service); /** * Tries to acquire the service with the given key * * @param key the key * @return the acquired service, or null if no free in pool */ Service acquire(Key key); /** * Releases the service back to the pool * * @param key the key * @param service the service */ void release(Key key, Service service); /** * Returns the current size of the pool * * @return the current size of the pool */ int size(); /** * Purges the pool. */ void purge(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy