use of com.alipay.sofa.ark.spi.service.ArkService in project sofa-ark by alipay.
the class ArkServiceContainer method stop.
/**
* Stop Ark Service Container
* @throws ArkRuntimeException
* @since 0.1.0
*/
public void stop() throws ArkRuntimeException {
if (stopped.compareAndSet(false, true)) {
LOGGER.info("Begin to stop ArkServiceContainer");
ClassLoader oldClassLoader = ClassLoaderUtils.pushContextClassLoader(getClass().getClassLoader());
try {
Collections.reverse(arkServiceList);
for (ArkService arkService : arkServiceList) {
LOGGER.info(String.format("Dispose service: %s", arkService.getClass().getName()));
arkService.dispose();
}
LOGGER.info("Finish to stop ArkServiceContainer");
} finally {
ClassLoaderUtils.popContextClassLoader(oldClassLoader);
}
}
}
use of com.alipay.sofa.ark.spi.service.ArkService in project sofa-ark by alipay.
the class ArkServiceContainer method start.
/**
* Start Ark Service Container
* @throws ArkRuntimeException
* @since 0.1.0
*/
public void start() throws ArkRuntimeException {
if (started.compareAndSet(false, true)) {
ClassLoader oldClassLoader = ClassLoaderUtils.pushContextClassLoader(getClass().getClassLoader());
try {
LOGGER.info("Begin to start ArkServiceContainer");
injector = Guice.createInjector(findServiceModules());
for (Binding<ArkService> binding : injector.findBindingsByType(new TypeLiteral<ArkService>() {
})) {
arkServiceList.add(binding.getProvider().get());
}
Collections.sort(arkServiceList, new OrderComparator());
for (ArkService arkService : arkServiceList) {
LOGGER.info(String.format("Init Service: %s", arkService.getClass().getName()));
arkService.init();
}
ArkServiceContainerHolder.setContainer(this);
ArkClient.setBizFactoryService(getService(BizFactoryService.class));
ArkClient.setBizManagerService(getService(BizManagerService.class));
ArkClient.setInjectionService(getService(InjectionService.class));
ArkClient.setEventAdminService(getService(EventAdminService.class));
ArkClient.setArguments(arguments);
LOGGER.info("Finish to start ArkServiceContainer");
} finally {
ClassLoaderUtils.popContextClassLoader(oldClassLoader);
}
}
}
Aggregations