Re: [Simpleweb-Support] hello,please help me! (sourceforge form)
                
                Brought to you by:
                
                    niallg
                    
                
            
            
        
        
        
    | 
     
      
      
      From: lyo <liy...@ho...> - 2009-01-03 03:08:52
      
     
   | 
Hi friends:
     I do it by using ThreadDumper.java(in the dir: simple-4.0.6\test\src\org\simpleframework\http\core).But the server thread remain not shutdown immediately.I means there is an javaw.exe in my windows process.My code is:
//////////////////// java code //////////////////
public class TestSimpleServer   implements Container  {
 
 private static final Log log = LogFactory.getLog(TestSimpleServer.class);
 static ContainerServer processor =null;
 static Connection connection = null;
 static Server server = null;
 static  private ThreadDumper threadDumper;
  
 /**
  * @param args
  */
 public static void main(String[] args)throws Exception {
  // TODO Auto-generated method stub
   Container container = new TestSimpleServer();
   server = new ContainerServer(container, 10);//what does the 10 mean? my server should be connected by 1000 clients.
   connection = new SocketConnection(server);
   SocketAddress address = new InetSocketAddress(8080);
   connection.connect(address);
   threadDumper = new ThreadDumper(60000); // dump threads every minute
   threadDumper.start();
  
       
 }
 public void handle(Request arg0, Response response) {
  log.info("### Enter hendle");
  String param;
  try {
   param = arg0.getParameter("id");
   log.info(">>> param:"+param);
   if("s".equals(param)){               // if client send parameter "s",then the server shutdown!
     connection.close();
     server.stop();
     threadDumper.kill();
   }else{
    PrintStream body=null;
    body = response.getPrintStream();
    long time = System.currentTimeMillis();
         response.set("Content-Type", "text/html");
         response.set("Server", "HelloWorld/1.0 (Simple 4.0)");
         response.setDate("Date", time);
         response.setDate("Last-Modified", time);
         
         body.println("<font color='red'>Test it</font>");
         body.close();
    
   }
  } catch (Exception e) {
   e.printStackTrace();
  }
  
 }
}
/////////////////  end ////////////////////////
I don't want to keep an javaw.exe in my windows process  :( .  So what should I do?Thks!
  ----- Original Message ----- 
  From: lyo 
  To: gal...@ya... ; sim...@li... 
  Sent: Saturday, January 03, 2009 2:37 AM
  Subject: hello,please help me! (sourceforge form)
  hello:
     I don't know how to reply this thread:http://sourceforge.net/mailarchive/message.php?msg_name=266712.48202.qm%40web36702.mail.mud.yahoo.com
  So I send this email to you. I stop server in your way:
  /////////////// java code //////////////////
   Container container = new TestSimpleServer();
     Server server = new ContainerServer(container, 10);
     Connection connection = new SocketConnection(server);
     SocketAddress address = new InetSocketAddress(8080);
     connection.connect(address);
     connection.close();
     server.stop();
  ///////////////////////////////////////////
  but the server throws Exception:
  ////////////////////////////////////////////////
  java.nio.channels.ClosedChannelException
   at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:130)
   at org.simpleframework.http.connect.Acceptor.accept(Acceptor.java:147)
   at org.simpleframework.http.connect.Acceptor.run(Acceptor.java:104)
   at org.simpleframework.util.select.SelectEvent.run(SelectEvent.java:74)
   at org.simpleframework.util.thread.DirectExecutor.execute(DirectExecutor.java:43)
   at org.simpleframework.util.select.EventDistributor.process(EventDistributor.java:386)
   at org.simpleframework.util.select.EventDistributor.process(EventDistributor.java:365)
   at org.simpleframework.util.select.EventDistributor.distribute(EventDistributor.java:342)
   at org.simpleframework.util.select.EventDistributor.run(EventDistributor.java:150)
  //////////////////////////////////////////////////
  And the server don't stop. What should I do?
 |