KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > backup > BackupStorageMonitor


1 /*
2  * MaxBackupMonitor.java
3  *
4  * Created on December 21, 2003, 8:29 PM
5  */

6
7 package com.sun.enterprise.config.backup;
8
9 import java.io.IOException JavaDoc;
10 import java.io.File JavaDoc;
11 import java.util.Arrays JavaDoc;
12 import java.util.ArrayList JavaDoc;
13 import java.util.List JavaDoc;
14 import java.io.FilenameFilter JavaDoc;
15 import com.sun.enterprise.config.backup.utils.LoggerHelper;
16 import com.sun.enterprise.config.backup.pluggable.EnvironmentFactory;
17 import com.sun.enterprise.config.backup.pluggable.BackupEnvironment;
18 import com.sun.enterprise.config.backup.utils.FactoryHelper;
19 import com.sun.enterprise.config.backup.status.BackupStatus;
20 import com.sun.enterprise.config.backup.status.ListBackupStatus;
21
22
23 /**
24  * Anything extraneous in the monitored directory will
25  * not be touched
26  * @author sridatta
27  */

28 public class BackupStorageMonitor extends StorageMonitor {
29     
30     /** Creates a new instance of MaxBackupMonitor */
31     public BackupStorageMonitor() {
32     }
33     
34     protected int getMaxBackups() {
35         return getEnv().getMaxBackups();
36     }
37
38     
39     protected String JavaDoc getFileNamePrefix() {
40      return getEnv().getBackupFileNamePrefix();
41     }
42     
43     protected FilenameFilter JavaDoc getFileNameFilter() {
44      return new BackupFileNameFilter(
45                     getEnv().getBackupFileNamePrefix());
46     }
47     
48     protected String JavaDoc getMonitoredDirectory() {
49      return getEnv().getDirectoryToStoreBackupFiles();
50     }
51     
52     public BackupStatus[] listBackupStatus() {
53         File JavaDoc[] f = null;
54         BackupStatus[] bss = null;
55         try {
56             f = getFiles();
57             
58             if(f == null || f.length == 0) return null;
59             
60             bss = new BackupStatus[f.length];
61             for (int i = 0 ; i < f.length; i++) {
62                 BackupStatus bs = new ListBackupStatus(f[i]);
63                 bss[i] = bs;
64             }
65         } catch(Exception JavaDoc e) {
66             //ignore
67
LoggerHelper.error("error_listing_backups", e);
68         }
69         
70         return bss;
71     }
72 }
Popular Tags