现在的位置: 首页 > 综合 > 正文

blazeds与spring的结合使用

2013年10月22日 ⁄ 综合 ⁄ 共 5292字 ⁄ 字号 评论关闭

一直看好spring opensource,如何更好地将blazeds与spring完美结合起来是其目标之一。spring的两大特点分别是依赖注入和切面编程,使用spring框架对于代码污染非常少,鬼知道当初rod johnson怎么搞出来这么一套厉害的东西!拉扯远了,进入正题。

1.什么是spring blazeds integration?

懒得翻译了,自己看吧。

Spring has always aimed to be agnostic to the client technologies being used to access its core services, intentionally leaving options open and letting the community drive the demand for any new first-class integration solutions to be added to the Spring project portfolio. Spring BlazeDS Integration is an answer to the commmunity demand for a top-level solution for building Spring-powered Rich Internet Applications using Adobe Flex for the client-side technology.

BlazeDS is an open source project from Adobe that provides the remoting and messaging foundation for connecting a Flex-based front-end to Java back-end services. Though it has previously been possible to use BlazeDS to connect to Spring-managed services, it has not been in a way that feels "natural" to a Spring developer, requiring the extra burden of having to maintain a separate BlazeDS xml configuration. Spring BlazeDS Integration turns the tables by making the BlazeDS MessageBroker a Spring-managed object, opening up the pathways to a more extensive integration that follows "the Spring way".

2.系统需求。

Java 5 以上

Spring 2.5.6 以上

Adobe BlazeDS 3.2 以上

3.服务端开发。

在服务器端的开发主要涉及了web.xml和applicationContext的配置。

其中web.xml配置如下:定义了spring的分发servlet和其映射的表达式。

在spring的配置的文件当中,我们需要在头部加上flex的命名空间等:

接着我们必须定义一个MessageBroker的工厂类和指出service-config.xml的路径。

如何定义一个映射请求的urlhandler类:

再定义一个分发请求的类:

最后,将我们的服务给暴露出来:

至此服务端开发完毕。

4.客户端开发。

客户端的开发就显得比较简单了:

这样配置好客户端和服务端便可以调用开发了,是不是很简单呢?有需要的朋友不妨向我索要代码。

【上篇】
【下篇】

抱歉!评论已关闭.