在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>