SimpleOpenMISInit.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.services.servlet;
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.services.servlet.OpenMISInit;
00039 
00040 public class SimpleOpenMISInit implements OpenMISInit {
00041 
00042   public SimpleOpenMISInit() {
00043     super();
00044   }
00045 
00046   public void preLoadingInit() throws ServiceException {
00047 
00048     //init of log management. If the directory log exist, the logmanager log in the log/openmislog.txt file.
00049     // otherwise it log on the console
00050     Properties  props = new Properties();
00051     props.put("org.openmobileis.common.log.file", System.getProperty("user.dir")+"/WEB-INF/log/openmislog.txt");
00052     File file = new File(System.getProperty("user.dir")+"/WEB-INF/log");
00053     if (file.exists())   FileOpenCloseLogManager.registerLogManager(props); //log to a file
00054     else LogManager.registerLogManager(null); //log to a file
00055 
00056     //init db propeties.
00057     PropertiesManager.getManager().addProperty("fastobjectdb.database.path", System.getProperty("user.dir")+"/database");
00058     PropertiesManager.getManager().addProperty("fastobjectdb.database.name", "db");
00059 
00060     //init internationalization management.
00061     try {
00062       String locale = IntlResourceManager.getManager().getSystemDefaultLocale();
00063       IntlResourceManager.getManager().addLocalizedProperties(System.getProperty("user.dir")+"/WEB-INF/conf/properties/systemmessages.properties", locale);
00064     } catch (Throwable ex)      {
00065       LogManager.traceError(0, ex);
00066     }
00067 
00068     //init synchro properties
00069     PropertiesManager.getManager().addProperty("org.openmobileis.synchro.client.openmsp.numsyncpropsfile",System.getProperty("user.dir") + "/WEB-INF/conf/numsync.txt");
00070     try {
00071       FastObjectDBManager.registerManager(new SynchroFastObjectDBManager()); //init synchro db to be use as default db
00072     } catch (Throwable ex)  {
00073       throw new ServiceException(ex);
00074     }
00075 
00076  }
00077 
00078   public void postLoadingInit() throws ServiceException {
00079   }
00080 
00081 }

Generated on Mon Jan 11 21:19:16 2010 for OpenMobileIS by  doxygen 1.5.4