本文整理汇总了Java中org.apache.camel.util.ServiceHelper.startServices方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceHelper.startServices方法的具体用法?Java ServiceHelper.startServices怎么用?Java ServiceHelper.startServices使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.util.ServiceHelper
的用法示例。
在下文中一共展示了ServiceHelper.startServices方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
camelContext = new DefaultCamelContext();
SimpleRegistry registry = new SimpleRegistry();
Map<String, Object> params = new HashMap<String, Object>();
params.put("custName", "Willem");
// bind the params
registry.put("params", params);
camelContext.setRegistry(registry);
template = camelContext.createProducerTemplate();
ServiceHelper.startServices(template, camelContext);
Endpoint value = camelContext.getEndpoint(getEndpointUri());
assertNotNull("Could not find endpoint!", value);
assertTrue("Should be a JPA endpoint but was: " + value, value instanceof JpaEndpoint);
endpoint = (JpaEndpoint)value;
transactionTemplate = endpoint.createTransactionTemplate();
entityManager = endpoint.createEntityManager();
}
示例2: setUp
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
@Before
protected void setUp() throws Exception {
super.setUp();
context2 = new DefaultCamelContext();
template2 = context2.createProducerTemplate();
ServiceHelper.startServices(template2, context2);
// add routes after CamelContext has been started
RouteBuilder routeBuilder = createRouteBuilderForSecondContext();
if (routeBuilder != null) {
context2.addRoutes(routeBuilder);
}
}
示例3: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
// inject CamelContext before starting
if (jsonMarshal instanceof CamelContextAware) {
((CamelContextAware) jsonMarshal).setCamelContext(camelContext);
}
if (jsonUnmarshal instanceof CamelContextAware) {
((CamelContextAware) jsonUnmarshal).setCamelContext(camelContext);
}
if (xmlMarshal instanceof CamelContextAware) {
((CamelContextAware) xmlMarshal).setCamelContext(camelContext);
}
if (xmlUnmarshal instanceof CamelContextAware) {
((CamelContextAware) xmlUnmarshal).setCamelContext(camelContext);
}
ServiceHelper.startServices(jsonMarshal, jsonUnmarshal, xmlMarshal, xmlUnmarshal);
}
示例4: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
if (binding == null) {
binding = CamelContextHelper.mandatoryLookup(getCamelContext(), bindingName, Binding.class);
}
if (delegate == null) {
delegate = getMandatoryEndpoint(getCamelContext(), delegateUri);
}
// inject CamelContext
if (binding instanceof CamelContextAware) {
((CamelContextAware) binding).setCamelContext(getCamelContext());
}
ServiceHelper.startServices(delegate, binding);
super.doStart();
}
示例5: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStart() throws Exception {
if (aggregationStrategy == null) {
aggregationStrategy = defaultAggregationStrategy();
}
if (producerCache == null) {
if (cacheSize < 0) {
producerCache = new EmptyProducerCache(this, camelContext);
LOG.debug("Enricher {} is not using ProducerCache", this);
} else if (cacheSize == 0) {
producerCache = new ProducerCache(this, camelContext);
LOG.debug("Enricher {} using ProducerCache with default cache size", this);
} else {
producerCache = new ProducerCache(this, camelContext, cacheSize);
LOG.debug("Enricher {} using ProducerCache with cacheSize={}", this, cacheSize);
}
}
ServiceHelper.startServices(producerCache, aggregationStrategy);
}
示例6: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
ServiceHelper.startServices(output, outputAsync, deadLetter);
// determine if redeliver is enabled or not
redeliveryEnabled = determineIfRedeliveryIsEnabled();
if (log.isTraceEnabled()) {
log.trace("Redelivery enabled: {} on error handler: {}", redeliveryEnabled, this);
}
// we only need thread pool if redelivery is enabled
if (redeliveryEnabled) {
if (executorService == null) {
// use default shared executor service
executorService = camelContext.getErrorHandlerExecutorService();
}
if (log.isDebugEnabled()) {
log.debug("Using ExecutorService: {} for redeliveries on error handler: {}", executorService, this);
}
}
// reset flag when starting
preparingShutdown = false;
redeliverySleepCounter.set(0);
}
示例7: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
if (dataFormat == null && name != null) {
dataFormat = getCamelContext().resolveDataFormat(name);
}
if (operation.equals("marshal")) {
marshal = new MarshalProcessor(dataFormat);
marshal.setCamelContext(getCamelContext());
} else {
unmarshal = new UnmarshalProcessor(dataFormat);
unmarshal.setCamelContext(getCamelContext());
}
ServiceHelper.startServices(dataFormat, marshal, unmarshal);
super.doStart();
}
示例8: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
jsonMarshalEndpoint = getCamelContext().getEndpoint("dataformat:json-jackson:marshal");
Objects.requireNonNull(jsonMarshalEndpoint, "jsonMarshalEndpoint");
jsonMarshalProducer = jsonMarshalEndpoint.createProducer();
Objects.requireNonNull(jsonMarshalProducer, "jsonMarshalProducer");
ServiceHelper.startServices(jsonMarshalEndpoint, jsonMarshalProducer);
super.doStart();
}
示例9: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStart() throws Exception {
ObjectHelper.notNull(configuration, "setNettyServerBootstrapConfiguration() must be called with a NettyServerBootstrapConfiguration instance", this);
// port must be set
if (configuration.getPort() <= 0) {
throw new IllegalArgumentException("Port must be configured on NettySharedHttpServerBootstrapConfiguration " + configuration);
}
// hostname must be set
if (ObjectHelper.isEmpty(configuration.getHost())) {
throw new IllegalArgumentException("Host must be configured on NettySharedHttpServerBootstrapConfiguration " + configuration);
}
LOG.debug("NettySharedHttpServer using configuration: {}", configuration);
// force using tcp as the underlying transport
configuration.setProtocol("tcp");
channelFactory = new HttpServerMultiplexChannelHandler();
channelFactory.init(configuration.getPort());
ChannelInitializer<Channel> pipelineFactory = new HttpServerSharedInitializerFactory(configuration, channelFactory, classResolver);
// thread factory and pattern
String port = Matcher.quoteReplacement("" + configuration.getPort());
String pattern = threadPattern;
pattern = pattern.replaceFirst("#port#", port);
ThreadFactory tf = new CamelThreadFactory(pattern, "NettySharedHttpServer", true);
// create bootstrap factory and disable compatible check as its shared among the consumers
bootstrapFactory = new HttpServerBootstrapFactory(channelFactory, false);
bootstrapFactory.init(tf, configuration, pipelineFactory);
ServiceHelper.startServices(channelFactory);
if (startServer) {
LOG.info("Starting NettySharedHttpServer on {}:{}", configuration.getHost(), configuration.getPort());
ServiceHelper.startServices(bootstrapFactory);
}
}
示例10: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStart() throws Exception {
if (extendedStatistics) {
int max = maxCacheSize == 0 ? CamelContextHelper.getMaximumCachePoolSize(camelContext) : maxCacheSize;
statistics = new DefaultEndpointUtilizationStatistics(max);
}
ServiceHelper.startServices(consumers.values());
}
示例11: setUp
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
public void setUp() throws Exception {
super.setUp();
context.setUseMDCLogging(true);
context2 = new DefaultCamelContext();
context2.setUseMDCLogging(true);
template2 = context2.createProducerTemplate();
ServiceHelper.startServices(template2, context2);
// add routes after CamelContext has been started
context2.addRoutes(createRouteBuilder2());
}
示例12: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
protected void doStart() throws Exception {
ObjectHelper.notNull(configuration, "setNettyServerBootstrapConfiguration() must be called with a NettyServerBootstrapConfiguration instance", this);
// port must be set
if (configuration.getPort() <= 0) {
throw new IllegalArgumentException("Port must be configured on NettySharedHttpServerBootstrapConfiguration " + configuration);
}
// hostname must be set
if (ObjectHelper.isEmpty(configuration.getHost())) {
throw new IllegalArgumentException("Host must be configured on NettySharedHttpServerBootstrapConfiguration " + configuration);
}
LOG.debug("NettySharedHttpServer using configuration: {}", configuration);
// force using tcp as the underlying transport
configuration.setProtocol("tcp");
channelFactory = new HttpServerMultiplexChannelHandler();
channelFactory.init(configuration.getPort());
ChannelPipelineFactory pipelineFactory = new HttpServerSharedPipelineFactory(configuration, channelFactory, classResolver);
// thread factory and pattern
String port = Matcher.quoteReplacement("" + configuration.getPort());
String pattern = threadPattern;
pattern = pattern.replaceFirst("#port#", port);
ThreadFactory tf = new CamelThreadFactory(pattern, "NettySharedHttpServer", true);
// create bootstrap factory and disable compatible check as its shared among the consumers
bootstrapFactory = new HttpServerBootstrapFactory(channelFactory, false);
bootstrapFactory.init(tf, configuration, pipelineFactory);
ServiceHelper.startServices(channelFactory);
if (startServer) {
LOG.info("Starting NettySharedHttpServer on {}:{}", configuration.getHost(), configuration.getPort());
ServiceHelper.startServices(bootstrapFactory);
}
}
示例13: setUp
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
@Before
protected void setUp() throws Exception {
super.setUp();
context2 = new DefaultCamelContext();
template2 = context2.createProducerTemplate();
ServiceHelper.startServices(template2, context2);
// add routes after CamelContext has been started
RouteBuilder routeBuilder = createRouteBuilderForSecondContext();
if (routeBuilder != null) {
context2.addRoutes(routeBuilder);
}
}
示例14: setUp
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
template = camelContext.createProducerTemplate();
ServiceHelper.startServices(template, camelContext);
Endpoint value = camelContext.getEndpoint(getEndpointUri());
assertNotNull("Could not find endpoint!", value);
assertTrue("Should be a JPA endpoint but was: " + value, value instanceof JpaEndpoint);
endpoint = (JpaEndpoint)value;
transactionTemplate = endpoint.createTransactionTemplate();
entityManager = endpoint.createEntityManager();
}
示例15: doStart
import org.apache.camel.util.ServiceHelper; //导入方法依赖的package包/类
@Override
protected void doStart() throws Exception {
super.doStart();
LOG.debug("Netty consumer binding to: {}", configuration.getAddress());
if (nettyServerBootstrapFactory == null) {
// setup pipeline factory
ServerPipelineFactory pipelineFactory;
ServerPipelineFactory factory = configuration.getServerPipelineFactory();
if (factory != null) {
pipelineFactory = factory.createPipelineFactory(this);
} else {
pipelineFactory = new DefaultServerPipelineFactory(this);
}
if (isTcp()) {
if (configuration.isClientMode()) {
nettyServerBootstrapFactory = new ClientModeTCPNettyServerBootstrapFactory();
} else {
nettyServerBootstrapFactory = new SingleTCPNettyServerBootstrapFactory();
}
} else {
nettyServerBootstrapFactory = new SingleUDPNettyServerBootstrapFactory();
}
nettyServerBootstrapFactory.init(context, configuration, pipelineFactory);
}
ServiceHelper.startServices(nettyServerBootstrapFactory);
LOG.info("Netty consumer bound to: " + configuration.getAddress());
}