Search in sources :

Example 6 with Implementation

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

the class ServiceFactoryBean method doAfterPropertiesSet.

@Override
protected void doAfterPropertiesSet() {
    if (!apiType && hasSofaServiceAnnotation()) {
        throw new ServiceRuntimeException(ErrorCode.convert("01-00103", beanId, ref.getClass()));
    }
    Implementation implementation = new DefaultImplementation();
    implementation.setTarget(ref);
    service = buildService();
    // default add jvm binding and service jvm binding should set serialize as true
    if (bindings.size() == 0) {
        JvmBindingParam jvmBindingParam = new JvmBindingParam().setSerialize(true);
        bindings.add(new JvmBinding().setJvmBindingParam(jvmBindingParam));
    }
    for (Binding binding : bindings) {
        service.addBinding(binding);
    }
    ComponentInfo componentInfo = new ServiceComponent(implementation, service, bindingAdapterFactory, sofaRuntimeContext);
    componentInfo.setApplicationContext(applicationContext);
    sofaRuntimeContext.getComponentManager().register(componentInfo);
}
Also used : JvmBinding(com.alipay.sofa.runtime.service.binding.JvmBinding) Binding(com.alipay.sofa.runtime.spi.binding.Binding) ServiceComponent(com.alipay.sofa.runtime.service.component.ServiceComponent) DefaultImplementation(com.alipay.sofa.runtime.spi.component.DefaultImplementation) ComponentInfo(com.alipay.sofa.runtime.spi.component.ComponentInfo) DefaultImplementation(com.alipay.sofa.runtime.spi.component.DefaultImplementation) Implementation(com.alipay.sofa.runtime.spi.component.Implementation) ServiceRuntimeException(com.alipay.sofa.runtime.api.ServiceRuntimeException) JvmBindingParam(com.alipay.sofa.runtime.service.binding.JvmBindingParam) JvmBinding(com.alipay.sofa.runtime.service.binding.JvmBinding)

Example 7 with Implementation

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

the class ExtensionClientImpl method publishExtensionPoint.

@Override
public void publishExtensionPoint(ExtensionPointParam extensionPointParam) {
    Assert.notNull(extensionPointParam, "extensionPointParam can not be null.");
    Assert.notNull(extensionPointParam.getName(), "Extension point name can not be null.");
    Assert.notNull(extensionPointParam.getContributionClass(), "Extension point contribution can not be null.");
    Assert.notNull(extensionPointParam.getTarget(), "Extension point target can not be null.");
    ExtensionPoint extensionPoint = new ExtensionPointImpl(extensionPointParam.getName(), extensionPointParam.getContributionClass());
    Implementation implementation = new DefaultImplementation(extensionPointParam.getTargetName());
    implementation.setTarget(extensionPointParam.getTarget());
    ComponentInfo extensionPointComponent = new ExtensionPointComponent(extensionPoint, sofaRuntimeContext, implementation);
    sofaRuntimeContext.getComponentManager().register(extensionPointComponent);
}
Also used : ExtensionPoint(com.alipay.sofa.service.api.component.ExtensionPoint) ExtensionPointImpl(com.alipay.sofa.runtime.ext.component.ExtensionPointImpl) DefaultImplementation(com.alipay.sofa.runtime.spi.component.DefaultImplementation) ComponentInfo(com.alipay.sofa.runtime.spi.component.ComponentInfo) ExtensionPointComponent(com.alipay.sofa.runtime.ext.component.ExtensionPointComponent) DefaultImplementation(com.alipay.sofa.runtime.spi.component.DefaultImplementation) Implementation(com.alipay.sofa.runtime.spi.component.Implementation)

Example 8 with Implementation

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

the class ExtensionPointFactoryBean method publishAsNuxeoExtensionPoint.

private void publishAsNuxeoExtensionPoint(Class<?> beanClass) throws Exception {
    Assert.notNull(beanClass, "Service must be implement!");
    ExtensionPointBuilder extensionPointBuilder = ExtensionPointBuilder.genericExtensionPoint(this.name, applicationContext.getClassLoader());
    if (this.contribution != null && this.contribution.length != 0) {
        for (int i = 0; i < contribution.length; i++) {
            extensionPointBuilder.addContribution(contribution[i]);
        }
    }
    Assert.hasLength(beanName, "required property 'beanName' has not been set for creating implementation");
    Assert.notNull(applicationContext, "required property 'applicationContext' has not been set for creating implementation");
    Implementation implementation = new SpringImplementationImpl(targetBeanName, applicationContext);
    ComponentInfo extensionPointComponent = new ExtensionPointComponent(extensionPointBuilder.getExtensionPoint(), sofaRuntimeContext, implementation);
    extensionPointComponent.setApplicationContext(applicationContext);
    sofaRuntimeContext.getComponentManager().register(extensionPointComponent);
}
Also used : ComponentInfo(com.alipay.sofa.runtime.spi.component.ComponentInfo) ExtensionPointComponent(com.alipay.sofa.runtime.ext.component.ExtensionPointComponent) Implementation(com.alipay.sofa.runtime.spi.component.Implementation) SpringImplementationImpl(com.alipay.sofa.runtime.spi.spring.SpringImplementationImpl)

