锘??xml version="1.0" encoding="utf-8" standalone="yes"?> openfire鏈嶅姟鍣ㄦ槸鍩轟簬xmpp鍗忚鐨勶紝XMPP鏀寔涓ょ鏂囦歡嫻佷紶杈撳崗璁紝SOCKS5 Bytestreams鍜?In-Band Bytestreams錛孲OCKS5鏄洿鎺ュ彂閫佷簩榪涘埗嫻侊紝鑰孖BB鏄皢鏂囦歡杞垚base64鐮佽繘琛岀劧鍚庣敤message鐨勫艦寮忚繘琛屼紶杈擄紝鎴戣繖閲屼粎瀹炵幇浜?jiǎn)SOCKS5鐨勬枃浠朵唬鐞嗕紶杈撱?br />SOCKS5鏂囦歡浼犺緭闇瑕佺敤鍒頒袱涓崗璁紝XEP-0065鍜孹EP-0096 鍗忓晢榪囩▼灝辨槸涓夋柟浜掔浉鍙戦亁ml鏉ヤ氦鎹俊鎭殑榪囩▼錛岄氫織鐐瑰氨鏄笁涓漢娌熼氫竴涓嬩紶浠涔堟枃浠跺拰鎬庝箞浼犳枃浠躲?br />棣栧厛閬靛驚XMP-0096鍗忚錛屽垵濮嬫柟緇欑洰鏍囨柟鍙戦佸寘鍚枃浠朵俊鎭殑xml 榪欐椂榪涘叆XEP-0065鍗忚闃舵 浠g悊鏂瑰洖澶嶄俊鎭紝鍛婄煡鍒濆鏂逛唬鐞嗙殑jid銆両P銆佺鍙g瓑淇℃伅 鐒跺悗灝辮繘鍏ヨ繛鎺ラ樁孌碉紝涔熷氨鏄垵濮嬫柟鍜岀洰鏍囨柟鍒嗗埆鍜屼唬鐞嗗緩绔媠ocks5榪炴帴鐨勮繃紼嬨傦紙鍏充簬SOCKS5鍗忚榪炴帴錛屾垜涔嬪悗浼?xì)琛ュ厖锛?jí)銆?br />鐩爣鏂規(guī)敹鍒頒唬鐞嗕俊鎭悗鍜屼唬鐞嗗緩绔媠ocket榪炴帴(浣跨敤SOCKS5鍗忚榪炴帴)錛岃繛鎺ユ垚鍔熷悗閫氱煡鍒濆鏂逛嬌鐢ㄧ殑浠g悊jid 鍒濆鏂規(guī)敹鍒板洖澶嶄俊鎭悗灝辮繘鍏ヤ簩榪涘埗嫻佷紶杈撻樁孌碉紝榪欐椂灝卞彲浠ュ紑濮嬪彂閫佷簩榪涘埗嫻佷簡(jiǎn) 絳夊垵濮嬫柟灝嗘祦鍙戦佸畬姣曞悗鎶妔ocket嫻佸叧闂紶杈撳氨瀹屾垚浜?jiǎn)鏂囦欢鐨勪紶杈撱?/p>
娉ㄦ剰錛歵ype涓簉esult鐨勫洖澶嶄俊鎭嬌鐢ㄧ殑id涓瀹氳鍜岃姹傜殑淇℃伅id涓鏍楓?/font>
{
var array:Array = [];
array.push(new Vga("a",10));
array.push(new Vga("c",2));
array.push(new Vga("f",1.3));
array.push(new Vga("d",1.1));
array.push(new Vga("e",16));
array.push(new Vga("b",0));
trace(array.toString());
//output: [a,10],[c,2],[f,1.3],[d,1.1],[e,16],[b,0]
var defaultSort:Array = array.sort();//榛樿鎺掑簭
trace(defaultSort.toString());
//output: [a,10],[b,0],[c,2],[d,1.1],[e,16],[f,1.3]
var sortFunArray:Array = array.sort(sortFun);//浣跨敤鑷畾涔夋柟娉曟帓搴?/span>
trace(sortFunArray.toString());
//output: [b,0],[d,1.1],[f,1.3],[c,2],[a,10],[e,16]
}
/**鑷畾涔夋帓搴忔柟娉?/span>*/
public function sortFun(a:Vga,b:Vga):int{
if(a.price < b.price){
return -1; //a鍦ㄥ墠,b鍦ㄥ悗
}else if(a.price == b.price){
return 0; //ab浣嶇疆涓嶅彉
}else{
return 1; //b鍦ㄥ墠,a鍦ㄥ悗
}
}
/**鎺掑簭VO瀵硅薄*/
public class Vga
{
public var name:String;
public var price:Number;
public function Vga(name:String,price:Number)
{
this.name = name;
this.price = price;
}
public function toString():String{
return "["+this.name+","+this.price+"]";
}
}
ArrayCollection鎺掑簭
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.collections.SortField;
import mx.collections.Sort;
import mx.collections.ArrayCollection;
private var acSort:ArrayCollection=
new ArrayCollection([{id:0,userName:"zhangSan",age:21},
{id:2,userName:"liSi",age:24},
{id:1,userName:"wangWu",age:31}]);
private function sortAc():ArrayCollection{
var sort:Sort=new Sort();
//鎸夌収ID鍗囧簭鎺掑簭
sort.fields=[new SortField("id")];
//鎸夌収userName闄嶅簭鎺掑簭
sort.fields=[new SortField("userName",true,true)];
//鍏堟寜ID鍗囧簭,鍐嶆寜userName闄嶅簭
sort.fields[new SortField("id"),new SortField("userName",true,true)];
acSort.sort=sort;
acSort.refresh();//鏇存柊
return acSort;
}
/*
鍏跺疄鐪嬬湅API灝變竴鐩簡(jiǎn)鐒?br /> SortField () 鏋勯犲嚱鏁?nbsp;
public function SortField(name:String = null,
caseInsensitive:Boolean = false,
descending:Boolean = false,
numeric:Object = null)
鍙傛暟
name:String (default = null) — 姝ゅ瓧孌電敤鏉ヨ繘琛屾瘮杈冪殑灞炴х殑鍚嶇О銆傚鏋滆瀵硅薄涓虹畝鍗曠被鍨嬶紝鍒欎紶閫?nbsp;null銆?nbsp;
caseInsensitive:Boolean (default = false) — 鍦ㄥ瀛楃涓茶繘琛屾帓搴忔椂錛屾寚紺烘瘮杈冭繍綆楃鏄惁蹇界暐鍊肩殑澶у皬鍐欍?br /> descending:Boolean (default = false) — 鎸囩ず姣旇緝榪愮畻絎︽槸鍚︽寜闄嶅簭鎺掑垪欏圭洰銆?nbsp;
numeric:Object (default = null) — 鎸囩ず姣旇緝榪愮畻絎︽槸鍚︽寜緙栧彿鑰屼笉鎸夊瓧姣嶉『搴忔瘮杈冩帓搴忛」鐩?nbsp;
*/
]]>
</mx:Script>
</mx:Application>
]]>
XEP-0096瀹氫箟鏂囦歡浼犺緭鍗忚錛屾彁渚涗簡(jiǎn)涓涓ā鍧楀寲妗嗘灦浣胯兘浜ゆ崲琚紶杈撴枃浠剁殑淇℃伅浠ュ強(qiáng)鍙傛暟鐨勫崗鍟嗭紝涔熷氨鏄湪浼犺緭鏂囦歡涔嬪墠鍗忓晢灝嗚浼犺緭鐨勬枃浠朵俊鎭?br />XEP-0065瀹氫箟SOCKS5嫻佷紶杈撴爣鍑嗗崗璁紝鎻愪緵鐢ㄤ簬鍦ㄤ換鎰忎袱涓猉MPP鐢ㄦ埛涔嬮棿寤虹珛瀛楄妭嫻佸茍榪涜鏂囦歡浼犺緭銆?br />鏍規(guī)嵁鎴戠殑鐞嗚В錛屾枃浠朵紶杈撶殑榪囩▼鍒嗕負(fù)鍗忓晢錛屽緩绔媠ocks5榪炴帴錛屼簩榪涘埗浼犺緭榪欎笁涓樁孌?br />鍗忓晢鐨勮繃紼嬫渶澶嶆潅錛岀劧鍚庢槸寤虹珛榪炴帴錛屼紶杈撳氨姣旇緝綆鍗曪紝涓嬮潰涓涓竴涓潵璁?br />鍗忓晢鍖呮嫭鍒濆鏂廣佺洰鏍囨柟銆佷唬鐞嗘柟錛屽垵濮嬫柟灝辨槸鍙戦佹枃浠舵柟錛岀洰鏍囨柟鍗蟲(chóng)枃浠舵帴鏀舵柟錛屼唬鐞嗘柟鏄痵ocks5浠g悊鏈嶅姟鍣紝<iq to="android@192.168.1.113/Spark 2.6.3" type="set" id="iq_13" from="iphone@192.168.1.113/xiff">
<si profile="http://jabber.org/protocol/si/profile/file-transfer" mime-type="text/plain" id="82B0C697-C1DE-93F9-103E-481C8E7A3BD8" xmlns="http://jabber.org/protocol/si">
<feature xmlns="http://jabber.org/protocol/feature-neg">
<x xmlns="jabber:x:data" type="form">
<field var="stream-method" type="list-single">
<option><value>http://jabber.org/protocol/bytestreams</value></option>
<option><value>http://jabber.org/protocol/ibb</value></option>
</field>
</x>
</feature>
<file xmlns="http://jabber.org/protocol/si/profile/file-transfer" name="img0545.png" size="152443"><desc>send</desc></file>
</si>
</iq>
鐩爣鏂規(guī)帴鏀跺埌淇℃伅鍚庡彂閫佸洖鎵э紝琛ㄧず鍚屾剰鎺ユ敹鏂囦歡<iq id="iq_13" to="iphone@192.168.1.113/xiff" from="android@192.168.1.113/Spark 2.6.3" type="result">
<si xmlns="http://jabber.org/protocol/si">
<feature xmlns="http://jabber.org/protocol/feature-neg">
<x xmlns="jabber:x:data" type="submit">
<field var="stream-method">
<value>http://jabber.org/protocol/bytestreams</value>
<value>http://jabber.org/protocol/ibb</value>
</field>
</x>
</feature>
</si>
</iq>
鍒濆鏂圭粰鏈嶅姟鍣ㄥ彂閫佷俊鎭紝璇鋒眰鎻愪緵浠g悊鏈嶅姟鍣?/p>
<iq id="iq_15" type="get"><query xmlns="http://jabber.org/protocol/disco#items" /></iq>
鏈嶅姟鍣ㄥ洖澶嶄俊鎭紝鍛婄煡鍙敤鐨勪唬鐞?/p>
<iq type="result" id="iq_15" to="iphone@192.168.1.113/xiff">
<query xmlns="http://jabber.org/protocol/disco#items">
<item jid="proxy.192.168.1.113" name="Socks 5 Bytestreams Proxy"/>
<item jid="pubsub.192.168.1.113" name="Publish-Subscribe service"/>
<item jid="conference.192.168.1.113" name="鍏叡鎴塊棿"/>
<item jid="search.192.168.1.113" name="User Search"/>
</query>
</iq>
榪欓噷閫夋嫨name=“Socks 5 Bytestreams Proxy”鐨勪唬鐞嗭紝鍒濆鏂圭粰榪欎釜浠g悊鍙戦佷俊鎭幏鍙栦唬鐞嗚繛鎺ヤ俊鎭?/p>
<iq id="iq_17" to="proxy.192.168.1.113" type="get"><query xmlns="http://jabber.org/protocol/bytestreams" /></iq>
<iq type="result" id="iq_17" from="proxy.192.168.1.113" to="iphone@192.168.1.113/xiff">
<query xmlns="http://jabber.org/protocol/bytestreams">
<streamhost jid="proxy.192.168.1.113" host="192.168.1.113" port="7777"/>
</query>
</iq>
鍒濆鏂規(guī)敹鍒頒唬鐞嗕俊鎭悗灝嗕唬鐞嗙殑淇℃伅鍙戦佺粰鐩爣鏂?/p>
<iq to="android@192.168.1.113/Spark 2.6.3" type="set" id="iq_19" from="iphone@192.168.1.113/xiff">
<query xmlns="http://jabber.org/protocol/bytestreams" mode="tcp" sid="82B0C697-C1DE-93F9-103E-481C8E7A3BD8">
<streamhost port="7777" host="192.168.1.113" jid="proxy.192.168.1.113" />
</query>
</iq>
<iq id="iq_19" to="iphone@192.168.1.113/xiff" type="result" from="android@192.168.1.113/Spark 2.6.3">
<query xmlns="http://jabber.org/protocol/bytestreams">
<streamhost-used jid="proxy.192.168.1.113"/>
</query>
</iq>
鍒濆鏂瑰紑濮嬩笌浠g悊寤虹珛socket榪炴帴(涔熶嬌鐢⊿OCKS5鍗忚)錛岃繛鎺ユ垚鍔熷悗緇欎唬鐞嗗彂閫佽姹傦紝瑕佹眰嬋媧繪枃浠舵祦<iq to="proxy.192.168.1.113" type="set" id="iq_21" from="iphone@192.168.1.113/xiff">
<query xmlns="http://jabber.org/protocol/bytestreams" sid="82B0C697-C1DE-93F9-103E-481C8E7A3BD8">
<activate>android@192.168.1.113/Spark 2.6.3</activate>
</query>
</iq>
浠g悊鍥炲嬋媧繪垚鍔熶俊鎭?/p>
<iq type="result" id="iq_21" from="proxy.192.168.1.113" to="iphone@192.168.1.113/xiff"/>
]]>
1.淇敼web.xml鏂囦歡銆?/p>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
鍙榪囨護(hù)鍣ㄥ鍔犳湁.action鍚庣紑鐨勮礬寰勬湁鏁堬紝濡傛灉闇瑕佹嫤鎴?jsp錛屽姞涓?.jsp灝辮浜?jiǎn)銆?/p>
浣嗘槸榪欐牱濡傛灉鏈夋棤鍚庣紑鍚嶇殑url錛堝/demo/錛夊氨涓嶈兘榪囨護(hù)浜?/p>
2.淇敼struts2鏍稿績(jī)jar涓殑default.properties鏂囦歡
鎶妔truts.action.extension=action,,
鏀逛負(fù)struts.action.extension=action,do,jsp,
浣嗘垜鏀逛簡(jiǎn)涔嬪悗鍙戠幇鏍規(guī)湰娌℃晥鏋滐紝涓嶇煡涓轟綍
3.鑷畾涔変竴涓?/span>緇ф壙StrutsPrepareAndExecuteFilter鐨勮繃婊ゅ櫒錛屽皢閰嶇疆鎹㈡垚鑷繁鑷畾涔夌殑榪囨護(hù)鍣ㄣ傦紙鎺ㄨ崘姝ゆ硶錛?/span>
淇敼web.xml
榪欑鏂規(guī)硶璇曢獙鎴愬姛
ORM緙撳瓨絳栫暐
1.浜嬪姟綰х紦瀛?session level cache)
session鐢熷懡鍛ㄦ湡鐨勭紦瀛?鍏抽棴session鍗蟲(chóng)秷浜?/p>
2.搴旂敤綰?榪涚▼綰х紦瀛?sessionFactory level cache)
鏌愪釜搴旂敤涓殑鍏變韓緙撳瓨,澶氫釜浜嬪姟鍙互鍏變韓,鍦╯essionFactory灞傚疄鐜?鎵鏈塻essionFactory鍒涘緩鐨剆ession鍙互鍏變韓.
3.鍒嗗竷寮忕紦瀛?/p>
澶氫釜JVM鍏變韓鐨勭紦瀛?閫氳繃榪滅▼鏈哄埗瀹炵幇緙撳瓨鏁版嵁鍚屾,浠繪剰瀹炰緥淇敼鏁版嵁,鎵鏈夌殑JVM閮借鏇存柊緙撳瓨.
Hibernate鏁版嵁緙撳瓨
1.鍐呴儴緙撳瓨(session level)涓綰х紦瀛?/span>
鏄簨鍔$駭鐨勭紦瀛?session涓淮鎶ょ殑涓涓狹ap,Map鐨刱ey鏄寘鍚簡(jiǎn)鏁版嵁綾誨瀷鍜宨d,浠庢暟鎹簱鍔犺澆鐨勬暟鎹兘浼?xì)杩涘叆Map緙撳瓨?shù)?閫氳繃session鍔犺澆鏁版嵁鏃朵細(xì)鍏堝湪session緙撳瓨閲屾壘,涓綰х紦瀛樻槸session鐨刾rivate鏁版嵁,session瀹炰緥娑堜骸灝辨竻闄や簡(jiǎn),鍦ㄥ簲鐢ㄤ腑灝變繚鎸佸湪涓嬈¤姹傜殑寮濮嬪拰緇撴潫涔嬮棿.
涓鑸敱Hibernate鑷姩緇存姢,涔熸敮鎸佹墜鍔ㄧ淮鎶?/p>
session.evit(Object obj) 灝嗘寔涔呭寲瀵硅薄浠庝竴綰х紦瀛樹(shù)腑娓呴櫎.
session.clear() 娓呯┖涓綰х紦瀛?/p>
session.contains(Object obj) 鍒ゆ柇鎸囧畾鐨勫璞℃槸鍚﹀瓨鍦ㄤ簬涓綰х紦瀛樹(shù)腑.
session.flush() 鍒鋒柊涓綰х紦瀛樺尯鐨勫唴瀹?浣跨紦瀛樹(shù)笌鏁版嵁搴撴暟鎹繚鎸佸悓姝?
2.浜岀駭緙撳瓨(sessionFactory level)
鍖呭惈浜?jiǎn)搴旂敤珩斿拰鍒嗗竷寮忕殑缂撳?鐢辨湰sessionFactory鐨勬墍鏈塻ession瀹炰緥鍏變韓,session鎿嶄綔鏃朵細(xì)鍏堟煡涓綰х紦瀛?鐒跺悗鏌ヤ簩綰х紦瀛?鏈鍚庡啀鏌ョ墿鐞嗘暟鎹簱.瑕佷嬌鐢ㄤ簩綰х紦瀛樺繀欏昏榪涜閰嶇疆.
閫傚悎鐢ㄧ紦瀛樼殑鏁版嵁
1.涓嶄細(xì)琚叾浠栧簲鐢ㄤ慨鏀?/p>
鍖呮嫭鐩存帴鐢↗DBC淇敼絳?鍥犱負(fù)鍏朵粬搴旂敤淇敼浜?jiǎn)鏁版嵁涔嬪悗hibernate騫朵笉鐭ラ亾,涓嶈兘鑷姩鏇存柊緙撳瓨,涓嶈繃鍙互鎵嬪姩鏇存柊緙撳瓨
2.鏁版嵁澶у皬鍙互鎺ュ彈,姣曠珶鍐呭瓨璧勬簮涔熶笉澶?/p>
3.鏁版嵁鏇存柊棰戠巼浣?姣斿鏁版嵁瀛楀吀絳夊父閲忔暟鎹?
4.鍙兘琚郴緇熼綣佷嬌鐢?/p>
5.闈炲叧閿殑鏁版嵁
6.涓嶄細(xì)琚茍鍙戣闂殑鏁版嵁
甯哥敤鐨勪簩綰х紦瀛樻彃浠?/p>
EHCache org.hibernate.cache.EhCacheProvider
OSCache org.hibernate.cache.OSCacheProvider
SwarmCahe org.hibernate.cache.SwarmCacheProvider 鎻愪緵浜?jiǎn)鍒嗗竷寮?/p>
JBossCache org.hibernate.cache.TreeCacheProvider 鎻愪緵浜?jiǎn)鍒嗗竷寮?/p>
EHCache浜岀駭緙撳瓨閰嶇疆鏂規(guī)硶
1.鍚敤浜岀駭緙撳瓨棣栧厛瑕佸湪hibernate.cfg.xml閰嶇疆
<hibernate-configuration>
<session-factory>
<!-- 閰嶇疆浜岀駭緙撳瓨鎻掍歡EHCache鐨凱rovider綾?->
<property name="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</property>
<!-- 鍚姩"鏌ヨ緙撳瓨" -->
<property name="hibernate.cache.use_query_cache">
true
</property>
</session-factory>
</hibernate-configuration>
2.鐒跺悗閰嶇疆cache鐨勯厤緗枃浠秂hcache.xml
<ehcache>
<!-- maxElementsInMemory涓虹紦瀛樺璞$殑鏈澶ф暟鐩?
eternal璁劇疆鏄惁姘歌繙涓嶈繃鏈?
timeToIdleSeconds瀵硅薄澶勪簬絀洪棽鐘舵佺殑鏈澶氱鏁?
timeToLiveSeconds瀵硅薄澶勪簬緙撳瓨鐘舵佺殑鏈澶氱鏁?
overflowtodisk鍐呭瓨?shù)笉鑳鲦椂鏄惁鍚敤纾佺洏缂撳?-->
<diskStore path="java.io.tmpdir"/>
<defaultCache maxElementsInMemory="10000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600" overflowToDisk="true"/>
</ehcache>
3.鏈鍚庤鍦ㄦ槧灝勬枃浠?**.hbm.xml涓寚瀹氬疄浣撶殑緙撳瓨鍚屾絳栫暐
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class>
<!-- 璁劇疆璇ユ寔涔呭寲綾葷殑浜岀駭緙撳瓨騫跺彂璁塊棶絳栫暐-->
<cache usage="read-write"/>
<set name = "xxx">
<cache usage="read-only" />
</set>
</class>
</hibernate-mapping>
hibernate鎻愪緵鐨勭紦瀛樺悓姝ョ瓥鐣?鍙互鍦╱sage涓緗?/p>
read-only
鍙
nonstrict-read-write
鏇存柊棰戠巼涓嶉珮
read-write
涓ユ牸鍙鍐?/p>
transactional(Ecache涓嶆敮鎸?
浜嬪姟鍨嬬紦瀛?/p>