在我正在处理的项目中,我看到了这段代码:
@Autowired
private ContextBuilder contextBuilder;
response = service.payment(contextBuilder.getContext(), request);
请求和响应是两个包含输入和输出请求的bean。 Contextbuilder类是这样的:
private Context context;
private ContextEntry contextEntry;
private UserInfoRequestBean userInfo;
private String sessionId;
private boolean session = false;
public ContextBuilder() {
this.context = new Context();
this.contextEntry = new ContextEntry();
}
public Context getContext() {
this.contextEntry.setKey("SESSIONID");
this.contextEntry.setValue(sessionId( null));
this.context.getData().add(this.contextEntry);
return this.context;
}
public String sessionId(String sessionId) {
if (this.session) {
this.session = false;
synchronized (ContextBuilder.class) {
if (sessionId != null) {
this.sessionId = sessionId;
return null;
} else {
return this.sessionId;
}
}
} else {
return this.sessionId;
}
}
我无法得到getContext(),特别是sessionId()在做什么?什么是SESSIONID的价值?它总是无效?如果是的话为什么?