我编写了一个自定义RpcRequestBuilder进行身份验证,非常类似:
http://stuffthathappens.com/blog/2009/12/22/custom-http-headers-with-gwt-rpc
但是我需要每个GWT RPC服务在使用之前设置我的自定义构建器,或者如果可能的话,告诉GWT使用我的版本作为默认值.我怎样才能做到这一点?
小智 5
public static final UtilServiceAsync getInstance() {
if (instance == null) {
instance = (UtilServiceAsync) GWT.create(UtilService.class);
ServiceDefTarget target = (ServiceDefTarget) instance;
RpcRequestBuilder reqBuilder = new RpcRequestBuilder() {
@Override
protected RequestBuilder doCreate(String serviceEntryPoint) {
RequestBuilder rb = super.doCreate(serviceEntryPoint);
rb.setHeader("HEADER_SIGNATURE", "your token");
return rb;
}
};
target.setRpcRequestBuilder(reqBuilder);
//target.setServiceEntryPoint(GWT.getModuleBaseURL() + "springGwtServices/" + "utilService");
}
return instance;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1213 次 |
| 最近记录: |