Example 9 with Implementation

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

the class SpringContextInstallStage method publishContextAsSofaComponent.

private void publishContextAsSofaComponent(DeploymentDescriptor deployment, ApplicationRuntimeModel application, ApplicationContext context) {
    ComponentName componentName = ComponentNameFactory.createComponentName(SpringContextComponent.SPRING_COMPONENT_TYPE, deployment.getModuleName());
    Implementation implementation = new SpringContextImplementation(context);
    ComponentInfo componentInfo = new SpringContextComponent(componentName, implementation, application.getSofaRuntimeContext());
    application.getSofaRuntimeContext().getComponentManager().register(componentInfo);
}
Also used : SpringContextImplementation(com.alipay.sofa.runtime.spring.SpringContextImplementation) ComponentName(com.alipay.sofa.runtime.api.component.ComponentName) ComponentInfo(com.alipay.sofa.runtime.spi.component.ComponentInfo) SpringContextComponent(com.alipay.sofa.runtime.spring.SpringContextComponent) SpringContextImplementation(com.alipay.sofa.runtime.spring.SpringContextImplementation) Implementation(com.alipay.sofa.runtime.spi.component.Implementation)

Example 10 with Implementation

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

the class ExtensionClientImpl method publishExtensionPoint.

@Override
public void publishExtensionPoint(ExtensionPointParam extensionPointParam) {
    Assert.notNull(extensionPointParam, "extensionPointParam can not be null.");
    Assert.notNull(extensionPointParam.getName(), "Extension point name can not be null.");
    Assert.notNull(extensionPointParam.getContributionClass(), "Extension point contribution can not be null.");
    Assert.notNull(extensionPointParam.getTarget(), "Extension point target can not be null.");
    ExtensionPoint extensionPoint = new ExtensionPointImpl(extensionPointParam.getName(), extensionPointParam.getContributionClass());
    Implementation implementation = new DefaultImplementation(extensionPointParam.getTargetName());
    implementation.setTarget(extensionPointParam.getTarget());
    ComponentInfo extensionPointComponent = new ExtensionPointComponent(extensionPoint, sofaRuntimeContext, implementation);
    sofaRuntimeContext.getComponentManager().register(extensionPointComponent);
}
Also used : ExtensionPoint(com.alipay.sofa.service.api.component.ExtensionPoint) ExtensionPointImpl(com.alipay.sofa.runtime.ext.component.ExtensionPointImpl) DefaultImplementation(com.alipay.sofa.runtime.spi.component.DefaultImplementation) ComponentInfo(com.alipay.sofa.runtime.spi.component.ComponentInfo) ExtensionPointComponent(com.alipay.sofa.runtime.ext.component.ExtensionPointComponent) DefaultImplementation(com.alipay.sofa.runtime.spi.component.DefaultImplementation) Implementation(com.alipay.sofa.runtime.spi.component.Implementation)

Aggregations

ComponentInfo (com.alipay.sofa.runtime.spi.component.ComponentInfo)11 Implementation (com.alipay.sofa.runtime.spi.component.Implementation)11 DefaultImplementation (com.alipay.sofa.runtime.spi.component.DefaultImplementation)6 ServiceRuntimeException (com.alipay.sofa.runtime.api.ServiceRuntimeException)5 JvmBinding (com.alipay.sofa.runtime.service.binding.JvmBinding)5 ServiceComponent (com.alipay.sofa.runtime.service.component.ServiceComponent)5 ExtensionPointComponent (com.alipay.sofa.runtime.ext.component.ExtensionPointComponent)4 Binding (com.alipay.sofa.runtime.spi.binding.Binding)4 Service (com.alipay.sofa.runtime.service.component.Service)3 ServiceImpl (com.alipay.sofa.runtime.service.component.impl.ServiceImpl)3 SpringImplementationImpl (com.alipay.sofa.runtime.spi.spring.SpringImplementationImpl)3 BindingParam (com.alipay.sofa.runtime.api.client.param.BindingParam)2 ComponentName (com.alipay.sofa.runtime.api.component.ComponentName)2 ExtensionPointImpl (com.alipay.sofa.runtime.ext.component.ExtensionPointImpl)2 JvmBindingParam (com.alipay.sofa.runtime.service.binding.JvmBindingParam)2 BindingConverter (com.alipay.sofa.runtime.spi.service.BindingConverter)2 BindingConverterContext (com.alipay.sofa.runtime.spi.service.BindingConverterContext)2 SpringContextComponent (com.alipay.sofa.runtime.spring.SpringContextComponent)2 SpringContextImplementation (com.alipay.sofa.runtime.spring.SpringContextImplementation)2 ExtensionPoint (com.alipay.sofa.service.api.component.ExtensionPoint)2