flex与Spring整合1

在flex中我们要调用java对象需要在remoting-config.xml中这样配置:

 <destination id="helloAction"> 
 <properties> 
 <source>com.deng.action.HelloAction</source> 
 </properties> 
 </destination>

 但是这样配置的话,我们的对象HelloAction就是用flex给我们new出来的,它并不是使用spring容器的,所以我们的目标就是flex直接到sping容器中去取,也就是用到spring的依赖查找而不是依赖注入了.

 

具体的整合方式如下:

  1.增加SpringFactory.java代码,该代码在http://flex-java.googlecode.com/svn/trunk/flex/01-java/src/flex/spring/factories/SpringFactory.java,直接拷过来就是不用作任何修改(后续会给出改代码)

  2. SpringFactory我们需要将其注册到flex中,修改services-config.xml在文件中加入下面这段配置:

<factories>
    <factory id="spring" class="com.deng.factory.SpringFactory"/>
</factories>

3.修改remoting-config.xml,如下所示:

    <destination id="helloAction">
        <properties>
            <factory>spring</factory>
            <source>helloActionBean</source>
       </properties>
    </destination>

其中factory的属性值就是我们在services-config.xml配置文件中我们配置的factory id

source 就是对应我们在spring配置文件application.xml配置的bean的id,如下所示:

    <bean id="helloActionBean" class="com.deng.action.HelloAction">
    </bean>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值