??xml version="1.0" encoding="utf-8" standalone="yes"?>91精品久久久久久9s密挑,国产精品日韩电影,禁断一区二区三区在线http://www.aygfsteel.com/zhanglijun33/archive/2017/02/23/432335.html无?/dc:creator>无?/author>Thu, 23 Feb 2017 03:26:00 GMThttp://www.aygfsteel.com/zhanglijun33/archive/2017/02/23/432335.htmlhttp://www.aygfsteel.com/zhanglijun33/comments/432335.htmlhttp://www.aygfsteel.com/zhanglijun33/archive/2017/02/23/432335.html#Feedback0http://www.aygfsteel.com/zhanglijun33/comments/commentRss/432335.htmlhttp://www.aygfsteel.com/zhanglijun33/services/trackbacks/432335.htmlNW.js入门

NW.js能做什么?

NW.js是基?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">?/a>?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">Node.js?/a>。它允许您直接从览器调用Node.js代码和模块,q在您的应用E序中用Web技术。此外,您可以轻村֜Web应用E序打包到本机应用程序?/p>

获取NW.js

您可以从官方|站http://nwjs.io获取最新的二进制文件。或者你也可以徏立NW.js按照中的说明二进制文件自?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">NW.js?br />

提示Q?/p>

您选择SDK构徏风格来开发您的应用程序,q您能够用DevTools调试您的应用E序。有?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">构徏版本之间的差异,请参?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">构徏版本?br />

~写NW.js应用E序


CZ1 - Hello World

q个基本CZ演示如何~写一个NW.js应用E序?/p>

步骤1.创徏package.jsonQ?/p>

{    “name” Q?/span> “helloworld” Q?/span>   “main” Q?/span> “index.html”  } 

