0
我想訪問java類中存在的靜態塊內的數據。在下面的數據中,可以在加載靜態塊的實例後訪問它。webAppAccess.getModelName()數據如何傳遞給鏈接的java對象類中的任何靜態塊?
public final static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(OuterClass.class.getName());
static String userId= "";
public static void getModelName(WebAppAccess webAppAccess) {
userId = webAppAccess.getModelName();
logger.info("USERID " + userId);
}
靜態 {
String PROPERTIES_FILE = "/config/log4j.properties";
logger.info("USERID 2 " + userId);
if(userId.equals("qwe"))
System.setProperty("balancer.log", "C:\\log_f.out");
else
System.setProperty("balancer.log", "C:\\log_f2.out");
File file = new File (BSConfig.getHomedir() + PROPERTIES_FILE);