This commit is contained in:
Redkale
2017-03-20 21:05:28 +08:00
parent 910eb88c55
commit fdc868641d
5 changed files with 79 additions and 73 deletions

View File

@@ -147,14 +147,14 @@ public class ABMainService implements Service {
@RestMapping(name = "syncabtime")
public String abCurrentTime(@RestParam(name = "#") final String name) {
String rs = "同步abCurrentTime: " + bcService.showCurrentTime(name);
String rs = "同步abCurrentTime: " + bcService.bcCurrentTime(name);
System.out.println("执行了 ABMainService.abCurrentTime++++同步方法");
return rs;
}
@RestMapping(name = "asyncabtime")
public void abCurrentTime(final AsyncHandler<String, Void> handler, @RestParam(name = "#") final String name) {
bcService.showCurrentTime(AsyncHandler.create((v, a) -> {
bcService.bcCurrentTime(AsyncHandler.create((v, a) -> {
System.out.println("执行了 ABMainService.abCurrentTime----异步方法");
String rs = "异步abCurrentTime: " + v;
if (handler != null) handler.completed(rs, null);

View File

@@ -18,16 +18,16 @@ public class BCService implements Service {
@Resource
private CService cService;
public String showCurrentTime(final String name) {
String rs = "同步showCurrentTime: " + cService.getCurrentTime(name).getResult();
System.out.println("执行了 BCService.showCurrentTime++++同步方法");
public String bcCurrentTime(final String name) {
String rs = "同步bcCurrentTime: " + cService.ccCurrentTime(name).getResult();
System.out.println("执行了 BCService.bcCurrentTime++++同步方法");
return rs;
}
public void showCurrentTime(final AsyncHandler<String, Void> handler, final String name) {
cService.getCurrentTime(AsyncHandler.create((v, a) -> {
System.out.println("执行了 BCService.showCurrentTime----异步方法");
String rs = "异步showCurrentTime: " + v.getResult();
public void bcCurrentTime(final AsyncHandler<String, Void> handler, final String name) {
cService.ccCurrentTime(AsyncHandler.create((v, a) -> {
System.out.println("执行了 BCService.bcCurrentTime----异步方法");
String rs = "异步bcCurrentTime: " + v.getResult();
if (handler != null) handler.completed(rs, null);
}, (t, a) -> {
}), name);

View File

@@ -14,15 +14,15 @@ import org.redkale.util.*;
*/
public class CService implements Service {
public RetResult<String> getCurrentTime(final String name) {
String rs = "同步getCurrentTime: " + name + ": " + Utility.formatTime(System.currentTimeMillis());
System.out.println("执行了 CService.getCurrentTime++++同步方法");
public RetResult<String> ccCurrentTime(final String name) {
String rs = "同步ccCurrentTime: " + name + ": " + Utility.formatTime(System.currentTimeMillis());
System.out.println("执行了 CService.ccCurrentTime++++同步方法");
return new RetResult(rs);
}
public void getCurrentTime(final AsyncHandler<RetResult<String>, Void> handler, final String name) {
String rs = "异步getCurrentTime: " + name + ": " + Utility.formatTime(System.currentTimeMillis());
System.out.println("执行了 CService.getCurrentTime----异步方法");
public void ccCurrentTime(final AsyncHandler<RetResult<String>, Void> handler, final String name) {
String rs = "异步ccCurrentTime: " + name + ": " + Utility.formatTime(System.currentTimeMillis());
System.out.println("执行了 CService.ccCurrentTime----异步方法");
if (handler != null) handler.completed(new RetResult(rs), null);
}
}