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


Java ServiceHelper.startService方法代码示例

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


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

示例1: afterPropertiesSet

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public void afterPropertiesSet() throws Exception {
    // lets bind the URI to a pojo
    notNull(uri, "uri");
    // Always resolve the camel context by using the camelContextID
    if (ObjectHelper.isNotEmpty(camelContextId)) {
        camelContext = CamelContextResolverHelper.getCamelContextWithId(applicationContext, camelContextId);
    }
    notNull(camelContext, "camelContext");
    if (serviceRef != null && getService() == null && applicationContext != null) {
        setService(applicationContext.getBean(serviceRef));
    }

    Endpoint endpoint = CamelContextHelper.getMandatoryEndpoint(camelContext, uri);
    notNull(getService(), "service");
    Object proxy = getProxyForService();

    try {
        // need to start endpoint before we create consumer
        ServiceHelper.startService(endpoint);
        consumer = endpoint.createConsumer(new BeanProcessor(proxy, camelContext));
        // add and start consumer
        camelContext.addService(consumer, true, true);
    } catch (Exception e) {
        throw new FailedToCreateConsumerException(endpoint, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:CamelServiceExporter.java

示例2: doStart

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStart() throws Exception {
    warmUp();

    for (Route route : routes) {
        // start the route itself
        ServiceHelper.startService(route);

        // invoke callbacks on route policy
        if (route.getRouteContext().getRoutePolicyList() != null) {
            for (RoutePolicy routePolicy : route.getRouteContext().getRoutePolicyList()) {
                routePolicy.onStart(route);
            }
        }

        // fire event
        EventHelper.notifyRouteStarted(camelContext, route);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:RouteService.java

示例3: activate

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public void activate() {
    LOG.debug("CamelDestination activate().... ");
    ObjectHelper.notNull(camelContext, "CamelContext", this);
    try {
        LOG.debug("establishing Camel connection");
        destinationEndpoint = getCamelContext().getEndpoint(camelDestinationUri);
        if (destinationEndpoint == null) {
            throw new NoSuchEndpointException(camelDestinationUri);
        }
        consumer = destinationEndpoint.createConsumer(new ConsumerProcessor());
        ServiceHelper.startService(consumer);
    } catch (NoSuchEndpointException nex) {
        throw nex;
    } catch (Exception ex) {
        if (destinationEndpoint == null) {
            throw new FailedToCreateConsumerException(camelDestinationUri, ex);
        }
        throw new FailedToCreateConsumerException(destinationEndpoint, ex);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:CamelDestination.java

示例4: acquirePollingConsumer

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
public PollingConsumer acquirePollingConsumer(Endpoint endpoint) {
    // always create a new consumer
    PollingConsumer answer;
    try {
        answer = endpoint.createPollingConsumer();
        boolean singleton = true;
        if (answer instanceof IsSingleton) {
            singleton = ((IsSingleton) answer).isSingleton();
        }
        if (getCamelContext().isStartingRoutes() && singleton) {
            // if we are currently starting a route, then add as service and enlist in JMX
            // - but do not enlist non-singletons in JMX
            // - note addService will also start the service
            getCamelContext().addService(answer);
        } else {
            // must then start service so producer is ready to be used
            ServiceHelper.startService(answer);
        }
    } catch (Exception e) {
        throw new FailedToCreateConsumerException(endpoint, e);
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:EmptyConsumerCache.java

示例5: EndpointSubscription

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public EndpointSubscription(ExecutorService workerPool, Endpoint endpoint, final Observer<? super T> observer,
                            final Func1<Exchange, T> func) {
    this.workerPool = workerPool;
    this.endpoint = endpoint;
    this.observer = observer;

    // lets create the consumer
    Processor processor = new ProcessorToObserver<T>(func, observer);
    // must ensure the consumer is being executed in an unit of work so synchronization callbacks etc is invoked
    CamelInternalProcessor internal = new CamelInternalProcessor(processor);
    internal.addAdvice(new CamelInternalProcessor.UnitOfWorkProcessorAdvice(null));
    try {
        // need to start endpoint before we create producer
        ServiceHelper.startService(endpoint);
        this.consumer = endpoint.createConsumer(internal);
        // add as service so we ensure it gets stopped when CamelContext stops
        endpoint.getCamelContext().addService(consumer, true, true);
    } catch (Exception e) {
        observer.onError(e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:EndpointSubscription.java

示例6: enableDebugger

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public void enableDebugger() {
    logger.log("Enabling debugger");
    try {
        ServiceHelper.startService(debugger);
        enabled.set(true);
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:BacklogDebugger.java

示例7: doStart

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
    ObjectHelper.notNull(camelContext, "CamelContext", this);
    if (scope == ThrottlingScope.Context) {
        eventNotifier = new ContextScopedEventNotifier();
        // must start the notifier before it can be used
        ServiceHelper.startService(eventNotifier);
        // we are in context scope, so we need to use an event notifier to keep track
        // when any exchanges is done on the camel context.
        // This ensures we can trigger accordingly to context scope
        camelContext.getManagementStrategy().addEventNotifier(eventNotifier);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:ThrottlingInflightRoutePolicy.java

示例8: createProxy

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T createProxy(Endpoint endpoint, Class<?>... interfaceClasses) throws Exception {
    Producer producer = endpoint.createProducer();
    // ensure the producer is started
    ServiceHelper.startService(producer);
    return (T)Proxy.newProxyInstance(ProxyHelper.getClassLoader(interfaceClasses), interfaceClasses.clone(), new PojoMessageInvocationHandler(endpoint, producer));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:PojoProxyHelper.java

示例9: getConsumerMulticastProcessor

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected synchronized MulticastProcessor getConsumerMulticastProcessor() throws Exception {
    if (!multicastStarted && consumerMulticastProcessor != null) {
        // only start it on-demand to avoid starting it during stopping
        ServiceHelper.startService(consumerMulticastProcessor);
        multicastStarted = true;
    }
    return consumerMulticastProcessor;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:SedaEndpoint.java

示例10: doStart

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStart() throws Exception {
    if (producerCache == null) {
        if (cacheSize < 0) {
            producerCache = new EmptyProducerCache(this, camelContext);
            LOG.debug("DynamicSendTo {} is not using ProducerCache", this);
        } else if (cacheSize == 0) {
            producerCache = new ProducerCache(this, camelContext);
            LOG.debug("DynamicSendTo {} using ProducerCache with default cache size", this);
        } else {
            producerCache = new ProducerCache(this, camelContext, cacheSize);
            LOG.debug("DynamicSendTo {} using ProducerCache with cacheSize={}", this, cacheSize);
        }
    }
    ServiceHelper.startService(producerCache);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:SendDynamicProcessor.java

示例11: doStart

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
    ObjectHelper.notNull(camelContext, "camelContext", this);
    if (endpoint == null && endpointUri == null) {
        throw new IllegalArgumentException("Either endpoint or endpointUri must be configured");
    }

    if (endpoint == null) {
        endpoint = camelContext.getEndpoint(endpointUri);
    }

    producer = endpoint.createProducer();
    ServiceHelper.startService(producer);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:PublishEventNotifier.java

示例12: doStartManagementStrategy

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStartManagementStrategy() throws Exception {
    ObjectHelper.notNull(camelContext, "CamelContext");

    if (eventNotifiers != null) {
        for (EventNotifier notifier : eventNotifiers) {

            // inject CamelContext if the service is aware
            if (notifier instanceof CamelContextAware) {
                CamelContextAware aware = (CamelContextAware) notifier;
                aware.setCamelContext(camelContext);
            }

            ServiceHelper.startService(notifier);
        }
    }

    if (managementAgent != null) {
        ServiceHelper.startService(managementAgent);
        // set the naming strategy using the domain name from the agent
        if (managementNamingStrategy == null) {
            setManagementNamingStrategy(new DefaultManagementNamingStrategy(managementAgent.getMBeanObjectDomainName()));
        }
    }
    if (managementNamingStrategy instanceof CamelContextAware) {
        ((CamelContextAware) managementNamingStrategy).setCamelContext(getCamelContext());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:DefaultManagementStrategy.java

示例13: doStart

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStart() throws Exception {
    if (consumerCache == null) {
        if (maximumCacheSize > 0) {
            consumerCache = new ConsumerCache(this, camelContext, maximumCacheSize);
        } else {
            consumerCache = new ConsumerCache(this, camelContext);
        }
    }
    ServiceHelper.startService(consumerCache);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:DefaultConsumerTemplate.java

示例14: doStart

import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
    super.doStart();
    ServiceHelper.startService(endpoint);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:6,代码来源:ComponentProxyEndpoint.java

示例15: setUp

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


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