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

Generated on Mon Dec 4 11:03:30 2006 for OpenMobileIS by  doxygen 1.5.1-p1