Skip to content

Commit

Permalink
add dispatcher config in Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
HiWong committed Apr 20, 2018
1 parent 3340af2 commit 402a80e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
13 changes: 12 additions & 1 deletion CHINESE_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,23 @@ Andromeda和其他组件间通信方案的对比如下:
```groovy
implementation 'org.qiyi.video.svg:core:1.0.0'
```
在Application Module中使用gradle插件:
在application Module中使用gradle插件:
```groovy
apply plugin: 'org.qiyi.svg.plugin'
```

# 使用方式
## 为Dispatcher配置进程
由于Dispatcher负责管理所有进程信息,所以它应该运行在存活时间最长的进程中。
Dispatcher默认运行在主进程中。但是考虑到在有些App中,主进程不一定是存活时间最长的(比如音乐播放App中往往是播放进程的存活时间最长),
所以出现这种情况时开发者应该在application module的build.gradle中为Dispatcher配置进程名,如下:
```groovy
dispatcher{
process ":downloader"
}
```
在这里,":downloader"进程是存活时间最长的.

## 初始化
最好是在自己进程的Application中进行初始化(每个进程都有自己的Andromeda对象),代码如下:
```java
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,24 @@ add core lib dependency in Application or library Module:
```groovy
implementation 'org.qiyi.video.svg:core:0.9.3'
```
apply gradle plugin in Application Module:
apply gradle plugin in application Module:
```groovy
apply plugin: 'org.qiyi.svg.plugin'
```

# How to use
## Dispatcher config
**Dispatcher should always in the process that live longest cause it manager all process infos!.**
Default process of Dispatcher is main process.
Considering some process may live longer than main process in some apps(such as music app), developers should
config process name for Dispatcher in this case. Just as follows in build.gradle of application module:
```groovy
dispatcher{
process ":downloader"
}
```
In this case, ":downloader" process is the one that live longest.

## init
add init code in Application.onCreate():
```java
Expand All @@ -56,7 +68,7 @@ add init code in Application.onCreate():
Please make sure Andromeda inited before use if you don't init it in Application.onCreate().

## Register and use local service
### definition and implementation of local service
### Definition and implementation of local service
There are only two differences between local service and normal interfaces:
+ interfaces should be put in a common module to make it accessible to all modules
+ Andromeda will only hold one implementation at a time
Expand Down Expand Up @@ -138,7 +150,7 @@ public class BuyAppleImpl extends IBuyApple.Stub {
}

```
### Registration
### Registration of remote service
Differen from registration of local service, IBinder of remote service is need for registration :
```java
Andromeda.registerRemoteService(IBuyApple.class, BuyAppleImpl.getInstance().asBinder());
Expand Down

0 comments on commit 402a80e

Please sign in to comment.