本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例14: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
super.doStart();
ServiceHelper.startService(endpoint);
}
示例15: setUp
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
ServiceHelper.startService(converter);
}