ColdUpdateServerOpenMISInit.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.server;
00027 
00028 import java.io.File;
00029 import java.io.FileReader;
00030 import java.io.Reader;
00031 import java.util.Properties;
00032 
00033 import org.openmobileis.common.user.UserManager;
00034 import org.openmobileis.common.user.impl.MonoUserUserManagerFactory;
00035 import org.openmobileis.common.util.exception.ServiceException;
00036 import org.openmobileis.common.util.log.FileOpenCloseLogManager;
00037 import org.openmobileis.common.util.log.LogManager;
00038 import org.openmobileis.module.profiles.server.ProfilManagerSyncTarget;
00039 import org.openmobileis.services.servlet.OpenMISInit;
00040 import org.openmobileis.synchro.algo.syncnumber.SyncNumberManager;
00041 import org.openmobileis.synchro.algo.syncnumber.impl.EmptySyncNumberManagerDelegate;
00042 import org.openmobileis.synchro.openmsp.server.synctarget.SynchroTargerManager;
00043 import org.openmobileis.synchro.openmsp.server.synctarget.proxy.GenericProxySynchroTarget;
00044 
00045 public class ColdUpdateServerOpenMISInit implements OpenMISInit {
00046 
00047   public ColdUpdateServerOpenMISInit() {
00048     super();
00049   }
00050 
00051   public void preLoadingInit() throws ServiceException {
00052     
00053     //init of log management. If the directory log exist, the logmanager log in the log/openmislog.txt file.
00054     // otherwise it log on the console
00055     Properties  props = new Properties();
00056     props.put("org.openmobileis.common.log.file", System.getProperty("user.dir")+"/WEB-INF/log/openmislog.txt");
00057     File file = new File(System.getProperty("user.dir")+"/WEB-INF/log");
00058     if (file.exists())   FileOpenCloseLogManager.registerLogManager(props); //log to a file
00059     else LogManager.registerLogManager(null); //log to a file
00060     
00061     // init user manager with the default impl with one user. Login:test Pwd:test
00062     //to authenticate to another source, use your UserManagerFactory
00063     UserManager.getManager().registerUserManagerFactoryForGroup("default", new MonoUserUserManagerFactory());
00064     //the simpliest syncnumber. Start at 0 at each server start.
00065     SyncNumberManager.getManager().registerDelegate(new EmptySyncNumberManagerDelegate());
00066  
00067     
00068     //init profil management 
00069     //register a profil for a group.
00070     //reader contain the profil file.
00071     try {
00072             Reader reader = new FileReader(System.getProperty("user.dir")+"/profils/baseprofil.xml");
00073         //    TerminalXmlProfilParser serverprofilmanager = new TerminalXmlProfilParser(reader);
00074         //    ProfileDataManager.getManager().registerProfilDataFactoryForGroup("default", serverprofilmanager);
00075     } catch (Throwable ex)      {
00076         LogManager.traceError(0, ex);
00077     }
00078 
00079     //register profil listener target.
00080     ProfilManagerSyncTarget target = new ProfilManagerSyncTarget();
00081     SynchroTargerManager.getManager().addSynchroTargetListener(target, null, null);
00082     
00083     //init module jar files synchronisation
00084    // ColdUpdateModuleLoader.getManager();
00085     
00086     // to be added to work with a servlet server.
00087     SynchroTargerManager.getManager().registerProxyTargetForTerminal(new GenericProxySynchroTarget(), null);      
00088 }
00089 
00090   public void postLoadingInit() throws ServiceException {
00091   }
00092 
00093 }

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