??xml version="1.0" encoding="utf-8" standalone="yes"?>色999日韩自偷自拍美女,亚洲欧美综合在线精品,综合av在线http://www.aygfsteel.com/fastzch/category/43096.htmlI Love Java As My Life!zh-cnSun, 26 Sep 2010 10:28:19 GMTSun, 26 Sep 2010 10:28:19 GMT60使用ANT扚w~译Flex应用和模块(Use ANT to batch compiling application and modules of Flex)http://www.aygfsteel.com/fastzch/archive/2010/09/26/332885.htmlRobin's Java WorldRobin's Java WorldSun, 26 Sep 2010 00:51:00 GMThttp://www.aygfsteel.com/fastzch/archive/2010/09/26/332885.htmlhttp://www.aygfsteel.com/fastzch/comments/332885.htmlhttp://www.aygfsteel.com/fastzch/archive/2010/09/26/332885.html#Feedback0http://www.aygfsteel.com/fastzch/comments/commentRss/332885.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/332885.html
<target name="compileUI" >
        
<echo message="start to compile Flex UI" />
        
<for param="file">
            
<path>
                
<fileset dir="${flexsrc.dir}">
                    
<include name="**/*.mxml" />
                
</fileset>
            
</path>
            
<sequential>        
                
<propertyregex override="yes" property="compile.target.name" input="@{file}" regexp="(.*)src(.*)(mxml)" replace="\1bin\2swf" />
               
 <mxmlc file="@{file}" output="${compile.target.name}"
                    services
="${service.file}" context-root="${context.root}">
                    
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
                    
<static-link-runtime-shared-libraries>false</static-link-runtime-shared-libraries>
                    
<source-path path-element="${flexsrc.dir}" />
                    
<!-- use incremental compiling-->
                    
<compiler.incremental>true</compiler.incremental>
                    
<compiler.debug>false</compiler.debug>
                    
                    
<!-- 指定外部依赖库文?q些库文件将不会~译q目标SWF?nbsp;-->
                    
<compiler.external-library-path dir="${flexlib.dir}">
                        
<include name="**/*.swc" />
                    
</compiler.external-library-path>
                
</mxmlc>
                
<!-- 清除~存文g -->
                
<!--
                <delete file="${compile.target.name}.cache" />
                
-->
                
<echo message="Compiled @{file} =====>>   ${compile.target.name}" />
                
            
</sequential>
        
</for>

    
</target>


注意事项Q?br /> 1Q必M用ant-contrib包来支持fordQ用fordӞ别忘了如下声明:
<path id="ant.classpath">
        
<fileset dir="${ant.lib.dir}">
            
<include name="*.jar" />
        
</fileset>
    
</path>
    
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="ant.classpath" />

2Q编译每个mxmlӞ可用propertyregex来得到output文g名,
3Qsource-path一定不能写错,或随便写Q如果这L话,会出现如下错误:
              Error: A file found in a source-path must have the same package structure
4Q如果在q行的过E中出现Java heap size或permGen不的情况,可以指定如下pȝ参数Q?br />               ANT_OPTS=-XX:MaxPermSize=256M -Xmx1024m

Robin's Java World 2010-09-26 08:51 发表评论
]]>
Flex中带有三U状态CheckBox的Tree的实?/title><link>http://www.aygfsteel.com/fastzch/archive/2010/09/15/332027.html</link><dc:creator>Robin's Java World</dc:creator><author>Robin's Java World</author><pubDate>Tue, 14 Sep 2010 23:58:00 GMT</pubDate><guid>http://www.aygfsteel.com/fastzch/archive/2010/09/15/332027.html</guid><wfw:comment>http://www.aygfsteel.com/fastzch/comments/332027.html</wfw:comment><comments>http://www.aygfsteel.com/fastzch/archive/2010/09/15/332027.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/fastzch/comments/commentRss/332027.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/fastzch/services/trackbacks/332027.html</trackback:ping><description><![CDATA[     摘要: 常常会用到带?U状态CheckBox的树形组Ӟ比如在权限管理中Q或者是地区选择中等{,如下图: 不多说费话了Q直接进入主题,看看如何实现。其实在Flex中,只用自己实现一个TreeItemRenderer可以了Q代码如下: package com.robin {     import flash.events...  <a href='http://www.aygfsteel.com/fastzch/archive/2010/09/15/332027.html'>阅读全文</a><img src ="http://www.aygfsteel.com/fastzch/aggbug/332027.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/fastzch/" target="_blank">Robin's Java World</a> 2010-09-15 07:58 <a href="http://www.aygfsteel.com/fastzch/archive/2010/09/15/332027.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Flex4 bug -- Context Menu中菜单项Label不能带settings字样http://www.aygfsteel.com/fastzch/archive/2010/05/05/320147.htmlRobin's Java WorldRobin's Java WorldWed, 05 May 2010 12:35:00 GMThttp://www.aygfsteel.com/fastzch/archive/2010/05/05/320147.htmlhttp://www.aygfsteel.com/fastzch/comments/320147.htmlhttp://www.aygfsteel.com/fastzch/archive/2010/05/05/320147.html#Feedback0http://www.aygfsteel.com/fastzch/comments/commentRss/320147.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/320147.html今天在开发Flex的应用时Q发C个Flex4的bugQ即Context Menu中菜单项Label不能带settings字样?br />
代码如下Q?/p>
                var addSettingItem:ContextMenuItem = new ContextMenuItem("Add Control Setting", true);
                var saveSettingItem:ContextMenuItem = new ContextMenuItem("Save Control Setting", true);
                var saveAll:ContextMenuItem = new ContextMenuItem("Save All Control Settings", true);
                addSettingItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuItem_addSettingItemSelect);
                saveAll.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuItem_saveAllSettingItemSelect);
                saveSettingItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuItem_saveSettingItemSelect);
                rightClickContextMenu.hideBuiltInItems();
                rightClickContextMenu.customItems = [addSettingItem, saveSettingItem, saveAll];

