{"id":18628150,"url":"https://github.com/ujjboy/sofa-rpc-extension-demo","last_synced_at":"2025-10-27T09:20:34.083Z","repository":{"id":199462916,"uuid":"130194640","full_name":"ujjboy/sofa-rpc-extension-demo","owner":"ujjboy","description":"Demo of write third-party extension for sofa-rpc.","archived":false,"fork":false,"pushed_at":"2018-04-19T12:05:43.000Z","size":11,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-17T09:09:26.235Z","etag":null,"topics":["sofa-rpc-demo"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ujjboy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-04-19T09:50:17.000Z","updated_at":"2018-07-27T04:12:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"177d7279-8433-4ba4-a7a8-a79cd426fcc0","html_url":"https://github.com/ujjboy/sofa-rpc-extension-demo","commit_stats":null,"previous_names":["ujjboy/sofa-rpc-extension-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ujjboy/sofa-rpc-extension-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujjboy%2Fsofa-rpc-extension-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujjboy%2Fsofa-rpc-extension-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujjboy%2Fsofa-rpc-extension-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujjboy%2Fsofa-rpc-extension-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ujjboy","download_url":"https://codeload.github.com/ujjboy/sofa-rpc-extension-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ujjboy%2Fsofa-rpc-extension-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281244034,"owners_count":26467805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-27T02:00:05.855Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sofa-rpc-demo"],"created_at":"2024-11-07T04:45:40.119Z","updated_at":"2025-10-27T09:20:34.038Z","avatar_url":"https://github.com/ujjboy.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 为什么要扩展\n\nSOFARPC 是一个可扩展性较高的 RPC 框架，当官方实现或者第三方实现没有满足自身需求的时候，进行扩展。\n\n我们强烈推荐您将您的各种扩展贡献给 SOFARPC 官方。\n\n但是如果由于组件的特殊性（例如内部组件）、或者编译级别（例如要求JDK8以上）不同，我们建议您开启一个工程单独存放逻辑，就像本例一样。\n \n \n# 如何扩展 SOFARPC\n\n本文将通过一个扩展一个本地的注册中心的实现作为例子，简单介绍下 SOFARPC 扩展能力的步骤。\n\n## 步骤一： 编写实现\n\n我们新建一个 `org.howtimeflies.sofa.rpc.registry.MyRegistry`，继承自一个可扩展接口或者抽象类 `com.alipay.sofa.rpc.registry.Registry`，具体实现不多介绍。\n\n注意，在类名上增加如下注解，指定别名\n\n```java\npackage org.howtimeflies.sofa.rpc.registry;\n@Extension(\"myRegistry\")\npublic class MyRegistry extends com.alipay.sofa.rpc.registry.Registry {\n}\n```\n\n## 步骤二：编写扩展配置\n\n新建：`src/main/resources/META-INF/services/sofa-rpc/com.alipay.sofa.rpc.registry.Registry`\n内容为：\n```\nmyRegistry=org.howtimeflies.sofa.rpc.registry.MyRegistry\n```\n\n## 步骤三：测试\n\n可以打包测试，也可以直接写测试用例测试。例如 `org.howtimeflies.sofa.rpc.MyRegistryTest`里的。\n\n```java\npublic class MyRegistryTest {\n    public static void main(String[] args) {\n        // 指定自己的注册中心\n        RegistryConfig registryConfig = new RegistryConfig()\n                .setProtocol(\"myRegistry\");\n        \n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujjboy%2Fsofa-rpc-extension-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fujjboy%2Fsofa-rpc-extension-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fujjboy%2Fsofa-rpc-extension-demo/lists"}