Changeset 1667 for branches/3.0-Beta2
- Timestamp:
- 06/24/07 14:27:29 (18 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0-Beta2/components/common/src/ome/util/PathUtil.java
r1567 r1667 1 1 package ome.util; 2 2 3 import java.io.File; 3 4 import java.io.FileInputStream; 4 5 import java.io.IOException; 5 6 import java.util.Properties; 6 7 8 import ome.conditions.InternalException; 9 10 import org.springframework.util.ResourceUtils; 7 11 8 12 public class PathUtil { 9 10 private final String SPRING_FILE_PATH = "components/romio/resources/beanRefContext.xml"; 11 private final String OMERO_PROPS = "etc/omero.properties"; 12 private static PathUtil instance = null; 13 private static Properties properties; 14 15 private PathUtil() { 16 properties = new Properties(); 17 try { 18 properties.load(new FileInputStream(OMERO_PROPS)); 19 } catch (IOException e) { 20 // TODO - something 21 } 22 } 23 24 public static PathUtil getInstance() { 25 if (instance == null) { 26 return new PathUtil(); 27 } else { 28 return instance; 29 } 30 } 31 32 public String getDataFilePath() { 33 String path = properties.getProperty("omero.data.dir"); 34 return path; 35 } 13 14 private final String SPRING_FILE_PATH = "components/romio/resources/beanRefContext.xml"; 15 16 private final String OMERO_PROPS = "classpath:omero.properties"; 17 18 private static PathUtil instance = null; 19 20 private static Properties properties; 21 22 private PathUtil() { 23 properties = new Properties(); 24 File f = null; 25 FileInputStream fis = null; 26 try { 27 f = ResourceUtils.getFile(OMERO_PROPS); 28 fis = new FileInputStream(f); 29 properties.load(fis); 30 } catch (IOException e) { 31 throw new InternalException("Could not load omero.properties:"); 32 } finally { 33 if (fis != null) { 34 try { 35 fis.close(); 36 } catch (Exception e) { 37 // ok 38 } 39 } 40 } 41 } 42 43 public static PathUtil getInstance() { 44 if (instance == null) { 45 return new PathUtil(); 46 } else { 47 return instance; 48 } 49 } 50 51 public String getDataFilePath() { 52 String path = properties.getProperty("omero.data.dir"); 53 return path; 54 } 36 55 37 56 }