l果无论怎样Q?#8220;Save All Control Settings”菜单就是出不来Q改?#8220;Save All Control Setting”可以了。真是灰常灰常的奇?#8230;…

猜想一下,是不是因为Flash右键菜单中本来就包含有一?#8220;Settings...”的原因?

Robin's Java World 2010-05-05 20:35 发表评论
]]>
BlazeDS自定义认证与权限控制http://www.aygfsteel.com/fastzch/archive/2010/04/28/319555.htmlRobin's Java WorldRobin's Java WorldWed, 28 Apr 2010 01:56:00 GMThttp://www.aygfsteel.com/fastzch/archive/2010/04/28/319555.htmlhttp://www.aygfsteel.com/fastzch/comments/319555.htmlhttp://www.aygfsteel.com/fastzch/archive/2010/04/28/319555.html#Feedback1http://www.aygfsteel.com/fastzch/comments/commentRss/319555.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/319555.html阅读全文

Robin's Java World 2010-04-28 09:56 发表评论
]]>
BlazeDSl合Tomcatq行权限控制http://www.aygfsteel.com/fastzch/archive/2010/04/27/319428.htmlRobin's Java WorldRobin's Java WorldTue, 27 Apr 2010 01:56:00 GMThttp://www.aygfsteel.com/fastzch/archive/2010/04/27/319428.htmlhttp://www.aygfsteel.com/fastzch/comments/319428.htmlhttp://www.aygfsteel.com/fastzch/archive/2010/04/27/319428.html#Feedback0http://www.aygfsteel.com/fastzch/comments/commentRss/319428.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/319428.html 环境Q?br /> BlazeDS 3.2.0.3978
Tomcat 6.0.29 (本例在Tomcat 5.5中不能正常运行,因ؓTomcat 5.5的context部分的设计与6.0不一?
Java5

1Q在service-config.xml中加入认证和角色Q组Q的定义Q?br />
<security>
        
<login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat" />
        
<security-constraint id="trusted">
        
<auth-method>Basic</auth-method>
            
<roles>
                
<role>tomcat</role>
            
</roles>
        
</security-constraint>
        
<security-constraint id="users">
            
<auth-method>Basic</auth-method>
            
<roles>
                
<role>role1</role>
                
<role>tomcat</role>
            
</roles>
        
</security-constraint>
    
</security>
需要说明的是,q里的security-constraint tag相当于一个角色组Q其id属性就是角色组的IDQ如users角色l包含role1和tomcat两个角色?br /> auth-method tag表示认证的方式,Basic即采用HTTP Basic认证方式Q也可以自己实现认证方式Q可调定为CustomQ关于此U认证方式,我将在稍后分享给大家?br />
q些角色和用P均被定义在Tomcat的conf/tomcat-users.xml配置中:
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<!--
  NOTE:  By default, no user is included in the "manager" role required
  to operate the "/manager" web application.  If you wish to use this app,
  you must define such a user - the username and password are arbitrary.
-->
<!--
  NOTE:  The sample user and role entries below are wrapped in a comment
  and thus are ignored when reading this file. Do not forget to remove
  <!.. ..> that surrounds them.
-->

  
<role rolename="tomcat"/>
  
<role rolename="role1"/>
  
<role rolename="manager"/>
  
<user username="admin" password="admin" roles="manager"/>
  
<user username="tomcat" password="tomcat" roles="tomcat"/>
  
<user username="both" password="tomcat" roles="tomcat,role1"/>
  
<user username="role1" password="tomcat" roles="role1"/>

</tomcat-users>


2Q在remote-config.xml中配|具体的destination的权限约束:
<destination id="Domain">
        
<properties>
            
<source>com.robin.service.domain.DomainService</source>
            
<include-methods>
            
<method name="getAllDomains"/>
            
<method name="addOrUpdateDomain" security-constraint="trusted"/>
            
</include-methods>
        
</properties>
        
<security>
            
<security-constraint ref="users"/>
        
</security>
    
</destination>
在此配置中,定义所有的Ҏ(gu)只要是users角色l中的用户即可访问,但是addOrUpdateDomainҎ(gu)需要trusted角色l中的用h能访问?br />
3Q将BlazeDS与Tomcatl合所依赖的lib复制到l(f)ib目录中,包含flex-tomcat-common.jar和flex-tomcat-server.jar两个JAR?br />
4Q修改Tomcat目录下的conf/context.xml文gQ加入如下ContextQ在Tomcat5.5中无法成功)Q?br />
<Valve className="flex.messaging.security.TomcatValve"/>

好了Q就q么单,重启TomcatQ即可验证了?br />
ȝ一下:
1Q引入了角色l的概念Q这个比较好?br /> 2Q角色和用户定义依赖于TomcatQ无法定义在如DBMS中,不方便修攏V?br /> 3Q跨q_性不好?br /> 4Q资源与权限的映关pd开发时已经l定死,无法动态修攏V?


