use of com.alipay.sofa.runtime.spi.client.ClientFactoryInternal in project sofa-boot by sofastack.
the class ComponentManagerImpl method shutdown.
@Override
public void shutdown() {
if (SofaRuntimeProperties.isSkipAllComponentShutdown(appClassLoader)) {
return;
}
List<ComponentInfo> elems = new ArrayList<>(registry.values());
// shutdown spring contexts first
List<ComponentInfo> springContextComponents = elems.stream().filter(componentInfo -> componentInfo instanceof SpringContextComponent).collect(Collectors.toList());
for (ComponentInfo ri : springContextComponents) {
try {
unregister(ri);
} catch (Throwable t) {
SofaLogger.error(ErrorCode.convert("01-03001", ri.getName()), t);
}
}
if (!springContextComponents.isEmpty()) {
elems.removeAll(springContextComponents);
}
if (SofaRuntimeProperties.isSkipCommonComponentShutdown(appClassLoader)) {
return;
}
// shutdown remaining components
for (ComponentInfo ri : elems) {
try {
unregister(ri);
} catch (Throwable t) {
SofaLogger.error(ErrorCode.convert("01-03001", ri.getName()), t);
}
}
try {
if (registry != null) {
registry.clear();
}
if (resolvedRegistry != null) {
resolvedRegistry.clear();
}
clientFactoryInternal = null;
} catch (Throwable t) {
SofaLogger.error(ErrorCode.convert("01-03000"), t);
}
}
use of com.alipay.sofa.runtime.spi.client.ClientFactoryInternal in project sofa-boot by sofastack.
the class SofaRuntimeAutoConfiguration method sofaRuntimeManager.
@Bean
@ConditionalOnMissingBean
public static SofaRuntimeManager sofaRuntimeManager(Environment environment, BindingConverterFactory bindingConverterFactory, BindingAdapterFactory bindingAdapterFactory) {
ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl();
SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager(environment.getProperty("spring.application.name"), Thread.currentThread().getContextClassLoader(), clientFactoryInternal);
sofaRuntimeManager.getComponentManager().registerComponentClient(ReferenceClient.class, new ReferenceClientImpl(sofaRuntimeManager.getSofaRuntimeContext(), bindingConverterFactory, bindingAdapterFactory));
sofaRuntimeManager.getComponentManager().registerComponentClient(ServiceClient.class, new ServiceClientImpl(sofaRuntimeManager.getSofaRuntimeContext(), bindingConverterFactory, bindingAdapterFactory));
SofaFramework.registerSofaRuntimeManager(sofaRuntimeManager);
return sofaRuntimeManager;
}
use of com.alipay.sofa.runtime.spi.client.ClientFactoryInternal in project sofa-boot by sofastack.
the class SofaStartupIsleAutoConfiguration method sofaRuntimeManager.
@Bean(destroyMethod = "")
@ConditionalOnMissingBean
public static SofaRuntimeManager sofaRuntimeManager() {
ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl();
SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager("IsleStageCostTest", Thread.currentThread().getContextClassLoader(), clientFactoryInternal);
SofaFramework.registerSofaRuntimeManager(sofaRuntimeManager);
return sofaRuntimeManager;
}
use of com.alipay.sofa.runtime.spi.client.ClientFactoryInternal in project sofa-boot by alipay.
the class ComponentManagerImpl method shutdown.
@Override
public void shutdown() {
if (SofaRuntimeProperties.isSkipAllComponentShutdown(appClassLoader)) {
return;
}
List<ComponentInfo> elems = new ArrayList<>(registry.values());
// shutdown spring contexts first
List<ComponentInfo> springContextComponents = elems.stream().filter(componentInfo -> componentInfo instanceof SpringContextComponent).collect(Collectors.toList());
for (ComponentInfo ri : springContextComponents) {
try {
unregister(ri);
} catch (Throwable t) {
SofaLogger.error(ErrorCode.convert("01-03001", ri.getName()), t);
}
}
if (!springContextComponents.isEmpty()) {
elems.removeAll(springContextComponents);
}
if (SofaRuntimeProperties.isSkipCommonComponentShutdown(appClassLoader)) {
return;
}
// shutdown remaining components
for (ComponentInfo ri : elems) {
try {
unregister(ri);
} catch (Throwable t) {
SofaLogger.error(ErrorCode.convert("01-03001", ri.getName()), t);
}
}
try {
if (registry != null) {
registry.clear();
}
if (resolvedRegistry != null) {
resolvedRegistry.clear();
}
clientFactoryInternal = null;
} catch (Throwable t) {
SofaLogger.error(ErrorCode.convert("01-03000"), t);
}
}
use of com.alipay.sofa.runtime.spi.client.ClientFactoryInternal in project sofa-boot by alipay.
the class SofaStartupIsleAutoConfiguration method sofaRuntimeManager.
@Bean(destroyMethod = "")
@ConditionalOnMissingBean
public static SofaRuntimeManager sofaRuntimeManager() {
ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl();
SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager("IsleStageCostTest", Thread.currentThread().getContextClassLoader(), clientFactoryInternal);
SofaFramework.registerSofaRuntimeManager(sofaRuntimeManager);
return sofaRuntimeManager;
}
Aggregations