Java 类org.apache.camel.support.LifecycleStrategySupport 实例源码

项目:Camel    文件:CamelContextTrackerTest.java   
@Override
public void contextCreated(CamelContext camelContext) {
    camelContext.addLifecycleStrategy(new LifecycleStrategySupport() {
        @Override
        public void onContextStop(CamelContext context) {
            names.remove(context.getName());
        }
    });
    names.add(camelContext.getName());
}
项目:respiro    文件:DocumenterPlugin.java   
public DocumenterPlugin() {

        customizer = camelContext ->
          camelContext.addLifecycleStrategy(new LifecycleStrategySupport() {
              @Override
              public void onContextStart(CamelContext context) throws VetoCamelContextStartException {

                  routeDocumentations =
                    iterableList(context.getRouteDefinitions()).map(RouteDocumentation::fromRoute);
              }
          });

        exchangesListener = log::addExchange;
        Collector.addListener(exchangesListener);

        mapper = new ObjectMapper();
        SimpleModule fjModule = new SimpleModule();
        fjModule.addSerializer(List.class, new JsonSerializer<List>() {
            @Override
            public void serialize(
              List value,
              JsonGenerator gen,
              SerializerProvider serializers) throws IOException, JsonProcessingException {
                serializers.defaultSerializeValue(value.toJavaList(), gen);
            }
        });
        mapper.registerModule(fjModule);
    }
项目:ignite    文件:IgniteCamelStreamerTest.java   
/**
 * @throws Exception
 */
public void testUserSpecifiedCamelContext() throws Exception {
    final AtomicInteger cnt = new AtomicInteger();

    // Create a CamelContext with a probe that'll help us know if it has been used.
    CamelContext context = new DefaultCamelContext();
    context.setTracing(true);
    context.addLifecycleStrategy(new LifecycleStrategySupport() {
        @Override public void onEndpointAdd(Endpoint endpoint) {
            cnt.incrementAndGet();
        }
    });

    streamer.setSingleTupleExtractor(singleTupleExtractor());
    streamer.setCamelContext(context);

    // Subscribe to cache PUT events.
    CountDownLatch latch = subscribeToPutEvents(50);

    // Action time.
    streamer.start();

    // Send messages.
    sendMessages(0, 50, false);

    // Assertions.
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    assertCacheEntriesLoaded(50);
    assertTrue(cnt.get() > 0);
}