-1
爲什麼構造函數RegisterProxy()在我們調用「R response = proxy.CallAPISync(request);」時沒有執行; ?爲什麼構造函數沒有執行?
public class SoaCaller {
private static RegisterProxy proxy = new RegisterProxy(); ;
public static <T, R> R CallAPISyn(T request){
R response = proxy.CallAPISync(request);
return response;
}
}
public class RegisterProxy {
private static HashMap<String, BaseSoaImplement> cache = new HashMap<>();
public RegisterProxy(){
try {
cache.put(GetHotelStaticInfoRequestType.class.getName(), new GetHotelStaticInfoImpl());
}
catch (Exception ex){
ExceptionUtils.getStackTrace(ex));
}
}
要早得多因爲這不會創建新的實例。當SoaCaller被加載時,構造函數被調用。 –
構造函數將只在對象創建時被調用。 –
我唯一的解釋就是它之前被調用過。 – dasblinkenlight