简体   繁体   English

在Flex应用程序中获取数据的最佳方法是哪种?

[英]Which is the best way to get Data in my Flex Application?

I am new in Flex Development, While creating a new Mobile project it asks me if I want to Connect it to Some Servers and gives me four options `ColdFusion, PHP, Java and blazeDS). 我是Flex开发的新手,在创建新的Mobile项目时,它询问我是否要将其连接到某些服务器,并给了我四个选项(ColdFusion,PHP,Java和blazeDS)。

I have worked in java for all the time and not a PHP fellow, I would have simply selected Java and ignored all other. 我一直在Java中工作,而不是PHP学者,我只会选择Java而忽略其他所有东西。 But Since efficiency is an important concern in my current project I dont want to take a chance. 但是由于效率是我当前项目中的一个重要问题,所以我不想冒险。

According to you Which one is the best option ie ColdFusion, BlazeDS or Java, considering the fact that most of the time I will be storing large binary data in database ie Audio / Video files etc.? 根据您的说法,考虑到大多数情况下我将大型二进制数据存储在数据库中,例如音频/视频文件等,哪个是最佳选择,即ColdFusion,BlazeDS或Java?

Since you're a Java guy, you can immediately drop the PHP option: its AMF remoting options are slower than the other 3 and you don't want to learn a new language. 由于您是Java人士,因此可以立即删除PHP选项:其AMF远程处理选项比其他3个选项慢,并且您不想学习新的语言。

That leaves us with Java, CF, and BlazeDS, which are all basically flavors of Java and performance-wise they can be fairly similar (if used correctly: see further on): 剩下的就是Java,CF和BlazeDS,它们基本上都是Java的味道,在性能方面,它们可以非常相似(如果使用正确,请继续阅读):

  • Java: the most basic option; Java:最基本的选择; I reckon it's the fastest option for AMF remoting; 我认为这是AMF远程处理的最快选择。 plus you know the language 再加上你会说语言
  • BlazeDS: this is actually a Java server application that allows you to push messages to the client; BlazeDS:这实际上是一个Java服务器应用程序,允许您将消息推送到客户端。 so you can also write in Java; 所以你也可以用Java编写; but if you don't require the added functionality, don't bother 但是,如果您不需要添加的功能,请不要打扰
  • ColdFusion: a 'productivity layer' on top of Java: whether or not you like the language is up to you to decide (I personally am not a big fan). ColdFusion:Java之上的“生产力层”:您是否喜欢这种语言取决于您自己决定(我个人也不是很喜欢)。 You will have to setup a ColdFusion server. 您将必须设置ColdFusion服务器。 Though the developer edition of the CF server is free, the commercial edition is very expensive (unless you use Railo or BlueDragon). 尽管CF服务器的开发人员版本是免费的,但商业版本却非常昂贵(除非您使用Railo或BlueDragon)。

But there's one thing you need to know. 但是,您需要了解一件事。 Instantiation in CF is terribly expensive - I mean like 500 times slower than Java -, so if you have big lists it's definitely a nono. CF中的实例化非常昂贵-我的意思是比Java慢500倍-因此,如果您的清单很大,那肯定是一个麻烦的事。 Unless you use the trick I bumped into a few months ago: instead of instantiating an object you have to create a 'struct' and give it a '__type__' attribute. 除非您使用几个月前碰到的技巧,否则您必须创建一个“结构”并为其赋予一个“ __type__”属性,而不是实例化一个对象。

example, instead of: 例如,代替:

var instance = new path.to.MyClass();
//or
var instance = createObject("component", "path.to.MyClass");

do it like this: 像这样做:

var instance = structNew();
instance["__type__"] = "path.to.MyClass";

and ColdFusion will be just as fast - or maybe even slightly faster - then Java. 而且ColdFusion的速度将与Java一样快-甚至可能更快。

I have some benchmarks to back this up. 我有一些基准来支持这一点。 This image is a comparison of how much time it takes to create 50000 instances in some languages. 此图像是使用某些语言创建50000个实例所需时间的比较。 (I was actually trying to tell my boss how crappy CF really is.) And CF8 (not in the chart) is even 100 times slower. (我实际上是想告诉老板CF到底有多糟糕。)CF8(不在图表中)甚至慢了100倍。

在此处输入图片说明

Then I added AMF serialization and the 'typed struct' (as described earlier) to the list and this is the result: 然后,我在列表中添加了AMF序列化和“类型化结构”(如前所述),结果如下:

在此处输入图片说明

Some column names were lost in the graphic, but the second column from the left is the pure Java option. 一些列名称在图形中丢失了,但是左边第二列是纯Java选项。 So with this approach CF9 seems to actually be faster than Java. 因此,使用这种方法,CF9实际上似乎比Java更快。

I've been doing Flex -> ColdFusion for several years and while I sometimes get frustrated with coding ColdFusion, it has been great for handling the back end of Flex applications. 我从事Flex-> ColdFusion已有几年了,尽管有时我对编码ColdFusion感到沮丧,但它对于处理Flex应用程序的后端非常有用。 That said, I also use BlazeDS with ColdFusion and Flex to power (push) messaging in a couple of clients. 就是说,我还将BlazeDS与ColdFusion和Flex结合使用,以在几个客户端中推动(推送)消息传递。

Ultimately, I think ColdFusion (especially with the open source CFML server, Railo) is a fantastic back end (ie, data provider) for Flex applications. 最终,我认为ColdFusion(尤其是开源CFML服务器Railo)是Flex应用程序的理想后端(即数据提供程序)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM