class RpcBindingAdapter implements BindingAdapter<RpcBinding> {

    /**
     * pre out binding
     *
     * @param contract           binding contract
     * @param binding            binding object
     * @param target             binding target
     * @param sofaRuntimeContext sofa runtime context
     */
    @Override
    public void preOutBinding(Object contract, RpcBinding binding, Object target,
                              SofaRuntimeContext sofaRuntimeContext) {<FILL_FUNCTION_BODY>}

    /**
     * out binding, out binding means provide service
     *
     * @param contract           binding contract
     * @param binding            binding object
     * @param target             binding target
     * @param sofaRuntimeContext sofa runtime context
     * @return binding result
     */
    @Override
    public Object outBinding(Object contract, RpcBinding binding, Object target,
                             SofaRuntimeContext sofaRuntimeContext) {

        ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager()
            .getRootApplicationContext();
        ProviderConfigContainer providerConfigContainer = applicationContext
            .getBean(ProviderConfigContainer.class);
        ProcessorContainer processorContainer = applicationContext
            .getBean(ProcessorContainer.class);

        String uniqueName = providerConfigContainer.createUniqueName((Contract) contract, binding);
        ProviderConfig providerConfig = providerConfigContainer.getProviderConfig(uniqueName);
        processorContainer.processorProvider(providerConfig);

        if (providerConfig == null) {
            throw new ServiceRuntimeException(LogCodes.getLog(
                LogCodes.INFO_SERVICE_METADATA_IS_NULL, uniqueName));
        }

        try {
            providerConfig.export();
        } catch (Exception e) {
            throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_PUBLISH_FAIL), e);
        }

        if (providerConfigContainer.isAllowPublish()) {
            providerConfig.setRegister(true);
            List<RegistryConfig> registrys = providerConfig.getRegistry();
            for (RegistryConfig registryConfig : registrys) {
                Registry registry = RegistryFactory.getRegistry(registryConfig);
                registry.init();
                registry.start();
                registry.register(providerConfig);
            }
        }
        return Boolean.TRUE;
    }

    /**
     * pre unout binding
     *
     * @param contract           binding contract
     * @param binding            binding object
     * @param target             binding target
     * @param sofaRuntimeContext sofa runtime context
     */
    @Override
    public void preUnoutBinding(Object contract, RpcBinding binding, Object target,
                                SofaRuntimeContext sofaRuntimeContext) {

        ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager()
            .getRootApplicationContext();

        ProviderConfigContainer providerConfigContainer = applicationContext
            .getBean(ProviderConfigContainer.class);
        String key = providerConfigContainer.createUniqueName((Contract) contract, binding);
        ProviderConfig providerConfig = providerConfigContainer.getProviderConfig(key);
        try {
            providerConfig.unExport();
        } catch (Exception e) {
            throw new ServiceRuntimeException(
                LogCodes.getLog(LogCodes.ERROR_PROXY_PRE_UNPUBLISH_FAIL), e);
        }
    }

    /**
     * post unout binding
     *
     * @param contract           binding contract
     * @param binding            binding object
     * @param target             binding target
     * @param sofaRuntimeContext sofa runtime context
     */
    @Override
    public void postUnoutBinding(Object contract, RpcBinding binding, Object target,
                                 SofaRuntimeContext sofaRuntimeContext) {

        ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager()
            .getRootApplicationContext();
        ProviderConfigContainer providerConfigContainer = applicationContext
            .getBean(ProviderConfigContainer.class);
        String key = providerConfigContainer.createUniqueName((Contract) contract, binding);
        try {
            providerConfigContainer.removeProviderConfig(key);
        } catch (Exception e) {
            throw new ServiceRuntimeException(
                LogCodes.getLog(LogCodes.ERROR_PROXY_POST_UNPUBLISH_FAIL), e);
        }
    }

    /**
     * in binding, in binding means reference service
     *
     * @param contract           binding contract
     * @param binding            binding object
     * @param sofaRuntimeContext sofa runtime context
     */
    @Override
    public Object inBinding(Object contract, RpcBinding binding,
                            SofaRuntimeContext sofaRuntimeContext) {

        ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager()
            .getRootApplicationContext();
        ConsumerConfigHelper consumerConfigHelper = applicationContext
            .getBean(ConsumerConfigHelper.class);
        ConsumerConfigContainer consumerConfigContainer = applicationContext
            .getBean(ConsumerConfigContainer.class);
        ProcessorContainer processorContainer = applicationContext
            .getBean(ProcessorContainer.class);

        ConsumerConfig consumerConfig = consumerConfigHelper.getConsumerConfig((Contract) contract,
            binding);
        processorContainer.processorConsumer(consumerConfig);

        if (MockMode.LOCAL.equalsIgnoreCase(binding.getRpcBindingParam().getMockMode())) {
            consumerConfig.setMockRef(consumerConfigHelper.getMockRef(binding, applicationContext));
        }

        consumerConfigContainer.addConsumerConfig(binding, consumerConfig);

        try {
            Object result = consumerConfig.refer();
            binding.setConsumerConfig(consumerConfig);
            return result;
        } catch (Exception e) {
            throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_CONSUME_FAIL), e);
        }
    }

    /**
     * undo in binding
     *
     * @param contract
     * @param binding
     * @param sofaRuntimeContext
     */
    @Override
    public void unInBinding(Object contract, RpcBinding binding,
                            SofaRuntimeContext sofaRuntimeContext) {
        try {
            ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager()
                .getRootApplicationContext();
            ConsumerConfigContainer consumerConfigContainer = applicationContext
                .getBean(ConsumerConfigContainer.class);
            consumerConfigContainer.removeAndUnReferConsumerConfig(binding);
        } catch (Exception e) {
            throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_UNCOSUME_FAIL),
                e);
        }
    }

    /**
     * get binding class
     *
     * @return binding class
     */
    @Override
    public Class<RpcBinding> getBindingClass() {
        return RpcBinding.class;
    }

}


        ApplicationContext applicationContext = sofaRuntimeContext.getSofaRuntimeManager()
            .getRootApplicationContext();
        ProviderConfigContainer providerConfigContainer = applicationContext
            .getBean(ProviderConfigContainer.class);
        String uniqueName = providerConfigContainer.createUniqueName((Contract) contract, binding);
        ProviderConfigHelper providerConfigHelper = applicationContext
            .getBean(ProviderConfigHelper.class);
        ProviderConfig providerConfig = providerConfigHelper.getProviderConfig((Contract) contract,
            binding, target);
        try {
            providerConfigContainer.addProviderConfig(uniqueName, providerConfig);
        } catch (Exception e) {
            throw new ServiceRuntimeException(LogCodes.getLog(LogCodes.ERROR_PROXY_PUBLISH_FAIL), e);
        }
    
<no_super_class>