remoting-config.xml:
<destination id="TestSpring">
<properties>
<factory>spring</factory>
<source>springTest</source> <!--此处注入IOC注入-->
</properties>
</destination>
==============================================================
services-config.xml:
<factories>
<factory id="spring" class="flex.samples.factories.SpringFactory" />
</factories>
==============================================================
web.xml: 和struts整合spring一样
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
============================================================
applicationContext.xml
<bean id="springTest" class="flex.samples.SpringTest">
<property name="description">
<value>Hello Flex To Spring</value>
</property>
</bean>
SpringFactory.java文件
package flex.samples.factories;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import flex.messaging.FactoryInstance;
import flex.messaging.FlexFactory;
import flex.messaging.config.ConfigMap;
import flex.messaging.services.ServiceException;
public class SpringFactory implements FlexFactory
{
private static final String SOURCE = "source";
public void initialize(String id, ConfigMap configMap) {}
public FactoryInstance createFactoryInstance(String id, ConfigMap properties)
{
SpringFactoryInstance instance = new SpringFactoryInstance(this, id, properties);
instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId()));
return instance;
}
public Object lookup(FactoryInstance inst)
{
SpringFactoryInstance factoryInstance = (SpringFactoryInstance) inst;
return factoryInstance.lookup();
}
static class SpringFactoryInstance extends FactoryInstance
{
SpringFactoryInstance(SpringFactory factory, String id, ConfigMap properties)
{
super(factory, id, properties);
}
public String toString()
{
return "SpringFactory instance for id=" + getId() + " source=" + getSource() + " scope=" + getScope();
}
public Object lookup()
{
ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());
String beanName = getSource();
try
{
return appContext.getBean(beanName);
}
catch (NoSuchBeanDefinitionException nexc)
{
ServiceException e = new ServiceException();
String msg = "Spring service named '" + beanName + "' does not exist.";
e.setMessage(msg);
e.setRootCause(nexc);
e.setDetails(msg);
e.setCode("Server.Processing");
throw e;
}
catch (BeansException bexc)
{
ServiceException e = new ServiceException();
String msg = "Unable to create Spring service named '" + beanName + "' ";
e.setMessage(msg);
e.setRootCause(bexc);
e.setDetails(msg);
e.setCode("Server.Processing");
throw e;
}
}
}
}
=============================================
SpringTest.java
package flex.samples;
public class SpringTest {
private String description;
public String getDescription() {
return "This description from String. [" + description + "]";
}
public void setDescription(String description) {
this.description = description;
}
}
Flex.mxml:
<mx:RemoteObject id="myspring" destination="TestSpring" />
<mx:Button x="25" y="80" label="Call Spring" width="100" click="myspring.getDescription();" />
<mx:Label x="25" y="100" width="334" text="{myspring.getDescription.lastResult}"/>
//注意颜色对应关系
分享到:
相关推荐
hibernate+flex+spring 整合,hibernate+flex+spring 集成
自己写的Flex+spring+hibernate示例,精简易懂
Flex+Spring+Hibernate 整合的方式有多种,本文是利用flex builder插件,将flex与javaEE服务器端整合到一个工程里面,以便程序员可以在一个IDE里完成开发。
使用flex 4.5 + Spring 3.0 + Hibernate 3.3 + Cairngorm 2.2.1 + BlazeDS 3.3.0 + Spring BlazeDS Integration 1.0.3整合出的一个登录的小demo·
Flex PureMVC Flex BlazeDS Spring Hibernate 整合 里面一些图标是包双击可查看源代码
flex+spring+hibernate+mysql
Flex+spring+hibernate视屏,Flex+spring+hibernate视屏
flex整合hibernate,spring,详细配置
用flex+spring+hibernate整合的一个小小的登陆实例,希望对学习flex+java通信开发的有点帮助吧
博客项目,采用flex4.0+hibernate+spring+mysql实现;是本人在网上下载的,并经过整理了;下载后创建数据库,部署到tomcat上就可以运行;项目的功能不重要,重要的是参考这个框架在可以开发flex+spring+hibernate...
MyEclipse7.5+flex4+spring3.0.5+struts2.2.1+hibernate3.6.0+blazeds4.0.0.14931完美整合方案 内附所需jar包和源代码
flex与+struts2+hibernate+spring集成实例项目,源码奉献,物有所值
适用于有spring,hibernate搭建有了解的并且知道flex开发的人员,只是基础的spring+hibernate+flex项目搭建,新手入门哦!
Flex+spring+hibernate框架配置详解啊,包含源文件的
flex4+blazeds+spring+hibernate集成源码。内附完整jar包以及配置。给后来知道者帮助。
flex+java+spring+hibernate+blazeds整合
花了四天终于搭好flex+spring+hibernate。。。 我是初学者。。希望多点交流
MyEclipse7.5+flex4+spring+struts+hibernate+blazeds整合
该文档描述了安装Flex,将FlashBulider嵌入到MyEclipse8.6中的安装过程,并且逐步将Flex+Spring+Hibernate结合的详细过程一一列出来,供大家参考
Flex+hibernate+spring整合