ColdUpdateOpenMISInit.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2006 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: pdelrieu@openmobileis.org
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00020  * USA
00021  *
00022  *  Author : Philippe Delrieu
00023  *
00024  */
00025 
00026 package org.openmobileis.bundle.coldupdate.terminal;
00027 
00028 import java.io.File;
00029 import java.util.Properties;
00030 
00031 import org.openmobileis.common.intl.IntlResourceManager;
00032 import org.openmobileis.common.util.PropertiesManager;
00033 import org.openmobileis.common.util.exception.ServiceException;
00034 import org.openmobileis.common.util.log.FileOpenCloseLogManager;
00035 import org.openmobileis.common.util.log.LogManager;
00036 import org.openmobileis.database.fastobjectdb.FastObjectDBManager;
00037 import org.openmobileis.database.fastobjectdb.synchro.client.SynchroFastObjectDBManager;
00038 import org.openmobileis.module.terminal.ModuleManager;
00039 import org.openmobileis.services.servlet.OpenMISInit;
00040 
00041 public class ColdUpdateOpenMISInit implements OpenMISInit {
00042 
00043   public ColdUpdateOpenMISInit() {
00044     super();
00045   }
00046 
00047   public void preLoadingInit() throws ServiceException {
00048 
00049     //init of log management. If the directory log exist, the logmanager log in the log/openmislog.txt file.
00050     // otherwise it log on the console
00051     Properties  props = new Properties();
00052     props.put("org.openmobileis.common.log.file", System.getProperty("user.dir")+"/WEB-INF/log/openmislog.txt");
00053     File file = new File(System.getProperty("user.dir")+"/WEB-INF/log");
00054     if (file.exists())   FileOpenCloseLogManager.registerLogManager(props); //log to a file
00055     else LogManager.registerLogManager(null); //log to a file
00056 
00057     //init db propeties.
00058     PropertiesManager.getManager().addProperty("fastobjectdb.database.path", System.getProperty("user.dir")+"/database");
00059     PropertiesManager.getManager().addProperty("fastobjectdb.database.name", "db");
00060 
00061     //init internationalization management.
00062     try {
00063       String locale = IntlResourceManager.getManager().getSystemDefaultLocale();
00064       IntlResourceManager.getManager().addLocalizedProperties(System.getProperty("user.dir")+"/WEB-INF/conf/properties/systemmessages.properties", locale);
00065     } catch (Throwable ex)      {
00066       LogManager.traceError(0, ex);
00067     }
00068 
00069     //init synchro properties
00070     PropertiesManager.getManager().addProperty("org.openmobileis.synchro.client.openmsp.numsyncpropsfile",System.getProperty("user.dir") + "/WEB-INF/conf/numsync.txt");
00071     try {
00072         FastObjectDBManager.registerManager(new SynchroFastObjectDBManager()); //init synchro db to be use as default db
00073     } catch (Throwable ex)  {
00074       throw new ServiceException(ex);
00075     }
00076 
00077 
00078  }
00079 
00080   public void postLoadingInit() throws ServiceException {
00081     ModuleManager.getManager().registerModuleManagerListener(new ColdUpdateModuleManagerListener());
00082     ModuleManager.getManager().initModule();
00083   }
00084 
00085 }

Generated on Mon Jan 14 17:29:45 2008 for OpenMobileIS by  doxygen 1.5.4