Search in sources :

Example 11 with ServiceRuntimeException

use of com.alipay.sofa.runtime.api.ServiceRuntimeException in project sofa-boot by alipay.

the class ServiceComponent method deactivate.

@Override
public void deactivate() throws ServiceRuntimeException {
    Object target = service.getTarget();
    if (target == null) {
        throw new ServiceRuntimeException("Must contains the target object whiling registering Service.");
    }
    if (service.hasBinding()) {
        Set<Binding> bindings = service.getBindings();
        for (Binding binding : bindings) {
            BindingAdapter<Binding> bindingAdapter = this.bindingAdapterFactory.getBindingAdapter(binding.getBindingType());
            if (bindingAdapter == null) {
                throw new ServiceRuntimeException("Can't find BindingAdapter of type " + binding.getBindingType() + " while deactivate service " + service + ".");
            }
            SofaLogger.info(" <<Pre un-out Binding [{0}] Begins - {1}.", binding.getBindingType(), service);
            bindingAdapter.preUnoutBinding(service, binding, target, getContext());
            SofaLogger.info(" <<Pre un-out Binding [{0}] Ends - {1}.", binding.getBindingType(), service);
        }
    }
    super.deactivate();
}
Also used : Binding(com.alipay.sofa.runtime.spi.binding.Binding) ServiceRuntimeException(com.alipay.sofa.runtime.api.ServiceRuntimeException)

Aggregations

ServiceRuntimeException (com.alipay.sofa.runtime.api.ServiceRuntimeException)11 Binding (com.alipay.sofa.runtime.spi.binding.Binding)9 JvmBinding (com.alipay.sofa.runtime.service.binding.JvmBinding)6 ComponentInfo (com.alipay.sofa.runtime.spi.component.ComponentInfo)4 ServiceComponent (com.alipay.sofa.runtime.service.component.ServiceComponent)3 DefaultImplementation (com.alipay.sofa.runtime.spi.component.DefaultImplementation)3 Implementation (com.alipay.sofa.runtime.spi.component.Implementation)3 BindingParam (com.alipay.sofa.runtime.api.client.param.BindingParam)2 Service (com.alipay.sofa.runtime.service.component.Service)2 ServiceImpl (com.alipay.sofa.runtime.service.component.impl.ServiceImpl)2 BindingConverter (com.alipay.sofa.runtime.spi.service.BindingConverter)2 BindingConverterContext (com.alipay.sofa.runtime.spi.service.BindingConverterContext)2 SofaService (com.alipay.sofa.runtime.api.annotation.SofaService)1 Property (com.alipay.sofa.runtime.api.component.Property)1 Reference (com.alipay.sofa.runtime.service.component.Reference)1 ReferenceComponent (com.alipay.sofa.runtime.service.component.ReferenceComponent)1 ReferenceImpl (com.alipay.sofa.runtime.service.component.impl.ReferenceImpl)1 ComponentManager (com.alipay.sofa.runtime.spi.component.ComponentManager)1 SpringImplementationImpl (com.alipay.sofa.runtime.spi.spring.SpringImplementationImpl)1 StringWriter (java.io.StringWriter)1