WebServerActivator.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 package org.openmobileis.bundle.osgi;
00026 
00027 import java.io.IOException;
00028 
00029 import org.openmobileis.common.context.ApplicationContextManager;
00030 import org.openmobileis.common.context.Plateform;
00031 import org.openmobileis.embedded.util.SystemAPI;
00032 import org.openmobileis.embedded.webserver.WebServer;
00033 import org.osgi.framework.BundleActivator;
00034 import org.osgi.framework.BundleContext;
00035 
00043 public final class WebServerActivator implements BundleActivator {
00044   class StartServerBunble implements Runnable {
00045     StartServerBunble(){}
00046     
00047     public void run() {
00048       try  {
00049         System.out.println("start WebServer");
00050         System.out.println("User dir:"+System.getProperty("user.dir"));
00051         
00052 
00053           WebServer server = new WebServer();
00054                   
00055           server.serve();
00056         } catch (IOException ex)  {
00057           System.out.println("Server already started");
00058             // start IE
00059             Plateform plateform = ApplicationContextManager.getManager().getApplicationContext().getPlateform();
00060             if (plateform.getOS().equals(Plateform.POCKETPCOS)) {
00061               System.out.println("start IE alone.");
00062 //              System.loadLibrary("ExecDLL2002");
00063               // SystemAPI.execProgram("\\Windows\\iexplore.exe", "http://localhost:9090/services/index/"+Long.toString(SystemAPI.currentTimeInMillis())); //use to correct a bug in IE that deos not reload page
00064               SystemAPI.execProgram("\\Windows\\iexplore.exe", ""); //use to correct a bug in IE that deos not reload page
00065             }
00066             System.exit(0);
00067         }
00068     }
00069   }
00073   public WebServerActivator() {
00074     super();
00075   }
00076 
00077   /* (non-Javadoc)
00078    * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
00079    */
00080   public void start(BundleContext context) throws Exception {
00081     StartServerBunble tostart = new StartServerBunble();
00082     Thread thread = new Thread(tostart);
00083     thread.start();
00084     
00085     //load profil.
00086    // context.installBundle()
00087 
00088   }
00089 
00090   /* (non-Javadoc)
00091    * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
00092    */
00093   public void stop(BundleContext context) throws Exception {
00094   }
00095 
00096 }

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