1 package org.tigris.scarab.util; 2 3 48 49 import java.io.File ; 50 import java.io.InputStream ; 51 import java.util.Properties ; 52 53 import org.apache.log4j.PropertyConfigurator; 54 import org.apache.turbine.TurbineConfig; 55 56 65 public class TurbineInitialization 66 { 67 private static String lTrProps = "/WEB-INF/conf/TurbineResources.properties"; 68 69 protected static void initTurbine (String configDir) 70 throws Exception 71 { 72 TurbineConfig tc = new TurbineConfig(configDir, lTrProps); 73 tc.init(); 74 } 75 76 public static void setTurbineResources(String trProps) 77 { 78 lTrProps = trProps; 79 } 80 81 public static void setUp(String configDir, String configFile) 82 throws Exception 83 { 84 if (configDir == null || configFile == null) 85 { 86 System.err.println("config.dir System property was not defined"); 87 throw new Exception ("configDir or configFile was null"); } 89 90 System.getProperties().setProperty("configDir", configDir); 93 94 initTurbine(configDir); 95 96 InputStream is = new File (configDir + configFile).toURL() 97 .openStream(); 98 Properties props = new Properties (); 99 try 100 { 101 props.load(is); 102 PropertyConfigurator.configure(props); 104 } 105 catch (Exception e) 106 { 107 System.err.println("Can't read the properties file (" + 108 configDir + configFile + "). "); 109 } 110 } 111 } 112 | Popular Tags |