1 package org.enhydra.pim.business; 2 3 import org.enhydra.dods.DODS; 4 import org.enhydra.pim.business.api.CommonConstants; 5 6 import com.lutris.appserver.server.sql.DatabaseManagerException; 7 import com.lutris.appserver.server.sql.LogicalDatabase; 8 import com.lutris.logging.LogChannel; 9 import com.lutris.logging.Logger; 10 11 16 public class PimBase { 17 18 private static LogicalDatabase primaryDatabase = null; 19 20 private static LogicalDatabase backupDatabase = null; 21 22 private static LogChannel logChannel = null; 23 24 public static LogicalDatabase getPrimaryDatabase() { 25 if (primaryDatabase == null) { 26 try { 27 primaryDatabase = DODS.getDatabaseManager().findLogicalDatabase(CommonConstants.productionDatabaseName); 28 } catch (DatabaseManagerException e) { 29 e.printStackTrace(); 30 } 31 } 32 return primaryDatabase; 33 } 34 35 public static LogicalDatabase getBackupDatabase() { 36 if (backupDatabase == null) { 37 try { 38 backupDatabase = DODS.getDatabaseManager().findLogicalDatabase(CommonConstants.backupDatabaseName); 39 } catch (DatabaseManagerException e) { 40 e.printStackTrace(); 41 } 42 } 43 return backupDatabase; 44 } 45 46 public static LogChannel getLogChannel() { 47 if (logChannel == null) { 48 logChannel = DODS.getLogChannel(); 49 } 50 return logChannel; 51 } 52 53 public static void logError(String error) { 54 getLogChannel().write(Logger.ERROR, error); 55 } 56 57 public static void logInfo(String info) { 58 getLogChannel().write(Logger.INFO, info); 59 } 60 61 public static void logDebug(String debug) { 62 getLogChannel().write(Logger.DEBUG, debug); 63 } 64 65 } | Popular Tags |