|
2 | 2 |
|
3 | 3 | import com.alibaba.fastjson.JSON; |
4 | 4 | import com.alibaba.fastjson.serializer.SerializerFeature; |
5 | | -import io.kimmking.rpcfx.api.RpcfxRequest; |
| 5 | +import io.kimmking.rpcfx.api.RpcfxReflectionResolver; |
| 6 | +import io.kimmking.rpcfx.param.RpcfxRequest; |
6 | 7 | import io.kimmking.rpcfx.api.RpcfxResolver; |
7 | | -import io.kimmking.rpcfx.api.RpcfxResponse; |
| 8 | +import io.kimmking.rpcfx.param.RpcfxResponse; |
8 | 9 |
|
9 | 10 | import java.lang.reflect.InvocationTargetException; |
10 | 11 | import java.lang.reflect.Method; |
11 | 12 | import java.util.Arrays; |
12 | 13 |
|
13 | 14 | public class RpcfxInvoker { |
14 | 15 |
|
15 | | - private RpcfxResolver resolver; |
| 16 | +/* private RpcfxResolver resolver; |
16 | 17 |
|
17 | 18 | public RpcfxInvoker(RpcfxResolver resolver){ |
18 | 19 | this.resolver = resolver; |
| 20 | + }*/ |
| 21 | + private RpcfxReflectionResolver reflectionResolver; |
| 22 | + |
| 23 | + public RpcfxInvoker(RpcfxReflectionResolver reflectionResolver) { |
| 24 | + this.reflectionResolver = reflectionResolver; |
19 | 25 | } |
20 | 26 |
|
21 | 27 | public RpcfxResponse invoke(RpcfxRequest request) { |
22 | 28 | RpcfxResponse response = new RpcfxResponse(); |
23 | 29 | String serviceClass = request.getServiceClass(); |
24 | 30 |
|
25 | 31 | // 作业1:改成泛型和反射 |
26 | | - Object service = resolver.resolve(serviceClass);//this.applicationContext.getBean(serviceClass); |
| 32 | + //Object service = resolver.resolve(serviceClass);//this.applicationContext.getBean(serviceClass); |
| 33 | + Object service = reflectionResolver.resolve(serviceClass); |
27 | 34 |
|
28 | 35 | try { |
29 | 36 | Method method = resolveMethodFromClass(service.getClass(), request.getMethod()); |
|
0 commit comments