Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

TestOpenMSPSynchro.java

00001 /*
00002  * OpenMobileIS - a free Java(TM) Framework for mobile applications Java(TM)
00003  * Copyright (C) 2004-2005 Philippe Delrieu
00004  * All rights reserved.
00005  * Contact: openmobileis@e-care.fr
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 package org.openmobileis.synchro.openmsp.protocol.test;
00026 
00027 import java.util.Properties;
00028 
00029 import org.openmobileis.common.user.UserManager;
00030 import org.openmobileis.common.user.impl.MonoUserUserManagerFactory;
00031 import org.openmobileis.common.user.profil.ProfilDataManager;
00032 import org.openmobileis.common.user.profil.impl.XmlFileProfilDataFactory;
00033 import org.openmobileis.common.util.PropertiesManager;
00034 import org.openmobileis.common.util.log.LogManager;
00035 import org.openmobileis.embedded.webserver.WebServer;
00036 import org.openmobileis.synchro.client.SynchroDescriptor;
00037 import org.openmobileis.synchro.client.SynchroManager;
00038 import org.openmobileis.synchro.openmsp.client.OpenMSPSynchroManager;
00039 import org.openmobileis.synchro.openmsp.client.conduit.HttpOpenMSPSynchroConduit;
00040 import org.openmobileis.synchro.openmsp.server.synctarget.SynchroTargerManager;
00041 import org.openmobileis.synchro.openmsp.server.synctarget.proxy.GenericProxySynchroTarget;
00042 import org.openmobileis.synchro.security.auth.Credential;
00043 
00051 public final class TestOpenMSPSynchro {
00052 
00056   public TestOpenMSPSynchro() {
00057     super();
00058   }
00059 
00063   public static void main(String[] args) {
00064     //init 
00065     LogManager.registerLogManager(null);
00066     //init Terminal side.
00067     //load synchro properties
00068     try {
00069       PropertiesManager.getManager().addProperty("org.openmobileis.synchro.client.openmsp.numsyncpropsfile",System.getProperty("user.dir") + "/WEB-INF/conf/numsync.txt");
00070       OpenMSPSynchroManager.getManager().addListener(new TestOpenMSSyncListener(), null);
00071       SynchroManager.getManager().registerSynchroProcessor(OpenMSPSynchroManager.getManager());
00072   
00073       //init Synchro Server side.
00074       PropertiesManager.getManager().addProperty("org.openmobileis.common.user.profil.xmlprofilfile.path",System.getProperty("user.dir") + "/WEB-INF/conf/defaultprofils.xml");
00075       SynchroTargerManager.getManager().addSynchroTargetListener(new TestOpenMSPSynchroTargetListener(), null, null);
00076       UserManager.getManager().registerUserManagerFactoryForGroup("default", new MonoUserUserManagerFactory());
00077       ProfilDataManager.getManager().registerProfilDataFactoryForGroup("default", new XmlFileProfilDataFactory());
00078       SynchroTargerManager.getManager().addSynchroTargetListener(new TestOpenMSPSynchroTargetListener(), null, null);
00079       SynchroTargerManager.getManager().registerProxyTargetForTerminal(new GenericProxySynchroTarget(), null);
00080       
00081       //start server
00082       Runnable startWebServer = new Runnable() {
00083   
00084         public void run() {
00085           try {
00086   
00087             System.out.println("start WebServer");
00088   
00089             Properties props = new Properties();
00090             props.put("LOGFILE", System.getProperty("user.dir") + "/WEB-INF/log/server/log");
00091             LogManager.registerLogManager(props); //log to a file
00092   
00093             WebServer server = null;
00094             server = new WebServer();
00095   
00096             server.serve();
00097           } catch (Throwable ex) {
00098             ex.printStackTrace();
00099           }
00100         }
00101   
00102       };
00103       Thread th = new Thread(startWebServer);
00104       th.start();
00105       //do synchro
00106       //wait 1 second until the webserver is started.
00107       Thread.currentThread().sleep(1000);
00108       Credential cred = new Credential("test", "test");
00109       SynchroDescriptor descriptor = new SynchroDescriptor();
00110       descriptor.setSynchroConduit(new HttpOpenMSPSynchroConduit(System.getProperty("user.dir") + "/synchro","OpenMSPPlug-WI-V1.0-WINCE[DR-FR-WINCE/04-02-00-00]"));
00111       descriptor.setSynchroGroup("default");
00112       descriptor.setServerURL("http://localhost:9091/services/openmspservice");
00113       
00114       SynchroManager.getManager().doSynchro(cred, descriptor);
00115       
00116     } catch (Throwable ex)  {
00117       LogManager.traceError(0, ex);
00118     }
00119   }
00120 
00121 }

Generated on Wed Dec 14 21:05:35 2005 for OpenMobileIS by  doxygen 1.4.4