Search in sources :

Example 11 with SofaRuntimeManager

use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager in project sofa-boot by alipay.

the class DynamicJvmServiceProxyFinder method afterBizUninstall.

public void afterBizUninstall(Biz biz) {
    if (!SofaRuntimeProperties.isDynamicJvmServiceCacheEnable()) {
        return;
    }
    for (SofaRuntimeManager runtimeManager : SofaFramework.getRuntimeSet()) {
        if (runtimeManager.getAppClassLoader().equals(biz.getBizClassLoader())) {
            for (ComponentInfo componentInfo : runtimeManager.getComponentManager().getComponents()) {
                if (componentInfo instanceof ServiceComponent) {
                    ServiceComponent serviceComponent = (ServiceComponent) componentInfo;
                    String uniqueName = getUniqueName(serviceComponent.getService());
                    JvmServiceTargetHabitat jvmServiceTargetHabitat = jvmServiceTargetHabitats.get(uniqueName);
                    if (jvmServiceTargetHabitat != null) {
                        jvmServiceTargetHabitat.removeServiceComponent(biz.getBizVersion());
                    }
                }
            }
        }
    }
}
Also used : ServiceComponent(com.alipay.sofa.runtime.service.component.ServiceComponent) ComponentInfo(com.alipay.sofa.runtime.spi.component.ComponentInfo) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager)

Example 12 with SofaRuntimeManager

use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager in project sofa-boot by alipay.

the class DynamicJvmServiceProxyFinder method afterBizStartup.

public void afterBizStartup(Biz biz) {
    if (!SofaRuntimeProperties.isDynamicJvmServiceCacheEnable()) {
        return;
    }
    // The overhead is acceptable as this only happens after biz's successful installation
    for (SofaRuntimeManager runtimeManager : SofaFramework.getRuntimeSet()) {
        if (runtimeManager.getAppClassLoader().equals(biz.getBizClassLoader())) {
            for (ComponentInfo componentInfo : runtimeManager.getComponentManager().getComponents()) {
                if (componentInfo instanceof ServiceComponent) {
                    ServiceComponent serviceComponent = (ServiceComponent) componentInfo;
                    String uniqueName = getUniqueName(serviceComponent.getService());
                    jvmServiceTargetHabitats.computeIfAbsent(uniqueName, e -> new JvmServiceTargetHabitat(biz.getBizName()));
                    JvmServiceTargetHabitat jvmServiceTargetHabitat = jvmServiceTargetHabitats.get(uniqueName);
                    jvmServiceTargetHabitat.addServiceComponent(biz.getBizVersion(), serviceComponent);
                }
            }
        }
    }
}
Also used : ServiceComponent(com.alipay.sofa.runtime.service.component.ServiceComponent) ComponentInfo(com.alipay.sofa.runtime.spi.component.ComponentInfo) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager)

Example 13 with SofaRuntimeManager

use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager 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;
}
Also used : ClientFactoryImpl(com.alipay.sofa.runtime.client.impl.ClientFactoryImpl) ClientFactoryInternal(com.alipay.sofa.runtime.spi.client.ClientFactoryInternal) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 14 with SofaRuntimeManager

use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager in project sofa-boot by alipay.

the class RuntimeConfiguration method sofaRuntimeManager.

@Bean
@ConditionalOnMissingBean
public static SofaRuntimeManager sofaRuntimeManager(Environment environment, BindingConverterFactory bindingConverterFactory, BindingAdapterFactory bindingAdapterFactory) {
    String appName = environment.getProperty(SofaBootConstants.APP_NAME_KEY);
    ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl();
    SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager(appName, 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;
}
Also used : ClientFactoryImpl(com.alipay.sofa.runtime.client.impl.ClientFactoryImpl) ClientFactoryInternal(com.alipay.sofa.runtime.spi.client.ClientFactoryInternal) ReferenceClientImpl(com.alipay.sofa.runtime.service.client.ReferenceClientImpl) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ServiceClientImpl(com.alipay.sofa.runtime.service.client.ServiceClientImpl) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 15 with SofaRuntimeManager

use of com.alipay.sofa.runtime.spi.component.SofaRuntimeManager in project sofa-boot by alipay.

the class RuntimeTestConfiguration method sofaRuntimeManager.

@Bean
@ConditionalOnMissingBean
public static SofaRuntimeManager sofaRuntimeManager(@Value("${spring.application.name}") String appName, BindingConverterFactory bindingConverterFactory, BindingAdapterFactory bindingAdapterFactory) {
    ClientFactoryInternal clientFactoryInternal = new ClientFactoryImpl();
    SofaRuntimeManager sofaRuntimeManager = new StandardSofaRuntimeManager(appName, 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;
}
Also used : ClientFactoryImpl(com.alipay.sofa.runtime.client.impl.ClientFactoryImpl) ClientFactoryInternal(com.alipay.sofa.runtime.spi.client.ClientFactoryInternal) ReferenceClientImpl(com.alipay.sofa.runtime.service.client.ReferenceClientImpl) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ServiceClientImpl(com.alipay.sofa.runtime.service.client.ServiceClientImpl) SofaRuntimeManager(com.alipay.sofa.runtime.spi.component.SofaRuntimeManager) StandardSofaRuntimeManager(com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

SofaRuntimeManager (com.alipay.sofa.runtime.spi.component.SofaRuntimeManager)33 StandardSofaRuntimeManager (com.alipay.sofa.runtime.component.impl.StandardSofaRuntimeManager)15 ClientFactoryImpl (com.alipay.sofa.runtime.client.impl.ClientFactoryImpl)11 ClientFactoryInternal (com.alipay.sofa.runtime.spi.client.ClientFactoryInternal)11 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)10 Bean (org.springframework.context.annotation.Bean)10 ReferenceClientImpl (com.alipay.sofa.runtime.service.client.ReferenceClientImpl)9 ServiceClientImpl (com.alipay.sofa.runtime.service.client.ServiceClientImpl)9 ServiceComponent (com.alipay.sofa.runtime.service.component.ServiceComponent)8 Biz (com.alipay.sofa.ark.spi.model.Biz)6 Test (org.junit.Test)6 ComponentHealthChecker (com.alipay.sofa.healthcheck.impl.ComponentHealthChecker)4 JvmBinding (com.alipay.sofa.runtime.service.binding.JvmBinding)4 ComponentInfo (com.alipay.sofa.runtime.spi.component.ComponentInfo)4 SofaRuntimeContext (com.alipay.sofa.runtime.spi.component.SofaRuntimeContext)4 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)4 Map (java.util.Map)4 ApplicationRuntimeModel (com.alipay.sofa.isle.ApplicationRuntimeModel)2 DefaultModuleDeploymentValidator (com.alipay.sofa.isle.deployment.impl.DefaultModuleDeploymentValidator)2