*
* @return the virtualizer
*/
public JRFileVirtualizer getVirtualizer(String tmpDirectory, ServletContext servletContext) {
logger.debug("IN");
JRFileVirtualizer virtualizer = null;
SourceBean config = EnginConf.getInstance().getConfig();
String maxSizeStr = (String)config.getAttribute("VIRTUALIZER.maxSize");
int maxSize = 2;
if(maxSizeStr!=null) maxSize = Integer.parseInt(maxSizeStr);
String dir = (String)config.getAttribute("VIRTUALIZER.dir");
if(dir == null){
dir = tmpDirectory;
} else {
if(!dir.startsWith("/")) {
String contRealPath = servletContext.getRealPath("/");
if(contRealPath.endsWith("\\")||contRealPath.endsWith("/")) {
contRealPath = contRealPath.substring(0, contRealPath.length()-1);
}
dir = contRealPath + "/" + dir;
}
}
dir = dir + System.getProperty("file.separator") + "jrcache";
File file = new File(dir);
file.mkdirs();
logger.debug("Max page cached during virtualization process: " + maxSize);
logger.debug("Dir used as storing area during virtualization: " + dir);
virtualizer = new JRFileVirtualizer(maxSize, dir);
virtualizer.setReadOnly(false);
logger.debug("OUT");
return virtualizer;
}