当前位置: 首页>>代码示例>>Java>>正文


Java ServiceHelper.stopAndShutdownService方法代码示例

本文整理汇总了Java中org.apache.camel.util.ServiceHelper.stopAndShutdownService方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceHelper.stopAndShutdownService方法的具体用法?Java ServiceHelper.stopAndShutdownService怎么用?Java ServiceHelper.stopAndShutdownService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.util.ServiceHelper的用法示例。


在下文中一共展示了ServiceHelper.stopAndShutdownService方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shutdownServices

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
private void shutdownServices(Object service) {
    // do not rethrow exception as we want to keep shutting down in case of problems

    // allow us to do custom work before delegating to service helper
    try {
        if (service instanceof Service) {
            ServiceHelper.stopAndShutdownService(service);
        } else if (service instanceof Collection) {
            ServiceHelper.stopAndShutdownServices((Collection<?>)service);
        }
    } catch (Throwable e) {
        log.warn("Error occurred while shutting down service: " + service + ". This exception will be ignored.", e);
        // fire event
        EventHelper.notifyServiceStopFailure(this, service, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:DefaultCamelContext.java

示例2: doStop

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStop() throws Exception {
    // when stopping we intend to shutdown
    ServiceHelper.stopAndShutdownService(statistics);
    if (stopServicePool) {
        ServiceHelper.stopAndShutdownService(pool);
    }
    try {
        ServiceHelper.stopAndShutdownServices(producers.values());
    } finally {
        // ensure producers are removed, and also from JMX
        for (Producer producer : producers.values()) {
            getCamelContext().removeService(producer);
        }
    }
    producers.clear();
    if (statistics != null) {
        statistics.clear();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:ProducerCache.java

示例3: releasePollingConsumer

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
/**
 * Releases an acquired producer back after usage.
 *
 * @param endpoint the endpoint
 * @param pollingConsumer the pollingConsumer to release
 */
public void releasePollingConsumer(Endpoint endpoint, PollingConsumer pollingConsumer) {
    if (pollingConsumer instanceof ServicePoolAware) {
        // release back to the pool
        pool.release(endpoint, pollingConsumer);
    } else {
        boolean singleton = false;
        if (pollingConsumer instanceof IsSingleton) {
            singleton = ((IsSingleton) pollingConsumer).isSingleton();
        }
        if (!singleton) {
            try {
                // stop and shutdown non-singleton producers as we should not leak resources
                ServiceHelper.stopAndShutdownService(pollingConsumer);
            } catch (Exception ex) {
                if (ex instanceof RuntimeCamelException) {
                    throw (RuntimeCamelException)ex;
                } else {
                    throw new RuntimeCamelException(ex);
                }
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:30,代码来源:ConsumerCache.java

示例4: doStop

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStop() throws Exception {
    // stop event notifier
    camelContext.getManagementStrategy().removeEventNotifier(eventNotifier);
    ServiceHelper.stopService(eventNotifier);

    // stop and close collector
    ServiceHelper.stopAndShutdownService(spanCollector);
    if (spanCollector instanceof Closeable) {
        IOHelper.close((Closeable) spanCollector);
    }
    // clear braves
    braves.clear();
    // remove route policy
    camelContext.getRoutePolicyFactories().remove(this);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:ZipkinTracer.java

示例5: doShutdown

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doShutdown() throws Exception {
    ServiceHelper.stopAndShutdownService(processor);
    if (shutdownExecutorService) {
        getCamelContext().getExecutorServiceManager().shutdownNow(executorService);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:WireTapProcessor.java

示例6: releasePollingConsumer

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
public void releasePollingConsumer(Endpoint endpoint, PollingConsumer pollingConsumer) {
    // stop and shutdown the consumer as its not cache or reused
    try {
        ServiceHelper.stopAndShutdownService(pollingConsumer);
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:EmptyConsumerCache.java

示例7: releaseProducer

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
/**
 * Releases an acquired producer back after usage.
 *
 * @param endpoint the endpoint
 * @param producer the producer to release
 * @throws Exception can be thrown if error stopping producer if that was needed.
 */
public void releaseProducer(Endpoint endpoint, Producer producer) throws Exception {
    if (producer instanceof ServicePoolAware) {
        // release back to the pool
        pool.release(endpoint, producer);
    } else if (!producer.isSingleton()) {
        // stop and shutdown non-singleton producers as we should not leak resources
        ServiceHelper.stopAndShutdownService(producer);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:ProducerCache.java

示例8: doShutdown

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doShutdown() throws Exception {
    ServiceHelper.stopAndShutdownService(producerCache);
    super.doShutdown();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:RecipientListProcessor.java

示例9: doStop

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStop() throws Exception {
    // we should shutdown the services as this is our intention, to not re-use the services anymore
    ServiceHelper.stopAndShutdownService(consumerCache);
    consumerCache = null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:DefaultConsumerTemplate.java

示例10: releaseProducer

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
public void releaseProducer(Endpoint endpoint, Producer producer) throws Exception {
    // stop and shutdown the producer as its not cache or reused
    ServiceHelper.stopAndShutdownService(producer);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:EmptyProducerCache.java

示例11: doShutdown

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doShutdown() throws Exception {
    ServiceHelper.stopAndShutdownService(consumer);
    queue.clear();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:EventDrivenPollingConsumer.java

示例12: doShutdown

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doShutdown() throws Exception {
    super.doStop();
    ServiceHelper.stopAndShutdownService(validatingProcessor);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:ValidatorProducer.java

示例13: testQueueSize

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public void testQueueSize() throws Exception {
    // must start context as we do not use route builder that auto-start
    context.start();

    PollingConsumer consumer = context.getEndpoint(uri).createPollingConsumer();
    consumer.start();

    assertNotNull(consumer);
    EventDrivenPollingConsumer edpc = assertIsInstanceOf(EventDrivenPollingConsumer.class, consumer);
    assertEquals(0, edpc.getQueueSize());
    assertEquals(10, edpc.getQueueCapacity());
    assertFalse(edpc.isBlockWhenFull());

    for (int i = 0; i < 10; i++) {
        template.sendBody(uri, "Message " + i);
    }

    assertEquals(10, edpc.getQueueSize());

    try {
        template.sendBody(uri, "Message 10");
        fail("Should have thrown exception");
    } catch (CamelExecutionException e) {
        // queue should be full
        assertIsInstanceOf(IllegalStateException.class, e.getCause());
    }

    Exchange out = consumer.receive(5000);
    assertNotNull(out);
    assertEquals("Message 0", out.getIn().getBody());

    assertEquals(9, edpc.getQueueSize());
    assertEquals(10, edpc.getQueueCapacity());

    // now there is room
    template.sendBody(uri, "Message 10");

    assertEquals(10, edpc.getQueueSize());
    assertEquals(10, edpc.getQueueCapacity());

    ServiceHelper.stopService(consumer);
    // not cleared if we stop
    assertEquals(10, edpc.getQueueSize());
    assertEquals(10, edpc.getQueueCapacity());

    ServiceHelper.stopAndShutdownService(consumer);
    // now its cleared as we shutdown
    assertEquals(0, edpc.getQueueSize());
    assertEquals(10, edpc.getQueueCapacity());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:51,代码来源:EventDrivenPollingConsumerQueueSizeTest.java

示例14: destroy

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public void destroy() throws Exception {
    if (consumer != null) {
        ServiceHelper.stopAndShutdownService(consumer);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:CamelSourceAdapter.java


注:本文中的org.apache.camel.util.ServiceHelper.stopAndShutdownService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。