【发布时间】:2015-04-05 10:06:00
【问题描述】:
在我的应用程序中,我的服务类具有仅在方法参数中运行的无状态方法。
我的问题是,其中许多方法调用需要用户和应用程序请求它的外部 API。
一个简单的解决方案是将这些参数添加到所有服务方法中,例如:
class RequestInformation{
private String user;
private String application;
}
class SomeService{
foo(requestInformation, methodParamA, methodParamB)
bar(requestInformation, methodParamA, methodParamB, methodParamC)
}
我不确定向所有服务类中的所有方法添加相同的 RequestInformation 参数是否是个好主意。
我可以使用其他方法来避免在所有方法中都有 RequestInformation 吗?
【问题讨论】: