01: package com.calipso.reportgenerator.services;
02:
03: import com.calipso.reportgenerator.common.ReportGeneratorConfiguration;
04: import org.apache.commons.vfs.FileSystemManager;
05: import com.calipso.reportgenerator.common.InfoException;
06:
07: /**
08: * Clase abstracta para los distintos File System que se implementen
09: */
10: public abstract class FileSystemResolver {
11: private ReportGeneratorConfiguration reportGeneratorConfiguration;
12: private static DefaultFileSystemResolver defaultFileSystemResolver;
13:
14: public FileSystemResolver(
15: ReportGeneratorConfiguration reportGeneratorConfiguration) {
16: this .reportGeneratorConfiguration = reportGeneratorConfiguration;
17: }
18:
19: public static FileSystemManager getFileSystemManager(
20: ReportGeneratorConfiguration reportGeneratorConfiguration)
21: throws InfoException {
22: if (reportGeneratorConfiguration.getFrameworkPlatform()
23: .equalsIgnoreCase(FramewokPlatform.Calipso)) {
24: if (defaultFileSystemResolver == null) {
25: defaultFileSystemResolver = new DefaultFileSystemResolver(
26: reportGeneratorConfiguration);
27: }
28: return defaultFileSystemResolver.getFileSystemManager();
29: } else if (reportGeneratorConfiguration.getFrameworkPlatform()
30: .equalsIgnoreCase(FramewokPlatform.StandAlone)) {
31: if (defaultFileSystemResolver == null) {
32: defaultFileSystemResolver = new DefaultFileSystemResolver(
33: reportGeneratorConfiguration);
34: }
35: return defaultFileSystemResolver.getFileSystemManager();
36: }
37: return null;
38: }
39:
40: public ReportGeneratorConfiguration getReportGeneratorConfiguration() {
41: return reportGeneratorConfiguration;
42: }
43:
44: public static void resetFileSystemManager() {
45: try {
46: defaultFileSystemResolver.finalize();
47: defaultFileSystemResolver = null;
48: } catch (Exception e) {
49: } catch (Throwable throwable) {
50: }
51: }
52: }
|