PSQ?010.4.28. 分nl大家不依赖Tomcat容器实现认证与授权的例子Q如有需要,请参考:?a id="viewpost1_TitleUrl" class="postTitle2" href="http://www.aygfsteel.com/fastzch/archive/2010/04/28/319555.html">BlazeDS自定义认证与权限控制?br />
本Blog所有内容不得随意{载,版权属于作者所有。如需转蝲请与作者联p( fastzch@163.com    QQQ?184314Q?br /> 未经许可的{载,本h保留一切法律权益?br /> 一直以来,发现有某些h完全不尊重我的劳动成果,随意转蝲Q提醒一下那些h心哪天惹上官司?/font>


]]>
BlazeDS Study Notes -- Channel & Endpointhttp://www.aygfsteel.com/fastzch/archive/2010/04/07/317619.htmlRobin's Java WorldRobin's Java WorldWed, 07 Apr 2010 02:27:00 GMThttp://www.aygfsteel.com/fastzch/archive/2010/04/07/317619.htmlhttp://www.aygfsteel.com/fastzch/comments/317619.htmlhttp://www.aygfsteel.com/fastzch/archive/2010/04/07/317619.html#Feedback0http://www.aygfsteel.com/fastzch/comments/commentRss/317619.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/317619.htmlThe following example shows a RemoteObject component that defines a channel set and channel inline in MXML:
...
<RemoteObject id="ro" destination="Dest">
<mx:channelSet>
<mx:ChannelSet>
<mx:channels>
<mx:AMFChannel id="myAmf"
uri="http://myserver:2000/myapp/messagebroker/amf"/>
</mx:channels>
</mx:ChannelSet>
</mx:channelSet>
</RemoteObject>


The following example shows ActionScript code that is equivalent to the MXML code in the previous example:
private function run():void {
 ro = new RemoteObject();
 var cs:ChannelSet = new ChannelSet();
 cs.addChannel(new AMFChannel("myAmf",
 "http://servname:2000/eqa/messagebroker/amf"));
 ro.destination = "Dest";
 ro.channelSet = cs;
}

Important: When you create a channel on the client, you must still include a channel definition that specifies an endpoint class in the services-config.xml file. Otherwise, the message broker cannot pass a Flex client request to an endpoint.

 

 

Assigning channels and endpoints to a destination
1,If most of the destinations across all services use the same channels, you can define application-level default channels in the services-config.xml file, as the following example shows.
Note: Using application-level default channels is a best practice whenever possible.
<services-config ...>
...
<default-channels>
<channel ref="my-http"/>
<channel ref="my-amf"/>
</default-channels>
...
In this case, all destinations that do not define channels use a default channel. Destinations can override the
default channel setting by specifying their own channels, and services can also override it by specifying their own
default channels.
2,If most of the destinations in a service use the same channels, you can define service-level default channels, as
the following example shows:
<service ...>
...
<default-channels>
<channel ref="my-http"/>
<channel ref="my-amf"/>
</default-channels>
...
In this case, all destinations in the service that do not explicitly specify their own channels use the default
channel.
3,The destination definition can reference a channel inline, as the following example shows:
<destination id="sampleVerbose">
<channels>
<channel ref="my-secure-amf"/>
</channels>
...
</destination>

 

 

How to choosing a channel?
1, Non-polling AMF and HTTP channels
You can use AMF and HTTP channels without polling for remote procedure call (RPC) services, such as remoting service calls, proxied HTTP service calls and web service requests. These scenarios do not require the client to poll for messages or the server to push messages to the client.
2, Piggybacking on AMF and HTTP channels
The piggybacking feature enables the transport of queued messages along with responses to any messages the client sends to the server over the channel. Piggybacking provides lightweight pseudo polling, where rather than the client channel polling the server on a fixed or adaptive interval, when the client sends a non-command message to the server (using a Producer or RemoteObject object), the server sends any pending data for client messaging or data management subscriptions along with the response to the client message.
Piggybacking can also be used on a channel that has polling enabled but on a wide interval like 5 seconds or 10 seconds or more, in which case the application appears more responsive if the client is sending messages to the server. In this mode, the client sends a poll request along with any messages it sends to the server between its regularly scheduled poll requests. The channel piggybacks a poll request along with the message being sent, and the server piggybacks any pending messages for the client along with the acknowledge response to the client message.
3, Polling AMF and HTTP channels
AMF and HTTP channels support simple polling mechanisms that clients can use to request messages from the server at set intervals. A polling AMF or HTTP channel is useful when other options such as long polling or streaming channels are not acceptable and also as a fallback channel when a first choice, such as a streaming channel, is unavailable at run time.
4, Long polling AMF and HTTP channels
You can use AMF and HTTP channels in long polling mode to get pushed messages to the client when the other more efficient and real-time mechanisms are not suitable. This mechanism uses the normal application server HTTP request processing logic and works with typical J2EE deployment architectures.
You can establish long polling for any channel that uses a non-streaming AMF or HTTP endpoint by setting the polling-enabled ,  polling-interval-millis ,  wait-interval-millis , and  client-wait-interval-
millis  properties in a channel definition.
5, Streaming channels
For streaming, you can use streaming AMF or HTTP channels. Streaming AMF and HTTP channels work with streaming AMF or HTTP endpoints.

 

 


Long polling AMF and HTTP channels
In the default configuration for a polling AMF or HTTP channel, the endpoint does not wait for messages on the server. When the poll request is received, it checks whether any messages are queued for the polling client and if so, those messages are delivered in the response to the HTTP request. You configure long polling in the same way as polling, but you also must set the  wait-interval-millis ,  max-waiting-poll-requests , and client-wait-interval-millis  properties.
在一个polling AMF或HTTP channel默认配置下,服务端endpoint不会{待消息Q当轮询h被收到时Q它查Q何消息是否排队等待轮询的客户端,如果是,q些消息被交付给HTTPh的响应?br /> To achieve long polling, you set the following properties in the  properties  section of a channel definition in the services-config.xml file:
polling-enabled
polling-interval-millis
wait-interval-millis 
max-waiting-poll-requests .
client-wait-interval-millis


下面分别讲一下前面提到的几种模式Q?br /> 1)无轮询AMF、HTTP通道
你可以用这些通道无轮询的方式来提供RPC 服务Q比如远E服务调用、代理HTTP服务调用以及Web serviceh。这些方案不要求客户端轮询信息或者服务端消?#8220;?#8221;l客L?br /> <!-- Simple AMF -->
<channel-definition id="samples-amf"
 type="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:8400/myapp/messagebroker/amf"
 type="flex.messaging.endpoints.AmfEndpoint"/>
</channel-definition>

<!-- Simple secure AMF -->
<channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
 <endpoint url="https://{server.name}:9100/dev/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
</channel-definition>

<!-- Simple HTTP -->
<channel-definition id="my-http"
class="mx.messaging.channels.HTTPChannel">
 <endpoint url="http://{server.name}:8400/dev/messagebroker/http" class="flex.messaging.endpoints.HTTPEndpoint"/>
</channel-definition>

<!-- Simple secure HTTP -->
<channel-definition id="my-secure-http" class="mx.messaging.channels.SecureHTTPChannel">
 <endpoint url="https://{server.name}:9100/dev/messagebroker/httpsecure" class="flex.messaging.endpoints.SecureHTTPEndpoint"/>
</channel-definition>


2)搭蝲式AMF、HTTP通道
搭蝲式确保独立于客户端发送信息到服务端或者服务端响应消息到客L的数据传输。搭载式提供了轻量的假轮询Q一U比固定或者适当旉间隔轮询服务端更好的方式Qs特别是当客户端发送一个非命o消息到服务器Q用一个生产者或RemoteObject对象Q时Q服务器发送Q何未定的数据到客户端或数据理订阅随着客户端的信息响应?br /> 也可以在一个需要确保轮询,但是间隔却比较长Q例?U或?0U甚x多的通道中用,在这U情况下Q应用程序似乎更加敏感。这U模式下Q客L的轮询请求独立于M其他消息发送给服务?/p>

