查看一些Java代码,这似乎不正确。在我看来,每次调用项目时,您都会获得一个新的哈希图,因此该语句始终为false
projects.get(soapFileName) != null
似乎它应该有一个支持领域
public static HashMap<String,WsdlProject> projects = new HashMap<String,WsdlProject>();
public Object[] argumentsFromCallSoapui(CallT call, Vector<String> soapuiFiles, HashMap theDPLs,int messageSize)
{
try {
for (String soapFileName:soapuiFiles){
System.out.println("Trying "+soapFileName);
WsdlProject project ;
if (projects.get(soapFileName) != null){
project = projects.get(soapFileName);
} else {
project = new WsdlProject(soapFileName);
projects.put(soapFileName,project);
}
}
} ...
}
最佳答案
不。在Java中,静态变量仅初始化一次。
因此,这条线只会被调用一次。
public static HashMap<String,WsdlProject> projects = new HashMap<String,WsdlProject> ();