package com.haso.flexjavaDemo.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.haso.flexjavaDemo.po.Tick;
import flex.messaging.MessageBroker;
import flex.messaging.messages.AsyncMessage;
import flex.messaging.util.UUIDUtils;
public class TickCacheServlet extends HttpServlet {
private static FeedThread thread;
/**
* Constructor of the object.
*/
public TickCacheServlet() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// response.setContentType("text/html");
// PrintWriter out = response.getWriter();
// out
// .println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
// out.println("<HTML>");
// out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
// out.println(" <BODY>");
// out.print(" This is ");
// out.print(this.getClass());
// out.println(", using the GET method");
// out.println(" </BODY>");
// out.println("</HTML>");
// out.flush();
// out.close();
String cmd = request.getParameter("cmd");
if (cmd.equals("start")) {
start();
}
if (cmd.equals("stop")) {
stop();
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doGet(request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
public void start() {
if (thread == null) {
thread = new FeedThread();
thread.start();
}
System.out.println("start!!");
}
public void stop() {
thread.running = false;
thread = null;
}
public static class FeedThread extends Thread {
public boolean running = true;
public void run() {
MessageBroker msgBroker = MessageBroker.getMessageBroker(null);
String clientID = UUIDUtils.createUUID();
int i = 0;
while (running) {
Tick tick = new Tick();
tick.setAskPrice(new BigDecimal("100"));
tick.setBidPrice(new BigDecimal("100"));
tick.setMidPrice(new BigDecimal("100"));
tick.setTickTime(new Date());
tick.setSeqno(String.valueOf(i));
System.out.println(i);
AsyncMessage msg = new AsyncMessage();
msg.setDestination("tick-data-feed");
msg.setHeader("DSSubtopic", "tick");
msg.setClientId(clientID);
msg.setMessageId(UUIDUtils.createUUID());
msg.setTimestamp(System.currentTimeMillis());
msg.setBody(tick);
msgBroker.routeMessageToService(msg, null);
i++;
try {
Thread.sleep(20);
} catch (InterruptedException e) {
}
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
新版Flex4下Java与BlazeDs整合的项目(含远程调用和消息服务示例)
共66个文件
jar:11个
swf:11个
xml:6个
温馨提示
RT 已经含有了blazeDs.war FlashBuilder4 Tomcat6下测试通过~ 先启动后台服务 http://localhost:8080/Flex4JavaDemo/TickCacheServlet?cmd=start http://localhost:8080/Flex4JavaDemo/message.html
资源推荐
资源详情
资源评论
收起资源包目录
Flex4+BlazeDs+Java.rar (66个子文件)
Flex4JavaDemo
.project 2KB
flex_libs
.settings
org.eclipse.core.resources.prefs 88B
org.eclipse.wst.common.component 531B
org.eclipse.jdt.core.prefs 629B
org.eclipse.wst.common.project.facet.core.xml 269B
.actionScriptProperties 1KB
html-template
swfobject.js 25KB
index.template.html 5KB
history
history.js 25KB
historyFrame.html 798B
history.css 365B
playerProductInstall.swf 657B
src
com
haso
flexjavaDemo
test
TestSpring.java 523B
servlet
TickCacheServlet.java 4KB
spring
Test.java 264B
po
Tick.java 939B
util
FlexSpringFactory.java 3KB
.springBeans 415B
WebContent
spark_4.0.0.14159.swf 490KB
WEB-INF
flex
messaging-config.xml 806B
remoting-config.xml 536B
services-config.xml 6KB
version.properties 73B
proxy-config.xml 826B
web.xml 3KB
spring-form.tld 69KB
src
spring.tld 13KB
lib
commons-logging.jar 37KB
cfgatewayadapter.jar 15KB
flex-messaging-proxy.jar 65KB
commons-httpclient-3.0.1.jar 273KB
flex-messaging-remoting.jar 18KB
commons-codec-1.3.jar 46KB
flex-messaging-common.jar 94KB
flex-messaging-core.jar 669KB
flex-messaging-opt.jar 20KB
flex-rds-server.jar 53KB
xalan.jar 3MB
classes
com
haso
flexjavaDemo
test
servlet
TickCacheServlet.class 2KB
TickCacheServlet$FeedThread.class 2KB
spring
Test.class 935B
po
Tick.class 1KB
util
swfobject.js 25KB
sparkskins_4.0.0.14159.swf 68KB
META-INF
MANIFEST.MF 254B
Message.html 5KB
osmf_flex.4.0.0.13495.swf 147KB
Flex4JavaDemo.html 5KB
Flex4JavaDemo.swf 81KB
index.swf 75KB
history
history.js 25KB
historyFrame.html 798B
history.css 365B
playerProductInstall.swf 657B
framework_4.0.0.14159.swf 1013KB
rpc_4.0.0.14159.swf 203KB
textLayout_1.0.0.595.swf 256KB
index.html 5KB
Message.swf 80KB
.classpath 858B
flex_src
index.mxml 467B
com
haso
flex
po
remote
Tick.as 285B
Flex4JavaDemo.mxml 1KB
Message.mxml 2KB
.flexProperties 386B
blazeds.war 3.94MB共 66 条
- 1
君望永远
- 粉丝: 1627
上传资源 快速赚钱
我的内容管理
展开
我的资源
快来上传第一个资源
我的收益 登录查看自己的收益
我的积分
登录查看自己的积分
我的C币
登录后查看C币余额
我的收藏
我的下载
下载帮助
前往需求广场,查看用户热搜最新资源
- 自然语言处理中的技术评测.pdf
- 赵晋伟特殊零件的编程及加工新.doc
- 高中程序设计方案教学中培养学生反思性学习能力陈伟平金炳尧.doc
- 大数据时代我国平台金融的发展趋势研究.docx
- 简约经典学院风信息化教学教育课件说课动态模板.pptx
- 计算机组成原理实验课程网络在线试验平台建设模式的思考.doc
- 物债二分体系下网络虚拟财产权的再审视.docx
- 脑机接口技术在医疗健康领域应用白皮书.docx
- 计算机网络安全问题研究.docx
- PLC课程设计(青岛理工)(自动门控制-全自动洗衣机控制).doc
- 优化方案2017高中数学-第2章-算法初步-3.3.1-条件语句北师大版必修3.ppt
- 计算机技术在办公自动化中的应用.docx
- 中文机器阅读理解相关数据集汇总
- 五年级下册信息技术导学案第1课-网络漫游.ppt
- Java实验研究报告.doc
- 网络空间主权维护-洞察研究.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页