3)轮询AMF、HTTP通道
AMF、HTTP通道提供了简单的轮询机制Q客L可以用这个机制定期发送请求消息到服务端。当长期轮询或者流通道不能使用Ӟ或者作Z个流通道的备用通道时候,轮询AMF、HTTP通道是适用的?br /> <!-- AMF with polling -->
<channel-definition id="samples-polling-amf" type="mx.messaging.channels.AMFChannel">
 <endpoint url="http://{server.name}:8700/dev/messagebroker/amfpolling"   type="flex.messaging.endpoints.AMFEndpoint"/>
 <properties>
  <polling-enabled>true</polling-enabled>
  <polling-interval-seconds>8</polling-interval-seconds>
 </properties>
</channel-definition>

<!-- HTTP with polling -->
<channel-definition id="samples-polling-http" type="mx.messaging.channels.HTTPChannel">
<endpoint url="http://{server.name}:8700/dev/messagebroker/httppolling"
 type="flex.messaging.endpoints.HTTPEndpoint"/>
  <properties>
 <polling-enabled>true</polling-enabled>
 <polling-interval-seconds>8</polling-interval-seconds>
  </properties>
</channel-definition>
 注意Q这U模式中你也可以使用secure通道?/p>

 

 

4)  长轮询AMF、HTTP通道
当其他更加有效率的实时机制不合适的时候,你可以用AMF和HTTP通道的长期轮询模式来“?#8221;消息到客L?This mechanism uses the normal application server HTTP request processing logic and works with typical J2EE deployment architectures.q一机制的用标准应用服务器的HTTPh处理逻辑Qƈ与典型的J2EE架构协同工作?br /> You can establish long polling for any channel that uses a non-streaming AMF or HTTP endpoint by setting the polling-enabled , polling-interval-millis , wait-interval-millis , and client-wait-interval-millis properties in a channel definition; for more information, see Simple channels and endpoints .(zhn)可以ؓM通道建立长期轮询来用相应端点,需要设|一下参敎ͼpolling-enabled、polling-interval-millis、wait-interval-millis、client-w ait-interval-mills。有关wait-interval-millis的更多内容请参考Blazeds文档?br /> <!-- Long polling AMF -->
<channel-definition id="my-amf-longpoll" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://servername:8700/contextroot/messagebroker/myamflongpoll"
 class="flex.messaging.endpoints.AMFEndpoint"/>
  <properties>
 <polling-enabled>true</polling-enabled>
 <polling-interval-seconds>0</polling-interval-seconds>
 <wait-interval-millis>60000</wait-interval-millis>
 <client-wait-interval-millis>3000</client-wait-interval-millis>
 <max-waiting-poll-requests>100</max-waiting-poll-requests>
  </properties>
</channel-definition>

 

关于 Non-polling,Polling,Long polling和steaming的一些解?br /> http://www.qgy18.com/2008/08/webim-design-transport/
http://newteevee.com/2009/10/04/adobe-to-finally-support-http-streaming/

1.短轮?polling)Q核心思想是客L定时L务器取消息。ؓ了实现即时效果,轮询的间隔必设计得_短,另外Z操作的流畅,需要用Ajax来发送请求。本人的QGYWebIM是采用的此Ҏ(gu)。这U方案的优点是:后端E序~写比较Ҏ(gu)Q发送完响应信息马上断开q接Q不会占用太多服务器资源。缺Ҏ(gu)一般情况下Q频J的h中有大半是无用,q些冗余h无Ş中浪费了带宽和服务器资源。我们可以通过判断用户的活跃程度来决策h服务器的间隔Q我?1的一个帖子提到过q种Ҏ(gu)Q但是间隔一旦长了,消息的传送就有gӞq背了即时聊天的初衷了?/p>

