blazeds加入spring需要注意如下几个地方:
1.引入spring.jar
2.remoting-config.xml中加入如下配置:
<destination id ="helloworld">
<properties >
<factory>spring</factory><!--通过spring得到类的实例-->
<source>helloworld</source>
</properties >
3.写一个类名为SpringFactory implements FlexFacotry
代码如下:
package spring.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;
/**
* This interface is implemented by factory components which provide
* instances to the flex messaging framework. To configure flex data services
* to use this factory, add the following lines to your services-config.xml
* file (located in the WEB-INF/flex directory of your web application).
*
* <factories>
* <factory id="spring" class="flex.samples.factories.SpringFactory" />
* </factories>
*
* You also must configure the web application to use spring and must copy the spring.jar
* file into your WEB-INF/lib directory. To configure your app server to use spring,
* you add the following lines to your WEB-INF/web.xml file:
*
* <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>
*
* Then you put your spring bean configuration in WEB-INF/applicationContext.xml (as per the
* line above). For example:
*
* <?xml version="1.0" encoding="UTF-8"?>
* <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
*
* <beans>
* <bean name="weatherBean" class="dev.weather.WeatherService" singleton="true"/>
* </beans>
*
* Now you are ready to define a destination in flex that maps to this existing service.
* To do this you'd add this to your WEB-INF/flex/remoting-config.xml:
*
* <destination id="WeatherService">
* <properties>
* <factory>spring</factory>
* <source>weatherBean</source>
* </properties>
* </destination>
*
* @author Jeff Vroom
*/
public class SpringFactory implements FlexFactory
{
private static final String SOURCE = "source";
/**
* This method can be used to initialize the factory itself. It is called with configuration
* parameters from the factory tag which defines the id of the factory.
*/
public void initialize(String id, ConfigMap configMap) {}
/**
* This method is called when we initialize the definition of an instance
* which will be looked up by this factory. It should validate that
* the properties supplied are valid to define an instance.
* Any valid properties used for this configuration must be accessed to
* avoid warnings about unused configuration elements. If your factory
* is only used for application scoped components, this method can simply
* return a factory instance which delegates the creation of the component
* to the FactoryInstance's lookup method.
*/
public FactoryInstance createFactoryInstance(String id, ConfigMap properties)
{
SpringFactoryInstance instance = new SpringFactoryInstance(this, id, properties);
instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId()));
return instance;
} // end method createFactoryInstance()
/**
* Returns the instance specified by the source
* and properties arguments. For the factory, this may mean
* constructing a new instance, optionally registering it in some other
* name space such as the session or JNDI, and then returning it
* or it may mean creating a new instance and returning it.
* This method is called for each request to operate on the
* given item by the system so it should be relatively efficient.
* <p>
* If your factory does not support the scope property, it
* report an error if scope is supplied in the properties
* for this 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;
}
}
}
}
4.在services-config.xml加入如下代码:
<factories>
id就是remoting-config.xml <factory>spring<factory> ;
class:具体的实现类
<factory id="spring" class="spring.factories.SpringFactory"/>
</factories>
5.web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
分享到:
相关推荐
【标题】"Flex4.X+BlazeDS+Spring3实战开发在线书店四"涉及的核心技术栈是Adobe Flex 4.6、BlazeDS、Spring 3框架以及Java相关的JPA和Hibernate,配合MySQL数据库实现一个在线书店的完整系统。下面将详细阐述这些...
标题“flex+blazeds+spring”表明我们要探讨的是如何将Flex前端与BlazeDS中继层和Spring后端框架结合起来,实现完整的数据交互和应用程序逻辑。 在Flex与Spring集成的环境中,Flex作为用户界面展示层,负责与用户...
标题中的“PureMVC+Flex+BlazeDS+Spring+Hibernate.doc”指的是一项整合了多种技术的Web应用开发方案,这些技术包括PureMVC、Flex、BlazeDS、Spring和Hibernate。这篇文档可能是指导读者如何将这些技术结合在一起...
《Flex4.X+BlazeDS+Spring3 实战开发在线书店》是一门深入探讨使用Adobe Flex 4.6、BlazeDS、Spring 3框架以及Java相关技术进行Web应用程序开发的课程。这门课程旨在帮助开发者掌握如何构建功能丰富的、交互性强的...
在本课程中,我们将深入探讨如何使用Flex 4.6、BlazeDS、Spring 3 和其他相关技术来构建一个实际的在线书店应用。Flex 4.6 是Adobe Flex框架的一个重要版本,它提供了强大的富互联网应用程序(RIA)开发工具,使...
### Flex4+BlazeDS+Spring+iBatis 开发教程详解 #### 一、富互联网应用(RIA)概念与背景 ##### RIA定义 富互联网应用(Rich Internet Application,简称RIA)是一种新兴的应用程序形式,它结合了客户端与服务器端...
使用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+blazeDS+Spring官方Demo,环境搭建,内含十几个例子,从易到难,包括spring消息,spring安全,注解方式和非注解配置文件方式,十分好用。内含有tomcat,可直接启动并运行用户手册。
在"Flex4.X+BlazeDS+Spring3 实战开发在线书店一"这个项目中,开发者将学习如何利用这些技术构建一个功能完整的在线书店应用。Flex 4.6的Spark组件库提供了丰富的UI元素,可以设计出美观的用户界面。ActionScript ...
Myeclipse6.5+flex3+Blazeds+spring+hibernate完美整合,写的非常详细
Flex+BlazeDS+Spring+Hibernate 是一个经典的前端与后端集成方案,广泛应用于构建富互联网应用程序(Rich Internet Applications,RIA)。在这个框架组合中,Flex 作为用户界面层,提供了丰富的交互体验;BlazeDS ...
**集成Remote Object到Spring**:在Flex客户端,使用RemoteObject组件与BlazeDS建立连接,然后在Spring配置文件中定义相应的服务代理,以便于Spring管理这些远程服务。 D. **引入Hibernate框架**:在Java后端,...
《Flash Builder 4 + BlazeDs + Spring + Hibernate + Cairngorm 开发框架详解》 在IT行业中,构建高效、可扩展的Web应用是一项至关重要的任务。这个开发框架组合——Flash Builder 4、BlazeDs、Spring、Hibernate...
根据提供的文件信息,本文将详细介绍如何一步步搭建PureMVC+Flex+BlazeDS+Spring+Hibernate的技术栈。这个过程涉及到了多个技术领域的整合,包括前端的Flex开发、后端的Java开发以及数据库交互等多个方面。 ### 一...
在“Flex4+BlazeDS+Spring+Hibernate 整合源码”中,开发者可能实现了以下功能: 1. 使用Flex4创建前端用户界面,包括自定义组件和动画效果。 2. 通过BlazeDS配置,实现在Flex客户端与Spring服务层之间的数据双向...
标题中的“PureMVC+Flex+BlazeDS+Spring+Hibernate”是一个常见的技术栈组合,用于构建企业级的 Rich Internet Applications (RIA)。这个技术栈包括前端开发框架、后端服务通讯、应用服务器、服务端架构和数据持久化...
Flex+Gilead+BlazeDS+Spring+Hibernate示例Demo,使用1:n和m:n两个双向关系,很好的演示了Gilead的Hibernate Lazy Killer特性,借助Gilead可以有效规避DTO模式的大量繁琐代码。效果图展示地址:...
通过以上步骤,你将成功构建一个完整的PureMVC+Flex+BlazeDS+Spring+Hibernate RIA系统,实现前端与后端的无缝集成,提供高效的数据交换和复杂的业务处理能力。在实际开发中,你可能还需要考虑错误处理、安全性和...
标题中的“flex+spring +BlazeDs+spring+ibatis+Cairngorm整合教程”涉及到的是一个基于Adobe Flex前端、Spring后端服务、BlazeDS作为数据通信中间件、Spring框架进行服务管理以及Ibatis作为持久层操作的典型企业级...
在"BlazeDS+Spring+SpringMVC 注解方式配置文件"的场景下,我们将关注如何使用注解来简化这三者之间的整合。注解是Java中的一种元数据,可以为编译器或运行时环境提供信息,简化代码并减少XML配置。 首先,...