1 package com.calipso.reportgenerator.services; 2 3 import com.calipso.reportgenerator.common.ReportGeneratorConfiguration; 4 import org.apache.commons.vfs.FileSystemManager; 5 import com.calipso.reportgenerator.common.InfoException; 6 7 10 public abstract class FileSystemResolver { 11 private ReportGeneratorConfiguration reportGeneratorConfiguration; 12 private static DefaultFileSystemResolver defaultFileSystemResolver; 13 14 public FileSystemResolver(ReportGeneratorConfiguration reportGeneratorConfiguration) { 15 this.reportGeneratorConfiguration = reportGeneratorConfiguration; 16 } 17 18 public static FileSystemManager getFileSystemManager(ReportGeneratorConfiguration reportGeneratorConfiguration) throws InfoException { 19 if (reportGeneratorConfiguration.getFrameworkPlatform().equalsIgnoreCase(FramewokPlatform.Calipso)){ 20 if (defaultFileSystemResolver == null) { 21 defaultFileSystemResolver = new DefaultFileSystemResolver(reportGeneratorConfiguration); 22 } 23 return defaultFileSystemResolver.getFileSystemManager(); 24 } else if (reportGeneratorConfiguration.getFrameworkPlatform().equalsIgnoreCase(FramewokPlatform.StandAlone)){ 25 if (defaultFileSystemResolver == null) { 26 defaultFileSystemResolver = new DefaultFileSystemResolver(reportGeneratorConfiguration); 27 } 28 return defaultFileSystemResolver.getFileSystemManager(); 29 } 30 return null; 31 } 32 33 public ReportGeneratorConfiguration getReportGeneratorConfiguration() { 34 return reportGeneratorConfiguration; 35 } 36 37 public static void resetFileSystemManager(){ 38 try { 39 defaultFileSystemResolver.finalize(); 40 defaultFileSystemResolver = null; 41 }catch(Exception e){ 42 } 43 catch (Throwable throwable) { 44 } 45 } 46 } 47 | Popular Tags |