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

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