2.长轮?long-polling)Q基本原理是客户端向服务器发送请求,服务器接到请求后hold住连接,直到有新消息才返回响应信息ƈ关闭q接Q连接被断开期间用户的新信息会被服务器缓存v来。客L处理完响应信息后再向服务器发送新的请求。这U做法的优势是如果用户一直没新消息,客户端不会频J的轮询L务器取消息,节省了流量,但是服务器维持长q接是很消耗资源的。具体实现v来,前端q边基本不需要什么改动,依然是用Ajax轮询取信息,后端需要在没有新消息时处理一下?/p>

3.长连?streaming)Q其实很早以前就有h使用q种技术来实现聊天室的通讯QHTTP1.1开始支持。以前在面中嵌入一个iframeQiframe里放一个用长q接面Q服务器有新消息׃及时的在iframe里反映出来,再依靠客L的脚本解析出来就O(jin)K了。这样做一个比较严重的问题是:使用 iframeh长连接时Q无论是IEq是firefox都会认ؓ面没有加蝲完而显C度条Q很隄。不q这个问题是可以解决的。firefox支持了Streaming AjaxQ在readyState?的时候就能接受数据,所以问题不大;IE则只能在readyState?Q即q接断开时才能得到返回倹{但是伟大的Google工程师用了一个hack成功的解决了q个问题Q用一个被UCؓ“htmlfile”的ActiveXQ把iframe攑֜q个ActiveX里就O(jin)K了?/p>

无疑Q用长q接对于用户来说是最好的Ҏ(gu)Q用户体验最好(消息能及时的到达Q、占用用户带宽最(不会发送无用的hQ,但是会增加服务器的开销Q长轮询是折中方案,Facebook IM 是采用q种Ҏ(gu)Q不q做了一Ҏ(gu)动:客户端发L每个q接服务器都hold10SQ这10S中新消息会源源不断的q回l客LQ?0s后连接关闭,客户端发起下一个连接。这样做是因为Facebook的用户会不断的打开、关闭新面Q如果每个页面都建立一个永久的长连接,会阻塞浏览器其他hQ服务器也会吃不消的Q短轮询因ؓ实现h单,适用于小型应用?/p>

 

 


There is a browser-specific limit to the number of connections allowed per session. In Firefox, the limit is eight connections per session. In Internet Explorer, the limit is two connections allowed per session. Therefore, BlazeDS must limit the number of streaming connections per session on the server to stay below this limit.

 

 


Channel and endpoint recommendations

1. AMFChannel/Endpoint configured for long polling (no fallback needed)
Benifits:
Valid HTTP request/response pattern over standard ports that nothing in the network path will have trouble with.
Disadvantages:
When many messages are being pushed to the client, this configuration has the overhead of a poll round trip for every pushed message or small batch of messages queued between polls. Most applications are not pushing data so frequently for this to be a problem.
The Servlet API uses blocking IO, so you must define an upper bound for the number of long poll requests parked on the server at any single instant. If your number of clients exceeds this limit, the excess clients devolve to simple polling on the default 3- second interval with no server wait.
For example, if you server request handler thread pool has a size of 500, you could set the upper bound for waited polls to 250, 300, or 400 depending on the relative amount of non-poll requests you expect to service concurrently.

2. StreamingAMFChannel/Endpoint (in a channel set followed by the polling AMFChannel for fallback)
Benifits:
No polling overhead associated with pushing messages to the client.
Uses standard HTTP ports so firewalls do not interfere and all requests/responses are HTTP so packet inspecting proxies won’t drop the packets.
Disadvantages:
Holding onto the open request on the server and writing an infinite response is not typical HTTP behavior. HTTP proxies that buffer responses before forwarding them can effectively consume the stream. Assign the channel’s ‘connect-timeout-seconds’ property a value of 2 or 3 to detect this and trigger fallback to the next channel in your channel set.
No support for HTTP 1.0 client. If the client is 1.0, the open request is faulted and the client falls back to the next channel in its channel set.
The Servlet API uses blocking IO so as with long polling above, you must set a configured upper bound on the number of streaming connections you allow. Clients that exceed this limit are not able to open a streaming connection and will fall back to the next channel in their channel set.

3. AMFChannel/Endpoint with simple polling and piggybacking enabled (no fallback needed)
Benifits:
Valid HTTP request/response pattern over standard ports that nothing in the network path will have trouble with.
User experience feels more real-time than with simple polling on an interval.
Does not have thread resource constraints like long polling and streaming due to the blocking IO of the Servlet API.
Disadvantages:
Less real-time behavior than long polling or streaming. Requires client interaction with the
server to receive pushed data faster than the channel's configured polling interval.

 



]]>
BlazeDS Study Notes -- Achitecturehttp://www.aygfsteel.com/fastzch/archive/2010/04/03/317413.htmlRobin's Java WorldRobin's Java WorldSat, 03 Apr 2010 14:31:00 GMThttp://www.aygfsteel.com/fastzch/archive/2010/04/03/317413.htmlhttp://www.aygfsteel.com/fastzch/comments/317413.htmlhttp://www.aygfsteel.com/fastzch/archive/2010/04/03/317413.html#Feedback0http://www.aygfsteel.com/fastzch/comments/commentRss/317413.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/317413.html Channels and channel sets
A Flex component uses a channel to communicate with a BlazeDS server. A channel set contains channels; its primary function is to provide connectivity between the Flex client and the BlazeDS server. A channel set contains channels ordered by preference. The Flex component tries to connect to the first channel in the channel set and in the case where a connection cannot be established falls back to the next channel in the list. The Flex component continues to go through the list of channels in the order in which they are specified until a connection can be established over one of the channels or the list of channels is exhausted.
Flex clients can use different channel types such as the AMFChannel and HTTPChannel. Channel selection depends on a number of factors, including the type of application you are building. If non-binary data transfer is required, you would use the HTTPChannel, which uses a non-binary format called AMFX (AMF in XML).

Messages
All messages have client-side (ActionScript) implementations and server-side (Java) implementations because the messages are serialized and deserialized on both the client and the server.

Endpoint
 It is important that the channel and the endpoint use the same message format.

MessageBroker
The MessageBroker is responsible for routing messages to services and is at the core of BlazeDS on the server. After an endpoint initially processes the request, it extracts the message from the request and passes it to the MessageBroker. The MessageBroker inspects the message's destination and passes the message to its intended service. If the destination is protected by a security constraint, the MessageBroker runs the authentication and authorization checks before passing the message along

Services and destinations
Services and destinations are the next links in the message processing chain in the BlazeDS server. The system includes four services and their corresponding destinationsBlazeDS:
•     RemotingService and RemotingDestination
•     HTPProxyService and HTTPProxyDestination
•     MessageService and MessageDestination
Services are the targets of messages from client-side Flex components. Think of destinations as instances of a service configured in a certain way. For example, a RemoteObject component is used on the Flex client to communicate with the RemotingService. In the RemoteObject component, you must specify a destination  id  property that refers to a remoting destination with certain properties, such as the class you want to invoke methods on. The mapping between client-side Flex components and BlazeDS services is as follows:
•     HTTPService and WebService communicate with HTTPProxyService/HTTPProxyDestination         (RPC services)
•     RemoteObject communicates with RemotingService/RemotingDestination    (RPC services)
•     Producer and Consumer communicate with MessageService/MessageDestination   (Message services)


Adapters and assemblers
Although the BlazeDS server comes with a rich set of adapters and assemblers to communicate with different systems, custom adapters and assemblers can be plugged into the BlazeDS server. Similarly, you do not have to create all destinations in configuration files, but instead you can create them dynamically at server startup or when the server is running.


Configuration tokens
The configuration files sometimes contain special  {server.name}  and  {server.port}  tokens. These tokens are replaced with server name and port values based on the URL from which the SWF file is served when it is accessed through a web browser from a web server. Similarly, a special  {context.root}  token is replaced with the actual context root of a web application.
Note: If you use server tokens in a configuration file for an Adobe AIR application and you compile using that file, the application will not be able to connect to the server. You can avoid this issue by configuring channels in ActionScript rather than in a configuration file.

How you define JVM options depends on the application server you use. For example, in Apache Tomcat, you can define an environment variable JAVA_OPTS that contains tokens and their values, as this code snippet shows:
JAVA_OPTS=-Dmessaging.channel=my-amf -Dmy.token=myValue

 



]]>
BlazeDS Study Notes -- Building Projecthttp://www.aygfsteel.com/fastzch/archive/2010/04/01/317237.htmlRobin's Java WorldRobin's Java WorldThu, 01 Apr 2010 14:31:00 GMThttp://www.aygfsteel.com/fastzch/archive/2010/04/01/317237.htmlhttp://www.aygfsteel.com/fastzch/comments/317237.htmlhttp://www.aygfsteel.com/fastzch/archive/2010/04/01/317237.html#Feedback0http://www.aygfsteel.com/fastzch/comments/commentRss/317237.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/317237.htmlBuild client-side application notes:
1, Specifying the services-config.xml file in a compilation
When you compile your Flex application, you typically specify the services-config.xml configuration file to the compiler. This file defines the channel URLs that the client-side Flex application uses to communicate with the BlazeDS server. Then the channel URLs are compiled into the resultant SWF file.
Both client-side and server-side code use the services-config.xml configuration file. If you change anything in services-config.xml, you usually have to recompile your client-side applications and restart your server-side application for the changes to take effect.
In Flex Builder, the appropriate services-config.xml file is included automatically based on the BlazeDS web application that you specified in the configuration of your Flex Builder project. When you use the mxmlc compiler, use the  services  option to specify the location of the file.
Note: You can also create channel definitions at run time in ActionScript. In that case, you might be able to omit the reference to the services-config.xml configuration file from the compiler.
2, Specifying the context root in a compilation
The services-config.xml configuration file typically uses the  context.root  token to specify the context root of a
web application. At compile time, you use the compiler  context-root  option to specify that information.
During a compilation, Flex Builder automatically sets the value of the  context.root  token based on the BlazeDS
web application that you specified in the configuration of your project. When you use the mxmlc compiler, use the
context-root  option to set it.

 
How to create a Flash Builder project?
Use this procedure to create a Flex Builder project to edit one of the samples shipped with the Test Drive application.
The procedure for creating and configuring a new project is almost the same as the following procedure.
1     Start Flex Builder.
2     Select File > New > Flex Project.
3     Enter a project name. You are editing an existing application, so use the exact name of the sample folder:
testdrive-chat.
Note: If you are creating an empty project, you can name it anything that you want.
4     If you unzipped flex-src.zip in the samples directory, deselect the Use Default Location option, and specify the directory as C:\blazeds\tomcat\webapps\samples\testdrive-chat, or wherever you unzipped the file on your computer.
Note: By default, Flex Builder creates the project directory based on the project name and operating system. For example, if you are using the plug-in configuration of Flex Builder on Microsoft Windows, the default project directory is C:\Documents and Settings\USER_NAME\workspace\PROJECT_NAME.
5     Select the application type as Web application (runs in Flash Player) to configure the application to run in the browser as a Flash Player pplication.
If you are creating an AIR application, select Desktop Application (Runs In Adobe AIR). However, make sure that you do not have any server tokens in URLs in the configuration files. In the web application that ships with BlazeDS, server tokens are used in the channel endpoint URLs in the WEB-INF/flex/services-config.xml file, as the following example shows:
<endpoint
url="https://{server.name}:{server.port}/{context.root}/messagebroker/streamingamf"
      class="flex.messaging.endpoints.StreamingAMFEndpoint"/>
