00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00059 Plateform plateform = ApplicationContextManager.getManager().getApplicationContext().getPlateform();
00060 if (plateform.getOS().equals(Plateform.POCKETPCOS)) {
00061 System.out.println("start IE alone.");
00062
00063
00064 SystemAPI.execProgram("\\Windows\\iexplore.exe", "");
00065 }
00066 System.exit(0);
00067 }
00068 }
00069 }
00073 public WebServerActivator() {
00074 super();
00075 }
00076
00077
00078
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
00086
00087
00088 }
00089
00090
00091
00092
00093 public void stop(BundleContext context) throws Exception {
00094 }
00095
00096 }