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
00026
00027
00028
00029
00030 package org.openmobileis.embedded.webserver;
00031 import java.net.*;
00032
00033 import org.openmobileis.common.util.log.*;
00034
00042 public class ServerThread implements Runnable {
00043
00044 private WebServerConnection connexion;
00045 private Object waiter;
00046 private ServerThreadPool threadPool;
00047
00048 public ServerThread() {
00049 waiter = new Object();
00050 connexion = new WebServerConnection();
00051 Thread thread = new Thread( this );
00052 thread.start();
00053 }
00054
00055 public void run() {
00056 while (true) {
00057 try {
00058 synchronized (waiter) {
00059 try {
00060 if (threadPool != null) {
00061 threadPool.disposeObject(this);
00062 }
00063 waiter.wait();
00064 } catch (Exception ex) {
00065 LogManager.traceError(0, ex);
00066 }
00067 }
00068 connexion.run();
00069 } catch (Throwable ex) {
00070 LogManager.traceError(LogServices.WEBSERVICE,"ServerThread run connexion error");
00071 LogManager.traceError(LogServices.WEBSERVICE,ex);
00072 }
00073 }
00074 }
00075
00076 public void init(WebServer webserver, Socket socket,ServerThreadPool pool) {
00077 threadPool = pool;
00078 connexion.init(webserver, socket);
00079 synchronized (waiter) {
00080 waiter.notify();
00081 }
00082 }
00083
00084 public WebServerConnection getConnexion() {
00085 return connexion;
00086 }
00087
00088
00089 }