You would change that line to the following:
<endpoint url="http://your_server_name:8400/samples/messagebroker/streamingamf"
      class="flex.messaging.endpoints.StreamingAMFEndpoint"/>
6     Select J2EE as the Application server type.
7     Select Use Remote Object Access.
8     Select LiveCycle Data Services.
9     If the option is available, deselect Create Combined Java/Flex Project With WTP.
10  Click Next.
11  Deselect Use Default Location For Local LiveCycle Data Services Server.
12  Set the root folder, root URL, and context root of your web application.
The root folder specifies the top-level directory of the web application (the directory that contains the WEB-INF directory). The root URL specifies the URL of the web application, and the context root specifies the root of the web application.
13  Make sure that your BlazeDS server is running, and click Validate Configuration to ensure that your project is valid.
14  Verify that the Compile The Application Locally In Flex Builder option is selected.
15  Clear the Output Folder field to set the directory of the compiled SWF file to the main project directory.
By default, Flex Builder writes the compiled SWF file to the bin-debug directory under the main project directory. To use a different output directory, specify it in the Output Folder field.
16  Click Next.
17  Set the name of the main application file to Chat.mxml, and click Finish.

 

 Client-side logging
For client-side logging, you directly write messages to the log file, or configure the application to write messages generated by Flex to the log file. Flash Debug Player has two primary methods of writing messages to a log file:
?     The global  trace()  method. The global trace() method prints a String to the log file. Messages can contain checkpoint information to signal that your application reached a specific line of code, or the value of a variable.
?     Logging API. The logging API, implemented by the TraceTarget class, provides a layer of functionality on top of the  trace()  method. For example, you can use the logging API to log debug, error, and warning messages generated by Flex while applications execute.
Flash Debug Player sends logging information to the flashlog.txt file. The operating system determines the location of this file, as the following table shows:
Use settings in the mm.cfg text file to configure Flash Debug Player for logging. If this file does not exist, you can create it when you first configure Flash Debug Player. The location of this file depends on your operating system.
The following table shows where to create the mm.cfg file for several operating systems:
The mm.cfg file contains many settings that you can use to control logging. The following sample mm.cfg file enables error reporting and trace logging:
ErrorReportingEnable=1
TraceOutputFileEnable=1
After you enable reporting and logging, call the  trace()  method to write a String to the flashlog.txt file, as the
following example shows:
trace("Got to checkpoint 1.");
Insert the following MXML line to enable the logging of all Flex-generated debug messages to flashlog.txt:
<mx:TraceTarget loglevel="2"/>

