kingwong
发贴: 65
积分: 10
|
于 2004-10-26 16:23
现在有一个基于socket的应用程序,为了实现对这些socket连接sessions的管理,准备在应用程序中嵌入 jetty 来实现。参考了一些网上的资料,作了一个简单的集成(不知道对不对?后面有描述),然后在命令行下,同时启动 jetty 和 application。接着在IE中通过一个简单的JSP访问 application 里面的一个public 的 Hashtable(简单访问它的大小,在application启动时会初始化,控制台上有输出显示。),结果显示其 size 为 0 。
具体步骤如下: 1、启动Jetty的线程 LaunchJetty : import org.mortbay.jetty.Server;
public class LaunchJetty implements Runnable { public void run() { Server.main(new String[] { "etc/jetty.xml" }); } } 2、启动application的线程 LaunchTnGateWay: 同1类似。 3、命令行下启动程序 Launcher: public class Launcher { public static void main(String[] args) { Thread ljetty = new Thread(new LaunchJetty()); ljetty.start(); Thread lgateway = new Thread(new LaunchTnGateWay()); lgateway.start(); } }
4、控制台上的部分输出: ...... ---------- gateway.cluster.size() is :5 ---------- WI IN MI IL OH -------------------------------------------------- 2004/10/26 15:52:11:950 CST [DEBUG] TnGateway - creating Daemon Socket ... 15:52:12.107 EVENT Statistics on = false for org.mortbay.jetty.Server@a470b8 15:52:12.107 EVENT Starting Jetty/4.2.22 15:52:12.169 EVENT Started org.mortbay.http.NCSARequestLog@bd928a 2004/10/26 15:52:12:278 CST [DEBUG] TnGateway - daemon is ready to accept connec t on port 2323 15:52:12.513 EVENT Started WebApplicationContext[/test,CyberObject Demo Root] 15:52:12.732 EVENT Started WebApplicationContext[/TnGateWayConsole,file:/D:/MyH ttpd/webapps/TnGateWayConsole/] 15:52:12.810 EVENT Started SocketListener on 0.0.0.0:8080 15:52:12.810 EVENT Started AJP13Listener on 0.0.0.0:8009 15:52:12.810 EVENT NOTICE: AJP13 is not a secure protocol. Please protect the p ort 0.0.0.0:8009 15:52:12.810 EVENT Started org.mortbay.jetty.Server@a470b8
5、测试JSP部分输出: co.tn.gateway.TnGateway@164b09c cluster.size() = 0
请朋友们指点一下。谢先!
|