http://blog.sina.com.cn/s/blog_50af6d3801009pms.html
本文内容我没有验证过,仅仅是转过来,备用
一、目标
1、可以将flex编译产生的*.swf、*.as、*.css、图片等资源文件按模块分开打包,最后将这些资源发布成web服务
2、可以将实现按模块分bundle
二、普通方式下的flex实现
此处,采用flex的amf协议
1、web.xml文件
从web.xml中的servlet可以看出,由flex.messaging.MessageBrokerServlet来处理amf协议请求,同时分别需要提供services-config.xml的配置文件及flex目录来读取诸如remoting-config.xml等配置文件
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<servlet-class>
flex.messaging.MessageBrokerServlet
</servlet-class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</init-param>
<init-param>
<param-name>flex.write.path</param-name>
<param-value>/WEB-INF/flex</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
2、
三、osgi整合
1、发布servlet及资源
在Activator implements BundleActivator的start()方法中添加
下面相关的引用自己先搞定,可以参考后面会发布的一篇文章
待发:《使用org.osgi.service.http.HttpService发布web资源》
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.http.HttpService;
import flex.messaging.MessageBrokerServlet;
ServiceReference sr = context.getServiceReference(HttpService.class
.getName());
httpService = (HttpService) context.getService(sr);
// 保存全局的资源发布对象
Constant.httpService = httpService;
// 原web.xml中的MessageBrokerServlet的初始化参数
Dictionary<String, String> initparams = new Hashtable<String, String>();
initparams.put("services.configuration.file",
Constant.FLEX_PROJECT_CATALOG
+ Constant.SERVICES_CONFIGURATION_FILE);//设置找到路径即可
initparams.put("flex.write.path", Constant.FLEX_PROJECT_CATALOG
+ Constant.FLEX_WRITE_PATH);
initparams.put("load-on-startup", "1");
// 发布MessageBrokerServlet
httpService.registerServlet("/messagebroker",
new MessageBrokerServlet(), initparams, null);
扩展org.eclipse.equinox.http.registry的扩展点发布资源
如
httpService.registerResources("/base", "net/oupu/drp/base/client/flex/webapp", null);
上面这段代码,将net/oupu/drp/base/client/flex/webapp发布为路径base的资源,如访问
http://ip:port/base/index.swf
即是访问net/oupu/drp/base/client/flex/webapp下的index.swf文件
2、在remoting-config.xml中添加对应的destination
<destination id="*Service">
<properties>
<source>you_package.*Service</source>
</properties>
</destination>
you_package.*Service为提供方法的实现类
flex中通过endpoit,destination 的方式通过amf协议调用java类
3、动态扩展
部分代码设密,只说明一下思路
由于对于每一个service,都要去配置remoting-config.xml
所以,这里,我们可以只写一个destination,通过as文件来全局调用这一个
只需要将方法名,类全名,参数。传递过来
在you_package.*Service类中通过反射的方法来调用对应的类来处理或返回给flex前端
同时,为了as与java之间的传值比较方便,
可以在将as的object通过jasn转成java的object
分享到:
相关推荐
OSGI 整合 Flex 原创, 介绍了Flex跟Java通讯。 Flex集成到OSGI插件里面, 怎么调试插件里面的Flex,非常详细。 我花了2天时间才写完。...Flex整合OSGI讲解材料,包含PPT,word版详尽使用手册和源代码。
OSGI企业应用开发(十五)基于Spring、Mybatis、Spring MVC实现一个登录应用博文源码
基于osgi整合ssm框架开发web项目,使用ssm注解的方式开发,缺少两个jsp文件,能运行
spring-dm整合osgi所需所有jar包
OSGI入门和整合Spring OSGI入门和整合Spring
NULL 博文链接:https://zhouxi1987.iteye.com/blog/974105
OSGI + Webservice 例子 新手入门的例子
osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍osgi介绍
OSGi与Web容器的整合
OSGI进阶.pdf,OSGI实战.pdf,OSGI入门和整合Spring.pdf
一个osgi集成ibatis的例子,我也是在网上下载的
OSGI企业应用开发(十四)整合Spring、Mybatis、Spring MVC博文源码
OSGI 入门资料PDF,包括OSGI实战、OSGI进阶、OSGI 入门和整合Spring、OSGI原理与最佳实践
资源名称:OSGI原理与最佳实践内容简介:国内第一本OSGi图书OSGi国内推广者林昊多年经验的结晶涵盖OSGi从入门到深入的知识体系引领OSGi国内研究和普及本书基于作者多年使用OSGi的经验而编写,涵盖了OSGi从入门到深入...
讲述了Spring和Strust2的整合
利用R-OSGi实现分布式OSGi应用 本文通过介绍传统 OSGi 应用程序及 R-OSGi 的实现方式入手,阐述了 R-OSGi 对于 OSGi 规范的实现方式。然后通过一个简单的功能实现由浅入深地讲述传统 OSGi 和 R-OSGi 上的两种不同...
OSGI入门和整合Spring + OSGI进阶 + OSGI实战
网上收集的OSGI资料. 包括: OSGi原理与最佳实践(精选版).pdf OSGI实战和源码.rar osgi进阶.pdf Introduce.OSGi.ppt OSGi.in.action.ppt r4.cmpn.pdf r4.core.pdf r4.enterprise.pdf