Server-side logging
You configure server-side logging in the logging section of the services configuration file, services-config.xml. By default, output is sent to System.out.
You set the logging level to one of the following available levels:
?     All
?     Debug
?     Info
?     Warn
?     Error
?     None
You typically set the server-side logging level to  Debug  to log all debug messages, and also all info, warning, and error messages. The following example shows a logging configuration that uses the  Debug  logging level:
<logging>
<!-- You may also use flex.messaging.log.ServletLogTarget. -->
<target class="flex.messaging.log.ConsoleTarget" level="Debug">
<properties>
<prefix>[Flex]</prefix>
<includeDate>false</includeDate>
<includeTime>false</includeTime>
<includeLevel>false</includeLevel>
<includeCategory>false</includeCategory>
</properties>
<filters>
<pattern>Endpoint</pattern>
<!--<pattern>Service.*</pattern>-->
<!--<pattern>Message.*</pattern>-->
</filters>
</target>
</logging>

 

 

You use two parameters in a channel definition to enable message processing metrics:
     <record-message-times> 
     <record-message-sizes> 
Set these parameters to  true  or  false ; the default value is  false . You can set the parameters to different values to capture only one type of metric. For example, the following channel definition specifies to capture message timing
information, but not message sizing information:
<channel-definition id="my-streaming-amf"
class="mx.messaging.channels.StreamingAMFChannel">
<endpoint
url="http://{server.name}:{server.port}/{context.root}/messagebroker/streamingamf"
class="flex.messaging.endpoints.StreamingAMFEndpoint"/>
 <properties>
  <record-message-times>true</record-message-times>
  <record-message-sizes>false</record-message-sizes>
 </properties>
</channel-definition>



]]>
BlazeDS Study Notes -- Overview & Conceptshttp://www.aygfsteel.com/fastzch/archive/2010/03/31/317033.htmlRobin's Java WorldRobin's Java WorldWed, 31 Mar 2010 04:19:00 GMThttp://www.aygfsteel.com/fastzch/archive/2010/03/31/317033.htmlhttp://www.aygfsteel.com/fastzch/comments/317033.htmlhttp://www.aygfsteel.com/fastzch/archive/2010/03/31/317033.html#Feedback1http://www.aygfsteel.com/fastzch/comments/commentRss/317033.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/317033.htmlFlex and AIR applications use Flex components to communicate with the BlazeDS server, including the RemoteObject, HTTPService, WebService, Producer, and Consumer components. The HTTPService, WebService, Producer, and Consumer components are part of the Flex Software Development Kit (SDK).

What's Producer?

The BlazeDS core features include the RPC services and the Messaging Service.
You can access data through client-side RPC components that include HTTP GET or POST (HTTP services), SOAP (web services), or Java objects (remote object services).
BlazeDS lets you use RemoteObject components to access remote Java objects without configuring them as SOAP-compliant web services.

Client applications that send messages are called message producers. You define a producer in a Flex application by using the Producer component. Client applications that receive messages are called message consumers. You define a consumer in a Flex application by using the Consumer component. A Consumer component subscribes to a server-side destination and receives messages that a Producer component sends to that destination. For more information on messaging, see Using the Messaging Service.


