-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelloWorldTac.java
54 lines (43 loc) · 1.41 KB
/
HelloWorldTac.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.alibaba.tac.biz.processor;
import com.alibaba.tac.sdk.common.TacResult;
import com.alibaba.tac.sdk.domain.Context;
import com.alibaba.tac.sdk.factory.TacInfrasFactory;
import com.alibaba.tac.sdk.handler.TacHandler;
import com.alibaba.tac.sdk.infrastracture.TacLogger;
import com.tmall.itemcenter.ItemDO;
import com.tmall.itemcenter.TmallItemService;
import java.util.HashMap;
import java.util.Map;
/**
* @author jinshuan.li
*/
public class HelloWorldTac implements TacHandler<Object> {
/**
* get the logger service
*/
private TacLogger tacLogger = TacInfrasFactory.getLogger();
/**
* get the item service
*/
private TmallItemService tmallItemService = TacInfrasFactory.getServiceBean(TmallItemService.class);
/**
* implement a class which implements TacHandler interface
* {@link TacHandler}
* @param context
* @return
* @throws Exception
*/
@Override
public TacResult<Object> execute(Context context) throws Exception {
// the code
tacLogger.info("Hello World");
Map<String, Object> data = new HashMap<>();
data.put("name", "hellotac");
data.put("platform", "iPhone");
data.put("clientVersion", "7.0.2");
data.put("userName", "tac-userName");
ItemDO item = tmallItemService.getItem(123L);
data.put("item", item);
return TacResult.newResult(data);
}
}