Java 类org.apache.camel.spi.ServicePool 实例源码

项目:Camel    文件:ProducerCache.java   
public ProducerCache(Object source, CamelContext camelContext, ServicePool<Endpoint, Producer> producerServicePool, Map<String, Producer> cache) {
    this.source = source;
    this.camelContext = camelContext;
    if (producerServicePool == null) {
        // use shared producer pool which lifecycle is managed by CamelContext
        this.pool = camelContext.getProducerServicePool();
        this.stopServicePool = false;
    } else {
        this.pool = producerServicePool;
        this.stopServicePool = true;
    }
    this.producers = cache;
    if (producers instanceof LRUCache) {
        maxCacheSize = ((LRUCache) producers).getMaxCacheSize();
    }

    // only if JMX is enabled
    if (camelContext.getManagementStrategy().getManagementAgent() != null) {
        this.extendedStatistics = camelContext.getManagementStrategy().getManagementAgent().getStatisticsLevel().isExtended();
    } else {
        this.extendedStatistics = false;
    }
}
项目:Camel    文件:ConsumerCache.java   
public ConsumerCache(Object source, CamelContext camelContext, Map<String, PollingConsumer> cache, ServicePool<Endpoint, PollingConsumer> pool) {
    this.camelContext = camelContext;
    this.consumers = cache;
    this.source = source;
    this.pool = pool;
    if (consumers instanceof LRUCache) {
        maxCacheSize = ((LRUCache) consumers).getMaxCacheSize();
    }

    // only if JMX is enabled
    if (camelContext.getManagementStrategy().getManagementAgent() != null) {
        this.extendedStatistics = camelContext.getManagementStrategy().getManagementAgent().getStatisticsLevel().isExtended();
    } else {
        this.extendedStatistics = false;
    }
}
项目:Camel    文件:DefaultCamelContext.java   
public void setProducerServicePool(ServicePool<Endpoint, Producer> producerServicePool) {
    this.producerServicePool = producerServicePool;
}
项目:Camel    文件:DefaultCamelContext.java   
public ServicePool<Endpoint, Producer> getProducerServicePool() {
    return producerServicePool;
}
项目:Camel    文件:DefaultCamelContext.java   
public ServicePool<Endpoint, PollingConsumer> getPollingConsumerServicePool() {
    return pollingConsumerServicePool;
}
项目:Camel    文件:DefaultCamelContext.java   
public void setPollingConsumerServicePool(ServicePool<Endpoint, PollingConsumer> pollingConsumerServicePool) {
    this.pollingConsumerServicePool = pollingConsumerServicePool;
}
项目:Camel    文件:CamelContextSharedProducerServicePoolTest.java   
public void testSharedProducerServicePoolHitMax() throws Exception {
    // the default capacity
    assertEquals(100, context.getProducerServicePool().getCapacity());

    // change it
    ServicePool<Endpoint, Producer> pool = context.getProducerServicePool();
    pool.setCapacity(3);
    assertEquals(3, pool.getCapacity());

    Endpoint endpoint = context.getEndpoint("mock:foo");

    assertNull(pool.acquire(endpoint));
    assertEquals(0, pool.size());

    Producer producer = new MyProducer(endpoint);
    producer = pool.addAndAcquire(endpoint, producer);
    assertEquals(0, pool.size());

    Producer producer2 = new MyProducer(endpoint);
    producer2 = pool.addAndAcquire(endpoint, producer2);
    assertEquals(0, pool.size());

    Producer producer3 = new MyProducer(endpoint);
    producer3 = pool.addAndAcquire(endpoint, producer3);
    assertEquals(0, pool.size());

    pool.release(endpoint, producer);
    assertEquals(1, pool.size());

    pool.release(endpoint, producer2);
    assertEquals(2, pool.size());

    pool.release(endpoint, producer3);
    assertEquals(3, pool.size());

    Producer producer4 = new MyProducer(endpoint);
    try {
        producer4 = pool.addAndAcquire(endpoint, producer4);
        fail("Should throw an exception");
    } catch (IllegalStateException e) {
        assertEquals("Queue full", e.getMessage());
    }
    assertEquals(3, pool.size());
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public void setProducerServicePool(ServicePool<Endpoint, Producer> servicePool) {
  context.setProducerServicePool(servicePool);
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public ServicePool<Endpoint, Producer> getProducerServicePool() {
  return context.getProducerServicePool();
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public void setPollingConsumerServicePool(ServicePool<Endpoint, PollingConsumer> servicePool) {
  context.setPollingConsumerServicePool(servicePool);
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public ServicePool<Endpoint, PollingConsumer> getPollingConsumerServicePool() {
  return context.getPollingConsumerServicePool();
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public void setProducerServicePool(ServicePool<Endpoint, Producer> servicePool) {
    context.setProducerServicePool(servicePool);
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public ServicePool<Endpoint, Producer> getProducerServicePool() {
    return context.getProducerServicePool();
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public void setPollingConsumerServicePool(ServicePool<Endpoint, PollingConsumer> servicePool) {
    context.setPollingConsumerServicePool(servicePool);
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public ServicePool<Endpoint, PollingConsumer> getPollingConsumerServicePool() {
    return context.getPollingConsumerServicePool();
}
项目:Camel    文件:CamelContext.java   
/**
 * Sets a pluggable service pool to use for {@link Producer} pooling.
 *
 * @param servicePool the pool
 */
void setProducerServicePool(ServicePool<Endpoint, Producer> servicePool);
项目:Camel    文件:CamelContext.java   
/**
 * Gets the service pool for {@link Producer} pooling.
 *
 * @return the service pool
 */
ServicePool<Endpoint, Producer> getProducerServicePool();
项目:Camel    文件:CamelContext.java   
/**
 * Sets a pluggable service pool to use for {@link PollingConsumer} pooling.
 *
 * @param servicePool the pool
 */
void setPollingConsumerServicePool(ServicePool<Endpoint, PollingConsumer> servicePool);
项目:Camel    文件:CamelContext.java   
/**
 * Gets the service pool for {@link Producer} pooling.
 *
 * @return the service pool
 */
ServicePool<Endpoint, PollingConsumer> getPollingConsumerServicePool();