1 6 7 package SOFA.SOFAnet.Repository; 8 9 import java.io.*; 10 11 16 public class BinBundles extends StorageBase 17 { 18 19 20 public BinBundles(File baseDir) 21 { 22 super(baseDir, "jar", false); 23 init(); 24 } 25 26 protected StorageItem newItem(String name, File file) 27 { 28 BundleInfo bundleInfo = new BundleInfo(); 29 try 30 { 31 bundleInfo.fromFilename(name); 32 } 33 catch (BundleInfo.InvalidBundleNameException e) 34 { 35 return null; 36 } 37 bundleInfo.setFile(file); 38 return bundleInfo; 39 } 40 41 46 public BundleInfo getBinBundle(String bundleName) 47 { 48 return (BundleInfo)map.get(bundleName); 49 } 50 51 57 public boolean deleteBinBundle(String bundleName) 58 { 59 synchronized (map) 60 { 61 BundleInfo bundleInfo = (BundleInfo)map.remove(bundleName); 62 if (bundleInfo != null) 63 { 64 try 65 { 66 bundleInfo.getFile().delete(); 67 } 68 catch (Exception e) 69 { 70 } 71 return true; 72 } 73 else return false; 74 } 75 } 76 77 83 public BundleInfo addBinBundle(String bundleName) 84 { 85 synchronized (map) 86 { 87 if (map.get(bundleName) != null) return null; 88 89 BundleInfo bundleInfo = new BundleInfo(); 90 try 91 { 92 bundleInfo.fromBundleName(bundleName); 93 } 94 catch (BundleInfo.InvalidBundleNameException e) 95 { 96 return null; 97 } 98 99 bundleInfo.setFile(new File(baseDir, bundleInfo.getFileName() + ".jar")); 100 map.put(bundleName, bundleInfo); 101 return bundleInfo; 102 } 103 } 104 } 105 | Popular Tags |