Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Optimizing code
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnu-liguobin committed Jun 30, 2019
1 parent 2bf7461 commit 0f697cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,13 @@ Examples
- server

```java
//you need start a consul
//start server
public class ServerBuilderTest {
public static void main(String[] args) {
List<Object> tmpList1 = new ArrayList<>();
tmpList1.add(new HelloWorld());
ServerBuilder server = DlsRpc.getServerBuilder(DlsRpcConfiguration.WEB_SERVER_PORT(), tmpList1);
ServerBuilder server = DlsRpc.getServerBuilder(9000, tmpList1);
server.build().start();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class Server @Inject()(serializer: Serializer, serverChannel: ServerChannel, mes
//服务端任务执行器,使用缓存线程池
private[this] final lazy val executor: Executor = ExecutorBuilder.executorBuild("dlsRpc-thread-executor-%d", daemon = true)

protected[server] def setPort(port: Int): Server = {
private[server] def setPort(port: Int): Server = {
this.port = port
this
}

def setBeans(serviceBeans: Seq[AnyRef]): Server = {
private[server] def setBeans(serviceBeans: Seq[AnyRef]): Server = {
if (this.serviceBeans != null && this.serviceBeans.nonEmpty) {
this.serviceBeans = this.serviceBeans ++ serviceBeans
} else {
Expand All @@ -65,7 +65,7 @@ class Server @Inject()(serializer: Serializer, serverChannel: ServerChannel, mes
}

//关闭时强制GC
protected[server] def shutdown(): Unit = {
private[server] def shutdown(): Unit = {
try serverChannel.shutdown()
finally System.gc()
}
Expand Down

0 comments on commit 0f697cd

Please sign in to comment.