1 6 7 package com.sun.enterprise.config.backup.pluggable.impl; 8 9 import com.sun.enterprise.config.backup.pluggable.BackupEnvironment; 10 import com.sun.enterprise.config.backup.pluggable.EnvironmentFactory; 11 import com.sun.enterprise.config.backup.status.StatusConstants; 12 import com.sun.enterprise.config.backup.DefaultConstants; 13 import com.sun.enterprise.config.backup.BackupAbortException; 14 import com.sun.enterprise.config.backup.EnvironmentConstants; 15 import com.sun.enterprise.config.backup.utils.SystemPropsHelper; 16 17 26 public class DefaultBackupEnvironment implements BackupEnvironment, 27 StatusConstants, 28 DefaultConstants, 29 EnvironmentConstants { 30 31 32 33 private String _snapshotFileNamePrefix; 34 private String _backupFileNamePrefix; 35 private String _backupHistoryFileName; 36 private int _maxBackups; 37 private int _maxSnapShots; 38 private String _backupStorageType; 39 40 private String [] _directoriesToBackup; 41 private String _directoryToStoreBackupFiles; 42 private String _directoryToStoreSnapshotFile; 43 private String _directoryToStoreHistoryFile; 44 private String _statusInfoFileName; 45 46 47 public DefaultBackupEnvironment() { 48 initialize(); 49 } 50 51 protected void initialize() { 52 initializeDefaults(); 53 initializeFromEnvironment(); 54 } 55 56 private void initializeDefaults() { 57 _snapshotFileNamePrefix = DEFAULT_SNAPSHOT_FILENAME_PREFIX; 58 _backupFileNamePrefix = DEFAULT_BACKUP_FILENAME_PREFIX; 59 _backupHistoryFileName = DEFAULT_BACKUP_HISTORY_FILENAME; 60 _maxBackups = DEFAULT_MAX_BACKUPS; 61 _maxSnapShots = DEFAULT_MAX_SNAPSHOTS; 62 _statusInfoFileName = DEFAULT_STATUS_INFO_FILENAME; 63 } 64 65 private void initializeFromEnvironment() { 66 setDirectoriesToBackup(getEnvArr(DIRS_TO_BACKUP)); 67 68 String dir = getEnv(DIR_TO_STORE_BACKUP_FILES); 69 70 setDirectoryToStoreBackupFiles(dir); 71 setDirectoryToStoreSnapshotFile(dir); 72 setDirectoryToStoreHistoryFile(dir); 73 setBackupStorageType(getEnv(BACKUP_STORAGE_TYPE)); 74 } 75 76 79 protected String getEnv(String var) { 80 return SystemPropsHelper.getProperty(var); 81 } 82 83 86 protected String [] getEnvArr(String var) { 87 return SystemPropsHelper.getProperty(var).split(","); 89 } 90 91 95 96 public String [] getDirectoriesToBackup() { 97 return _directoriesToBackup; 98 } 99 100 public String getDirectoryToStoreBackupFiles() { 101 return _directoryToStoreBackupFiles; 102 } 103 104 public String getDirectoryToStoreHistoryFile() { 105 return _directoryToStoreHistoryFile; 106 } 107 108 public String getDirectoryToStoreSnapshotFile() { 109 return _directoryToStoreSnapshotFile; 110 } 111 112 116 public String getSnapshotFileNamePrefix() { 117 return _snapshotFileNamePrefix; 118 } 119 120 125 public String getBackupFileNamePrefix() { 126 return _backupFileNamePrefix; 127 } 128 129 132 public String getBackupHistoryFileName() { 133 return _backupHistoryFileName; 134 } 135 136 140 public int getMaxBackups() { 141 return _maxBackups; 142 } 143 147 public int getMaxSnapShots() { 148 return _maxSnapShots; 149 } 150 151 152 public String getExecutionType() { 153 return getEnv(EXECUTION_TYPE); 154 } 155 156 private void setDirectoryToStoreBackupFiles(String dir) { 157 _directoryToStoreBackupFiles = dir; 158 } 159 private void setDirectoryToStoreSnapshotFile(String dir) { 160 _directoryToStoreSnapshotFile = dir; 161 } 162 private void setDirectoryToStoreHistoryFile(String dir) { 163 _directoryToStoreHistoryFile = dir; 164 } 165 private void setDirectoriesToBackup(String [] dirs) { 166 _directoriesToBackup = dirs; 167 } 168 169 public String getBackupStorageType() { 170 return _backupStorageType; 171 } 172 173 private void setBackupStorageType(String type) { 174 _backupStorageType = type; 175 } 176 177 public String getStatusInfoFileName() { 178 return _statusInfoFileName; 179 } 180 181 } 182 | Popular Tags |