本文整理汇总了Java中org.apache.camel.spi.LifecycleStrategy.onServiceAdd方法的典型用法代码示例。如果您正苦于以下问题:Java LifecycleStrategy.onServiceAdd方法的具体用法?Java LifecycleStrategy.onServiceAdd怎么用?Java LifecycleStrategy.onServiceAdd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.spi.LifecycleStrategy
的用法示例。
在下文中一共展示了LifecycleStrategy.onServiceAdd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testService
import org.apache.camel.spi.LifecycleStrategy; //导入方法依赖的package包/类
public void testService() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
// must enable always as CamelContext has been started
// and we add the service manually below
context.getManagementStrategy().getManagementAgent().setRegisterAlways(true);
MyService service = new MyService();
for (LifecycleStrategy strategy : context.getLifecycleStrategies()) {
strategy.onServiceAdd(context, service, null);
}
MBeanServer mbeanServer = getMBeanServer();
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=services,*"), null);
assertEquals(9, set.size());
}
示例2: testNonManagedService
import org.apache.camel.spi.LifecycleStrategy; //导入方法依赖的package包/类
public void testNonManagedService() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
// must enable always as CamelContext has been started
// and we add the service manually below
context.getManagementStrategy().getManagementAgent().setRegisterAlways(true);
MyNonService service = new MyNonService();
for (LifecycleStrategy strategy : context.getLifecycleStrategies()) {
strategy.onServiceAdd(context, service, null);
}
MBeanServer mbeanServer = getMBeanServer();
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=services,*"), null);
assertEquals(8, set.size());
}
示例3: startChildService
import org.apache.camel.spi.LifecycleStrategy; //导入方法依赖的package包/类
protected void startChildService(Route route, List<Service> services) throws Exception {
for (Service service : services) {
LOG.debug("Starting child service on route: {} -> {}", route.getId(), service);
for (LifecycleStrategy strategy : camelContext.getLifecycleStrategies()) {
strategy.onServiceAdd(camelContext, service, route);
}
ServiceHelper.startService(service);
addChildService(service);
}
}
示例4: doAddService
import org.apache.camel.spi.LifecycleStrategy; //导入方法依赖的package包/类
private void doAddService(Object object, boolean stopOnShutdown, boolean forceStart) throws Exception {
// inject CamelContext
if (object instanceof CamelContextAware) {
CamelContextAware aware = (CamelContextAware) object;
aware.setCamelContext(this);
}
if (object instanceof Service) {
Service service = (Service) object;
for (LifecycleStrategy strategy : lifecycleStrategies) {
if (service instanceof Endpoint) {
// use specialized endpoint add
strategy.onEndpointAdd((Endpoint) service);
} else {
strategy.onServiceAdd(this, service, null);
}
}
if (!forceStart) {
// now start the service (and defer starting if CamelContext is starting up itself)
deferStartService(object, stopOnShutdown);
} else {
// only add to services to close if its a singleton
// otherwise we could for example end up with a lot of prototype scope endpoints
boolean singleton = true; // assume singleton by default
if (object instanceof IsSingleton) {
singleton = ((IsSingleton) service).isSingleton();
}
// do not add endpoints as they have their own list
if (singleton && !(service instanceof Endpoint)) {
// only add to list of services to stop if its not already there
if (stopOnShutdown && !hasService(service)) {
servicesToStop.add(service);
}
}
ServiceHelper.startService(service);
}
}
}