package.json是您的应用程序中的清单文件。它是以JSON格式~写的。该main字段昄?code style="box-sizing: border-box; font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; font-size: 12px; white-space: pre; max-width: 100%; border: 1px solid #e1e4e5; padding: 0px 5px; color: #e74c3c; overflow-x: auto; word-wrap: break-word; background: #ffffff;">"index.html"在本CZ中由NW.js打开的第一(如果引用了HTML文gQ。该name字段是在NW.js应用E序中用的唯一名称。有兌l信息,请参?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">清单格式?/p>

使用JS文g作ؓ?/p>

你可以把JS文g讄?code style="box-sizing: border-box; font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; font-size: 12px; white-space: pre; max-width: 100%; border: 1px solid rgba(0, 0, 0, 0.2); padding: 0px 5px; overflow-x: auto; word-wrap: break-word; background: rgba(255, 255, 255, 0.701961);">"main"字段Q如"main.js"。然后,JS文g在开始时加蝲到后台页面,默认情况下不打开MH口。通常你可以做一些初始化Q然后手动打开H口。例如,

// initialize your app  // and ...  nw ?/span>H口?/span>open Q?/span>'index.html' Q?/span> {}Q?/span> function Q?/span>win Q?/span> {}Q? 

步骤2.创徏index.htmlQ?/p>

<QDOCTYPE html>  < html >    < head >      < title > Hello WorldQ?span style="box-sizing: border-box;"></ title >    </ head >    < body >      < h1 > Hello WorldQ?span style="box-sizing: border-box;"></ h1 >    </ body >  </ html > 

q是正常的HTML文g。您可以使用最新浏览器支持的Q何Web技术?/p>

步骤3.q行应用E序

cd / path / to / your / app / path / to / nw?

/path/to/nw是NW.js的二q制文g。在Windows上,它的nw.exe; 在Linux上,它的nw; 在MacQ它?code style="box-sizing: border-box; font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; font-size: 12px; white-space: pre; max-width: 100%; border: 1px solid #e1e4e5; padding: 0px 5px; color: #e74c3c; overflow-x: auto; word-wrap: break-word; background: #ffffff;">nwjs.app/Contents/MacOS/nwjs?/p>

在Windows上拖?/p>

在Windows上,您可以拖?code style="box-sizing: border-box; font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; font-size: 12px; white-space: pre; max-width: 100%; border: 1px solid rgba(0, 0, 0, 0.2); padding: 0px 5px; overflow-x: auto; word-wrap: break-word; background: rgba(255, 255, 255, 0.701961);">folder containing package.json?code style="box-sizing: border-box; font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; font-size: 12px; white-space: pre; max-width: 100%; border: 1px solid rgba(0, 0, 0, 0.2); padding: 0px 5px; overflow-x: auto; word-wrap: break-word; background: rgba(255, 255, 255, 0.701961);">nw.exe以运行应用程序?/p>

CZ2 - 使用NW.js API

所有NW.js API都在nw对象中全局加蝲Q可以直接在JavaScript文g中用。有x持的API的完整列表,请参?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">API参?/a>?/p>

此示例显C如何在NW.js应用E序中创建本Z下文菜单。您可以index.html使用以下内容创徏Q?br style="box-sizing: border-box;" />

<QDOCTYPE html>  < html >  < head >    < title >上下文菜?span style="box-sizing: border-box;"></ title >  </ head >  < body  style = “widthQ?00Q? heightQ?00Q?/span>>  < p > “右键单击”昄上下文菜单?span style="box-sizing: border-box;"></ p >  < script >  //创徏一个空的上下文菜单 var  menu  =  new  nw ?/span>Menu Q);  //d一些项目与标签 菜单?/span>q加Q?/span>?/span> NW ?/span>菜单?/span>Q{    标签Q?/span> “目A” Q?/span>   单击Q?/span> 函数Q){      警报Q?/span>'你点M“目A” Q?    }  }Q);  菜单?/span>q加Q?/span>?/span> NW ?/span>菜单?/span>Q{  标签Q?/span> '目B'  }Q);  菜单?/span>q加Q?/span>?/span> NW ?/span>菜单?/span>Q{  cdQ?/span> “分隔W?#8221;  }Q);  菜单?/span>q加Q?/span>?/span> NW ?/span>菜单?/span>Q{  标签Q?/span> '目C'  }Q);  // Hooks“contextmenu”事g 文档?/span>w体?/span>的addEventListener Q?/span>'文本菜单' Q?/span> 函数Q?/span>EV Q?/span> {    //防止昄默认的上下文菜单   EV ?/span>的preventDefault Q);    //弹出的地方,你点LZ下文菜单?/span>   的菜?/span>?/span>弹出Q?/span>EV ?/span>?#175;x Q?/span> EV ?/span>ÿ Q?    return  false ;  }Q?/span> false Q?  </ script >    </ body >  </ html > 

...然后q行您的应用E序Q?br style="box-sizing: border-box;" />

cd / path / to / your / app / path / to / nw?

requireQ?nw.gui'Q?/p>

require('nw.gui')q支持用传l的加蝲NW.js API的方式。它q回相同?code style="box-sizing: border-box; font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; font-size: 12px; white-space: pre; max-width: 100%; border: 1px solid rgba(0, 0, 0, 0.2); padding: 0px 5px; overflow-x: auto; word-wrap: break-word; background: rgba(255, 255, 255, 0.701961);">nw对象?/p>

? - 使用Node.js API

你可以直接从DOM调用node.js和模块。所以它使用nw.js~写应用E序的无限可能?/p>

此示例显C如何?code style="box-sizing: border-box; font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; font-size: 12px; white-space: pre; max-width: 100%; border: 1px solid #e1e4e5; padding: 0px 5px; color: #e74c3c; overflow-x: auto; word-wrap: break-word; background: #ffffff;">osNode.js的模块查询操作系l^台。只需创徏index.htmlh以下内容的文Ӟq用NW.jsq行它?/p>

<QDOCTYPE HTML>  < HTML >  < ?/span>>    < 标题>我的操作pȝq_</ 标题>  </ ?/span>>  < w体>  < 脚本>  //使用Node.js的获取系l^台的 变种 OS  =  要求Q?/span>“OS” Q?  文档?/span>?/span>Q?/span>“您正在运行的' Q?/span> 操作pȝQ?/span>q_Q)Q?  </ script >  </ body >  </ html > 

您还可以使用?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">npmNW.js.安装的模块?/p>

本地节点模块

在运行时构徏的Native Node模块npm install与NW.js ABI不兼宏V要使用它们Q你必须用源代码重徏?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">nw-gyp。有兌l信息,请参?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">使用本机节点模块?/p>

下一步是什?/h2>

请参?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">使用DevTools调试以调试NW.js应用E序?/p>

请参?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">打包和分?/a>Q以便在生中打包和重新分发应用E序?/p>

有关可能遇到?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">问题Q请参阅常见问题解答?/p>

如果您要从NW.js 0.12或旧版本q移应用E序Q请参阅q移说明?/p>

获得帮助

?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">NW.js wiki上有很多有用的信息。维Z是对所有h开攄Q你鼓励你在wiki上发布你的知识?/p>

您也可以在Google组的邮件清?/a>或Gitter上的x通讯中提?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">问题?/p>

h告错误或提交要求?a style="box-sizing: border-box; color: #9b59b6; text-decoration: none;">GitHub使NW.js更强大?/p>



]]>
mysql触发器:每天增加一个随机数?/title><link>http://www.aygfsteel.com/zhanglijun33/archive/2015/08/06/426624.html</link><dc:creator>无?/dc:creator><author>无?/author><pubDate>Thu, 06 Aug 2015 01:26:00 GMT</pubDate><guid>http://www.aygfsteel.com/zhanglijun33/archive/2015/08/06/426624.html</guid><wfw:comment>http://www.aygfsteel.com/zhanglijun33/comments/426624.html</wfw:comment><comments>http://www.aygfsteel.com/zhanglijun33/archive/2015/08/06/426624.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zhanglijun33/comments/commentRss/426624.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zhanglijun33/services/trackbacks/426624.html</trackback:ping><description><![CDATA[     摘要: mysql触发器,5.6版?nbsp; <a href='http://www.aygfsteel.com/zhanglijun33/archive/2015/08/06/426624.html'>阅读全文</a><img src ="http://www.aygfsteel.com/zhanglijun33/aggbug/426624.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zhanglijun33/" target="_blank">无?/a> 2015-08-06 09:26 <a href="http://www.aygfsteel.com/zhanglijun33/archive/2015/08/06/426624.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>tomcat get传值时的中文ؕ码问题?/title><link>http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426102.html</link><dc:creator>无?/dc:creator><author>无?/author><pubDate>Wed, 08 Jul 2015 10:37:00 GMT</pubDate><guid>http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426102.html</guid><wfw:comment>http://www.aygfsteel.com/zhanglijun33/comments/426102.html</wfw:comment><comments>http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426102.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zhanglijun33/comments/commentRss/426102.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zhanglijun33/services/trackbacks/426102.html</trackback:ping><description><![CDATA[<p>server.xml里,connect修改为:</p><p><Connector port="8080" protocol="HTTP/1.1" <br />               connectionTimeout="20000" <br />               redirectPort="8443" <br />       useBodyEncodingForURI="true" <br />    URIEncoding="UTF-8"<br />      /></p><img src ="http://www.aygfsteel.com/zhanglijun33/aggbug/426102.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zhanglijun33/" target="_blank">无?/a> 2015-07-08 18:37 <a href="http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426102.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>myeclipse参数配置http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426101.html无?/dc:creator>无?/author>Wed, 08 Jul 2015 10:33:00 GMThttp://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426101.htmlhttp://www.aygfsteel.com/zhanglijun33/comments/426101.htmlhttp://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426101.html#Feedback0http://www.aygfsteel.com/zhanglijun33/comments/commentRss/426101.htmlhttp://www.aygfsteel.com/zhanglijun33/services/trackbacks/426101.html1.myeclipse参数配置-解决代码不提CZ保存{问?下蝲后去?txtQ然后导入myeclipse里的prefrences.
/Files/zhanglijun33/myeclipse参数配置-解决代码不提CZ保存{问?epf.txt   
2.myeclipse的启动参敎ͼ"D:\install\myeclipse10.7\MyEclipse 10\myeclipse.exe" -clean -Xms256m -Xmx768m -XX:MaxNewSize=256m -XX:MaxPermSize=768m

]]>
apache+jk+tomcat集群+session同步 http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426099.html无?/dc:creator>无?/author>Wed, 08 Jul 2015 10:26:00 GMThttp://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426099.htmlhttp://www.aygfsteel.com/zhanglijun33/comments/426099.htmlhttp://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426099.html#Feedback0http://www.aygfsteel.com/zhanglijun33/comments/commentRss/426099.htmlhttp://www.aygfsteel.com/zhanglijun33/services/trackbacks/426099.html阅读全文

]]>
正常的sqlQ带中文参数Q,在mysql-front里可以查出数据,在程序里却查不出?/title><link>http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426098.html</link><dc:creator>无?/dc:creator><author>无?/author><pubDate>Wed, 08 Jul 2015 10:23:00 GMT</pubDate><guid>http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426098.html</guid><wfw:comment>http://www.aygfsteel.com/zhanglijun33/comments/426098.html</wfw:comment><comments>http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426098.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zhanglijun33/comments/commentRss/426098.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zhanglijun33/services/trackbacks/426098.html</trackback:ping><description><![CDATA[<div><span style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">原因Q中文参数字W编码有问题Q在E序里调试的时候虽然不是ؕ码,但数据库依旧不认识。这需要在jdbc.mysql.url里指定数据库使用的字W编码:utf-8.</span><br style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;" /><span style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">jdbc.properties?/span><br style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;" /><span style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">mysql.jdbc.url=jdbc:mysql://192.168.1.246:3306/wxb_site1?useUnicode=true&characterEncoding=utf-8</span><br style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;" /><span style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">jndi的写法: context.xml里的写法Q?lt;Resource name="jndi/wxb_site"  auth="Container" </span><br style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;" /><span style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">      type="javax.sql.DataSource" username="root" password="root"   </span><br style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;" /><span style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">      driverClassName="com.mysql.jdbc.Driver"</span><span style="font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #ff0000;"> url="jdbc:mysql://192.168.1.246:3306/wxb_site1?useUnicode=true&amp;characterEncoding=utf-8"<br /></span><span style="color: #000000; font-family: verdana, 'courier new'; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 21px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;">   maxActive="100" maxIdle="10" maxWait="-1"/></span></div><img src ="http://www.aygfsteel.com/zhanglijun33/aggbug/426098.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zhanglijun33/" target="_blank">无?/a> 2015-07-08 18:23 <a href="http://www.aygfsteel.com/zhanglijun33/archive/2015/07/08/426098.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JMS服务器openJms入门http://www.aygfsteel.com/zhanglijun33/archive/2009/09/08/JMS.html无?/dc:creator>无?/author>Tue, 08 Sep 2009 03:25:00 GMThttp://www.aygfsteel.com/zhanglijun33/archive/2009/09/08/JMS.htmlhttp://www.aygfsteel.com/zhanglijun33/comments/294271.htmlhttp://www.aygfsteel.com/zhanglijun33/archive/2009/09/08/JMS.html#Feedback1http://www.aygfsteel.com/zhanglijun33/comments/commentRss/294271.htmlhttp://www.aygfsteel.com/zhanglijun33/services/trackbacks/294271.html
本文介绍开源的JMS服务器openJmsQ及怎样使用openJms来构建系l之间健全、高度可用的通讯Q从而简化企业应用的开发? openJmsW合SUN的JMS API 1.0.2规范Q支持消息队列,q支持消息传递的发布/订阅模式Q本文先ql服务的搭徏及JMS的非l构化消息发送和接收q行说明?br />
JMS 有五U消息类型。三U结构化或半l构化的消息cdQMapMessage、ObjectMessage ? StreamMessageQ以及两U非l构化的或自由格式的消息cdQTextMessage ? BytesMessageQ。而这里虽然我们只寚wl构化消息进行说明,但非l构化的消息格式却能够更好地q行交互操作Q因为它们在消息上很利用结构, 在此基础上与XML再进行结合,能方便的进行更好的扩展QXML相关化操作参考《Jaxb来实现Java-XML的{换》?br />
下面具体来介l服务器搭徏Q在http://openjms.sourceforge.net/downloads.html下蝲openJmsQ解压后 可以直接使用Q在 "openjms-0.7.6.1"bin 里,有openJms的运行脚本,执行 startup 启动Q弹Z个新的窗口,服务p行在新窗口内Qshutdown 为停止命令:

服务q行后,可以开始用JMS服务了,x服务搭徏完毕Q简单得不能再简单了?br />
下面是消息发送和接收的开发,开发中需要的jar包在"openjms-0.7.6.1"lib里可以找刎ͼ
openjms-0.7.6.1.jar
jms-1.0.2a.jar
exolabcore-0.3.7.jar
commons-logging-1.0.3.jar

把上面的cd加入到项目中Q下面是消息发送服务的代码Q?br />
package javayou.demo.openjms;
import java.util.*;
import javax.jms.*;
import javax.naming.*;

public class QueueSend {
    public static void main(String[] args) {
        try {
            //取得JNDI上下文和q接
            Hashtable properties = new Hashtable();
            properties.put(
                Context.INITIAL_CONTEXT_FACTORY,
                "org.exolab.jms.jndi.InitialContextFactory");
            //openJms默认的端口是1099
            properties.put(Context.PROVIDER_URL,
                 "rmi://localhost:1099/");
            Context context = new InitialContext(properties);

            //获得JMS信息q接队列工厂
            QueueConnectionFactory queueConnectionFactory =
                (QueueConnectionFactory) context.lookup(
                    "JmsQueueConnectionFactory");
            //获得JMS信息q接队列
            QueueConnection queueConnection =
                queueConnectionFactory.createQueueConnection();
            //产生队列SessionQ设|事务ؓfalseQ自动应{消息接?br />             QueueSession queueSession =
                queueConnection.createQueueSession(
                    false,
                    Session.AUTO_ACKNOWLEDGE);

            //获得默认内徏在JMS里的队列之一Qqueue1
            Queue queue = (Queue) context.lookup("queue1");
            //产生JMS队列发送器
            QueueSender queueSender =
                queueSession.createSender(queue);
            //发送数据到JMS
            TextMessage message = queueSession.createTextMessage();
            message.setText("Hello, I'm openJms.");
            queueSender.send(message);

            System.out.println(
                ""信息写入JMS服务器队?);

            //以下做清除工作,代码?br />             // ... ...
                      
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

执行E序发送消息,然后打开JMS控制収ͼ?admin 命o启动理q_Q点击菜单ActionsQConnectionsQonlineQ出现界面如下:

可以看到JSM默认的队列queue1里已l有1条消息了Q而其他的队列q是I着的?br />
下面我们来看看消息接收服务的代码Q?br />
package javayou.demo.openjms;
import java.util.*;
import javax.jms.*;
import javax.naming.*;
public class QueueReceiveSynchronous {
    public static void main(String[] args) {
        try {
            //取得JNDI上下文和q接
            Hashtable properties = new Hashtable();
            properties.put(
                Context.INITIAL_CONTEXT_FACTORY,
                "org.exolab.jms.jndi.InitialContextFactory");
            properties.put(Context.PROVIDER_URL,
                "rmi://localhost:1099/");
            Context context = new InitialContext(properties);

            //获得JMS信息q接队列工厂
            QueueConnectionFactory queueConnectionFactory =
                (QueueConnectionFactory) context.lookup(
                    "JmsQueueConnectionFactory");

            //获得JMS信息q接队列
            QueueConnection queueConnection =
                queueConnectionFactory.createQueueConnection();

            //启动接收队列U程
            queueConnection.start();
            //产生队列SessionQ设|事务ؓfalseQ自动应{消息接?br />             QueueSession queueSession =
                queueConnection.createQueueSession(
                    false,
                    Session.AUTO_ACKNOWLEDGE);
            //获得默认内徏在JMS里的队列之一Qqueue1
            Queue queue = (Queue) context.lookup("queue1");
            //产生JMS队列接收?br />             QueueReceiver queueReceiver =
                queueSession.createReceiver(queue);
            //通过同步的方法接收消?br />             Message message = queueReceiver.receive();
            String messageText = null;
            if (message instanceof TextMessage)
                messageText = ((TextMessage) message).                        
                    getText();
            System.out.println(messageText);
            //以下做清除工作,代码?br />             // ... ...
          
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

~译后运行接收信息服务,可以看到接收到ƈ打印之前发送的消息Q再看看控制収ͼ发现queue1的消息队列变?Q消息已被读取,消息发送和接收到此l束?br />


上篇openJms介绍 (一) 提到了openJms的构建及消息的发送和接收Q这主要了解消息的发布和订阅。JMS 的发?订阅模型定义了如何向一个内容节点发布和订阅消息Q内容节点也叫主?topic)Q主题是为发布?publisher)和订阅? (subscribe) 提供传输的中介。发?订阅模型使发布者和订阅者之间不需要直接通讯Q如RMIQ就可保证消息的传送,有效解决pȝ间耦合问题Q当然有q个需要才行)Q还 有就是提供了一对一、一对多的通讯方式Q比较灵zR?br />
先介lJMS?个概念,持久订阅模式和非持久订阅模式Q其实也是发?订阅模型在可靠性上提供?U方式:

非持久订阅模式:只有当客L处于Ȁzȝ态,也就是和JMS 服务器保持连接的状态下Q才能接收到发送到某个Topic的消息,而当客户端处于离U状态时Q则q个旉D发到Topic的消息将会永q接收不到?br />
持久订阅模式Q客L向JMS 注册一个识别自pn份的IDQ当q个客户端处于离U时QJMS 服务器会个ID 保存所有发送到主题的消息,当客户再ơ连接到JMS 服务器时Q会Ҏ自己的ID 得到所有当自己处于ȝ时发送到主题的消息,x息永q能接收到?br />
下面我们接着来看openJms在发?订阅模式上的表现Q由于篇q关p,在这里只讲述非持久订阅模式,持久订阅模式可以ҎJMS的标准来试?br />
消息发布的代码如下:

package javayou.demo.openjms;
import java.util.*;
import javax.jms.*;
import javax.naming.*;
public class TopicPublish {
    public static void main(String[] args) {
        try {
            //取得JNDI上下文和q接
            Hashtable properties = new Hashtable();
            properties.put(
                Context.INITIAL_CONTEXT_FACTORY,
                "org.exolab.jms.jndi.InitialContextFactory");
            //openJms默认的端口是1099
            properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
            Context context = new InitialContext(properties);
            //获得JMS Topicq接队列工厂
            TopicConnectionFactory factory =
                (TopicConnectionFactory) context.lookup(
                    "JmsTopicConnectionFactory");

            //创徏一个Topicq接Qƈ启动
            TopicConnection topicConnection = factory.createTopicConnection();
            topicConnection.start();

            //创徏一个Topic会话Qƈ讄自动应答
            TopicSession topicSession =
                topicConnection.createTopicSession(false,
                        Session.AUTO_ACKNOWLEDGE);

            //lookup 得到 topic1
            Topic topic = (Topic) context.lookup("topic1");
            //用Topic会话生成Topic发布?br />             TopicPublisher topicPublisher = topicSession.createPublisher(topic);

            //发布消息到Topic
            System.out.println("消息发布到Topic");
            TextMessage message = topicSession.createTextMessage
                ("你好Q欢q定购TopiccL?);
            topicPublisher.publish(message);

            //资源清除Q代码略 ... ...   
        } catch (NamingException e) {
            e.printStackTrace();
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}

而订阅消息的接收有同步的和异?U,他们分别使用receive()和onMessage(Message message)Ҏ来接收消息,具体代码Q?br />
同步接收Q?br />
package javayou.demo.openjms;
import java.util.*;
import javax.jms.*;
import javax.naming.*;
public class TopicSubscribeSynchronous {

    public static void main(String[] args) {
        try {
            System.out.println("定购消息接收启动Q?);
            //取得JNDI上下文和q接
            Hashtable properties = new Hashtable();
            properties.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.exolab.jms.jndi.InitialContextFactory");
            properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
            Context context = new InitialContext(properties);

            //获得Topic工厂和Connection
            TopicConnectionFactory factory =
                (TopicConnectionFactory) context.lookup(
                    "JmsTopicConnectionFactory");
            TopicConnection topicConnection = factory.createTopicConnection();
            topicConnection.start();

            //创徏Topic的会话,用于接收信息
            TopicSession topicSession =
                topicConnection.createTopicSession(
                    false,
                    Session.AUTO_ACKNOWLEDGE);

            //lookup topic1
            Topic topic = (Topic) context.lookup("topic1");
                    //创徏Topic subscriber
            TopicSubscriber topicSubscriber =
                topicSession.createSubscriber(topic);
            //收满10条订阅消息则退?br />             for (int i=0; i<10; i++) {
                //同步消息接收Q用receiveҎQ堵塞等待,直到接收消息
                TextMessage message = (TextMessage) topicSubscriber.receive();
                System.out.println("接收订阅消息["+i+"]: " + message.getText());
            }
            //资源清除Q代码略 ... ...
            System.out.println("订阅接收l束.");
        } catch (NamingException e) {
            e.printStackTrace();
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}

非同步接Ӟ

package javayou.demo.openjms;
import java.util.*;
import javax.jms.*;
import javax.naming.*;
public class TopicSubscribeAsynchronous implements MessageListener {
    private TopicConnection topicConnection;
    private TopicSession topicSession;
    private Topic topic;
    private TopicSubscriber topicSubscriber;

    TopicSubscribeAsynchronous() {
        try {
            //取得JNDI上下文和q接
            Hashtable properties = new Hashtable();
            properties.put(
                Context.INITIAL_CONTEXT_FACTORY,
                "org.exolab.jms.jndi.InitialContextFactory");
            properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
            Context context = new InitialContext(properties);

            //取得Topic的连接工厂和q接
            TopicConnectionFactory topicConnectionFactory =
                (TopicConnectionFactory) context.lookup(
                    "JmsTopicConnectionFactory");
            topicConnection = topicConnectionFactory.createTopicConnection();

            //创徏Topic的会话,用于接收信息
            topicSession =
                topicConnection.createTopicSession(false,
                    Session.AUTO_ACKNOWLEDGE);
            topic = (Topic) context.lookup("topic1");

            //创徏Topic subscriber
            topicSubscriber = topicSession.createSubscriber(topic);
            //讄订阅监听
            topicSubscriber.setMessageListener(this);

            //启动信息接收
            topicConnection.start();
        } catch (NamingException e) {
            e.printStackTrace();
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        System.out.println("非同步定购消息的接收Q?);
        try {
            TopicSubscribeAsynchronous listener =
                new TopicSubscribeAsynchronous();
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    //收到订阅信息后自动调用此Ҏ
    public void onMessage(Message message) {
        try {
            String messageText = null;
            if (message instanceof TextMessage)
                messageText = ((TextMessage) message).getText();
            System.out.println(messageText);
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}

~译好后Q启动openJms服务Q打开admin理収ͼZq行方便Q这里先列出三个cȝq行命oQ?br /> java -cp ."; -Djava.ext.dirs=."lib; javayou.demo.openjms.TopicPublish
java -cp ."; -Djava.ext.dirs=."lib; javayou.demo.openjms.TopicSubscribeSynchronous
java -cp ."; -Djava.ext.dirs=."lib; javayou.demo.openjms.TopicSubscribeAsynchronous

先运?个接收命令,再运行发布命令,可以看到控制台的Topic有消息接Ӟq且接收1?都有消息接收的提C,到此完成演示Q由于是非持久订阅,所以可以看到控制台上的Topic消息条数不会减少?

]]>
OSCache的实际?/title><link>http://www.aygfsteel.com/zhanglijun33/archive/2008/11/27/oscache.html</link><dc:creator>无?/dc:creator><author>无?/author><pubDate>Thu, 27 Nov 2008 06:48:00 GMT</pubDate><guid>http://www.aygfsteel.com/zhanglijun33/archive/2008/11/27/oscache.html</guid><wfw:comment>http://www.aygfsteel.com/zhanglijun33/comments/243000.html</wfw:comment><comments>http://www.aygfsteel.com/zhanglijun33/archive/2008/11/27/oscache.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zhanglijun33/comments/commentRss/243000.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zhanglijun33/services/trackbacks/243000.html</trackback:ping><description><![CDATA[     摘要: 目性能优化相关Qoscache实际应用,Cookie的؜乱及解决  <a href='http://www.aygfsteel.com/zhanglijun33/archive/2008/11/27/oscache.html'>阅读全文</a><img src ="http://www.aygfsteel.com/zhanglijun33/aggbug/243000.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zhanglijun33/" target="_blank">无?/a> 2008-11-27 14:48 <a href="http://www.aygfsteel.com/zhanglijun33/archive/2008/11/27/oscache.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>hql editor 的?/title><link>http://www.aygfsteel.com/zhanglijun33/archive/2008/11/17/hqlEdit.html</link><dc:creator>无?/dc:creator><author>无?/author><pubDate>Mon, 17 Nov 2008 06:19:00 GMT</pubDate><guid>http://www.aygfsteel.com/zhanglijun33/archive/2008/11/17/hqlEdit.html</guid><wfw:comment>http://www.aygfsteel.com/zhanglijun33/comments/240955.html</wfw:comment><comments>http://www.aygfsteel.com/zhanglijun33/archive/2008/11/17/hqlEdit.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zhanglijun33/comments/commentRss/240955.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zhanglijun33/services/trackbacks/240955.html</trackback:ping><description><![CDATA[     摘要: hqlEdit的?spring service层的试  <a href='http://www.aygfsteel.com/zhanglijun33/archive/2008/11/17/hqlEdit.html'>阅读全文</a><img src ="http://www.aygfsteel.com/zhanglijun33/aggbug/240955.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zhanglijun33/" target="_blank">无?/a> 2008-11-17 14:19 <a href="http://www.aygfsteel.com/zhanglijun33/archive/2008/11/17/hqlEdit.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>url 传中文ؕ?的解?/title><link>http://www.aygfsteel.com/zhanglijun33/archive/2008/11/10/url_chinese.html</link><dc:creator>无?/dc:creator><author>无?/author><pubDate>Mon, 10 Nov 2008 03:51:00 GMT</pubDate><guid>http://www.aygfsteel.com/zhanglijun33/archive/2008/11/10/url_chinese.html</guid><wfw:comment>http://www.aygfsteel.com/zhanglijun33/comments/239631.html</wfw:comment><comments>http://www.aygfsteel.com/zhanglijun33/archive/2008/11/10/url_chinese.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.aygfsteel.com/zhanglijun33/comments/commentRss/239631.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/zhanglijun33/services/trackbacks/239631.html</trackback:ping><description><![CDATA[1传中文之前的准备<br /> <font style="background-color: #9deec1"> <%<br />   String a = "我是立军";<br />   a = URLEncoder.encode(a,"gbk");<br />   %><br />   <body><br />    <a href="hello.jsp?actionName=<%=a%>" > 试验</a><br /> <br /> 2.接收 <font style="background-color: #9deec1"><%<br />   String actionName=new String(request.getParameter("actionName").getBytes("iso8859_1"));<br />   %> </font><br /> <font style="background-color: #9deec1">actionName:<%=actionName %></font></font> <img src ="http://www.aygfsteel.com/zhanglijun33/aggbug/239631.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/zhanglijun33/" target="_blank">无?/a> 2008-11-10 11:51 <a href="http://www.aygfsteel.com/zhanglijun33/archive/2008/11/10/url_chinese.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">»</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ά</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">²</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank">ݳ</a>| <a href="http://" target="_blank">ƽ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ʡ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">µ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ϲ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>