public abstract class AbstractAdaptor extends Object implements HttpAdaptor2
Modifier and Type | Field and Description |
---|---|
protected Class<?>[] |
argTypes |
protected int |
curIndex |
protected String[] |
defaultValues |
protected int |
errCtxIndex |
protected ParamInjector[] |
injs |
protected Method |
method |
protected String[] |
paramNames |
Constructor and Description |
---|
AbstractAdaptor() |
Modifier and Type | Method and Description |
---|---|
Object[] |
adapt(javax.servlet.ServletContext sc,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
String[] pathArgs)
你的适配器需要根据传入的 request 和 response 生成函数的调用参数
|
protected ParamInjector |
evalInjector(Type type,
Param param) |
protected abstract ParamInjector |
evalInjectorBy(Type type,
Param param)
子类实现这个方法根据自己具体的逻辑来生产一个参数注入器
|
protected String |
getParamRealName(int index) |
protected Object |
getReferObject(javax.servlet.ServletContext sc,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse resp,
String[] pathArgs) |
void |
init(ActionInfo ai)
这是更高级的初始化方法,可以获得更多的初始化信息
|
void |
init(Method method)
这个函数将在你的适配器生命周期内,这个函数将只被调用一次。它用来告诉你的适配器,你需要适配什么方法。
|
protected void |
init(Method method,
String[] paramNames) |
protected ParamInjector |
paramNameInject(Method method,
int index)
这是最后的大招了,查一下形参的名字,作为@Param("形参名")进行处理
|
protected ParamInjector[] injs
protected Method method
protected Class<?>[] argTypes
protected String[] defaultValues
protected String[] paramNames
protected int curIndex
protected int errCtxIndex
public void init(ActionInfo ai)
HttpAdaptor2
init
in interface HttpAdaptor2
HttpAdaptor
public void init(Method method)
HttpAdaptor
init
in interface HttpAdaptor
method
- 你需要适配的方法protected ParamInjector evalInjector(Type type, Param param)
protected abstract ParamInjector evalInjectorBy(Type type, Param param)
type
- 参数类型param
- 参数的注解public Object[] adapt(javax.servlet.ServletContext sc, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String[] pathArgs)
HttpAdaptor
adapt
in interface HttpAdaptor
sc
- Servlet 上下文对象req
- 请求对象resp
- 响应对象pathArgs
- 字符串数组,路径参数。详情请参看 路径参数protected Object getReferObject(javax.servlet.ServletContext sc, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, String[] pathArgs)
protected ParamInjector paramNameInject(Method method, int index)
protected String getParamRealName(int index)
Copyright © 2017. All rights reserved.