BlazeDS uses a message-based framework to send data back and forth between the client and server. BlazeDS uses two primary exchange patterns between server and client. In the first pattern, the request-response pattern, the second pattern is the publish-subscribe pattern where the server routes published messages to the set of clients that have subscribed to receive them.

 

To send messages across the network, the client uses channels. A channel encapsulates message formats, network protocols, and network behaviors to decouple them from services, destinations, and application code. A channel formats and translates messages into a network-specific form and delivers them to an endpoint on the server. 

 


Channels communicate with Java-based endpoints on the server. An endpoint unmarshals messages in a protocol-specific manner and then passes the messages in generic Java form to the message broker. The message broker determines where to send messages, and routes them to the appropriate service destination.
BlazeDS includes several types of channels, including standard and secure Action Message Format (AMF) channels and HTTP (AMFX) channels. AMF and HTTP channels support non-polling request-response patterns and client polling patterns to simulate real-time messaging. The streaming AMF and HTTP channels provide true data streaming for real-time messaging. 

 

 Configure an existing J2EE web application to support BlazeDS by performing the following steps: 
 1, Add the BlazeDS JAR files and dependent JAR files to the WEB-INF/lib directory. 
2, Edit the BlazeDS configuration files in the WEB-INF/flex directory. 
3, Define MessageBrokerServlet and a session listener in WEB-INF/web.xml.



]]>
Flash Performance Issue in None-activeX Architecture -- stutter soundhttp://www.aygfsteel.com/fastzch/archive/2010/03/05/314592.htmlRobin's Java WorldRobin's Java WorldFri, 05 Mar 2010 04:15:00 GMThttp://www.aygfsteel.com/fastzch/archive/2010/03/05/314592.htmlhttp://www.aygfsteel.com/fastzch/comments/314592.htmlhttp://www.aygfsteel.com/fastzch/archive/2010/03/05/314592.html#Feedback0http://www.aygfsteel.com/fastzch/comments/commentRss/314592.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/314592.html
The root cause of this issue is used to extract method of Sound class for retract samples, and then play by extracted samples. You may ask me, why don't use play method of Sound class directly? I think I only answer you that it's business requirements.

Following are my test code:
package {
    
import flash.events.Event;
    
import flash.events.SampleDataEvent;
    
import flash.media.Sound;
    
import flash.net.URLRequest;
    
import flash.system.System;
    
import flash.utils.ByteArray;

    
public class Extract {
        
private var sourceSnd:Sound = new Sound();
        
private var outputSnd:Sound = new Sound();
        
private var urlReq:URLRequest = new URLRequest("11k.mp3"); //this file has 575 frames
        
//        private var urlReq:URLRequest = new URLRequest("44k.mp3");  //this file has 1150 frames
        private var samplesCount:uint = 0;

        
public function play():void {
            sourceSnd.load(urlReq);
            
//            sourceSnd.play(); // if use source sound to playing, we will not be got machine gun sound.
            sourceSnd.addEventListener(Event.COMPLETE, loaded); //use this approach, we will be got stutter.
        }


        
private function loaded(event:Event):void {
            outputSnd.addEventListener(SampleDataEvent.SAMPLE_DATA, processSound);
            outputSnd.play();
        }


        
private function processSound(event:SampleDataEvent):void {
            var bytes:ByteArray 
= new ByteArray();
            var samplesPerTime:uint 
= sourceSnd.extract(bytes, 8192);
            samplesCount 
+= samplesPerTime;
            
//            trace("samplesCount:" + samplesCount + ",samplesPerTime:" + samplesPerTime);
            event.data.writeBytes(bytes);
            
//            flash.system.System.gc();
        }


    }

}

You can refer to following test steps for reproduce stutter/machine gun sound issue:
 
1, Run/debug test application in Firefox, you will get smooth sound at once.
 
2, Open a new tab in the same window, and open a heavy load web page (for example: http://www.taobao.com)
 
3, You will get stutter when a heavy load page is loading.

If you interest in this problem also, we can study it together.


]]>
Sound Extract Method Studyhttp://www.aygfsteel.com/fastzch/archive/2009/12/15/305917.htmlRobin's Java WorldRobin's Java WorldTue, 15 Dec 2009 04:50:00 GMThttp://www.aygfsteel.com/fastzch/archive/2009/12/15/305917.htmlhttp://www.aygfsteel.com/fastzch/comments/305917.htmlhttp://www.aygfsteel.com/fastzch/archive/2009/12/15/305917.html#Feedback2http://www.aygfsteel.com/fastzch/comments/commentRss/305917.htmlhttp://www.aygfsteel.com/fastzch/services/trackbacks/305917.html The extract method like a black box, we can't know what does it do.

1, Extract low sample rate sound will be get more samples, I can't understand that why like this. I know that it will transfer all kind of sample rate to 44.1KHz, but we can't know that how to transfer?

2, MPEG wave data is not bound to a single frame, so we need overlap some frames in a SWF sound what the sound compose of some frames. the overlap size is an experience value, in general, I set it as 7 frames. The value is depend your parse frames and detail extract algorithm sometimes. Anyway, 7 is my recommendation value.

3, This method can provide some very useful function with SoundMixer class for extend your application. For instance, show wave shape, add some effect, etc.
There is a sample for show waveform:
http://www.bytearray.org/?p=329

At last, I strong recommend an open source project, this project is a stream player based on Flex platform.
http://code.google.com/p/as3mp3streamplayer/

If you had deeply researched at this method, please communication with me. thank you!
 



]]>
վ֩ģ壺 Ž| | ĺ| | | Զ| | | | Ĭ| ƽ| | żҴ| | ʯ| | ¡| Դ| | ɳ| | ͭϿ| | ѳ| | | ΢| п| Ӻ| ɳ| | | | ˳| ƽɽ| | | Ϫ| ˳| Ӳ| ̩|