FLEX和spring、hibernate的整合
flex的後臺使用spring+hibernate,spring+hibernate的整合方法和j2ee的專案中方法相同。主要是flex和spring的整合
編寫SpringFactory.java類:
java 程式碼
- package com.fire.spring;
- 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;
- } // end method createFactoryInstance()
- 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;
- }
- }
- }
- }
配置WEB-INF/flex/service-config.xml,在最後新增如下程式碼:
xml 程式碼
xml 程式碼
- <factories>
- <factory id=“spring” class=“com.fire.spring.SpringFactory”/>
- factories>
在使用remoteobject的時候,配置remote-config.xml時,如下進行配置:
xml 程式碼
- <destination id=“provinceService”>
- <properties>
- <factory>spring</factory>
- <source>provinceService</source>
- </properties>
- </destination>
注:以上內容來自網路,本人不承擔任何連帶責任
文章轉自:http://www.daoyu.com/?p=72
相關文章
- Spring 整合 HibernateSpring
- 將Flex與Spring框架整合FlexSpring框架
- sh_Spring整合HibernateSpring
- 整合Macromedia Flex和JavaMacFlexJava
- Spring整合Hibernate的事務管理Spring
- [摘]Struts+Spring+Hibernate整合Spring
- 框架(Spring、Struts2和Hibernate三者)整合框架Spring
- Spring與Hibernate整合中的session問題SpringSession
- struts+hibernate+spring 整合中出現的問題Spring
- 【SSH框架】系列之 Spring 整合 Hibernate 框架框架Spring
- spring json dwr struts2.0 hibernate整合SpringJSON
- Spring和JUnit的整合Spring
- Hibernate--與Spring整合及增刪改查Spring
- Struts2+hibernate+spring配置程式整合下載Spring
- Quartz - Spring和Quartz的整合quartzSpring
- ssh中整合spring和hibernate之後的application.xml檔案的超詳細配置SpringAPPXML
- Spring4學習(四)Spring4中整合Hibernate4Spring
- 整合struts和hibernate開發嚮導 (轉)
- MyBatis和Spring整合的奧祕MyBatisSpring
- Mybatis分頁和Spring的整合MyBatisSpring
- SSH開發實踐part1:Spring與Hibernate整合Spring
- 關於Jdon框架和Hibernate的整合,Banq大哥請進框架
- Struts 和Spring ioc 整合Spring
- Spring事物管理和hibernate事物管理的疑問Spring
- 關於spring和ibatis的整合SpringBAT
- 使用Spring 3.1和Hibernate做持久層Spring
- Spring Boot 整合 Mybatis 和 MySQLSpring BootMyBatisMySql
- JavaFX 整合 Sqlite 和 Hibernate 開發爬蟲應用JavaSQLite爬蟲
- 使用Spring整合Hibernate,並實現對資料表的增、刪、改、查的功能Spring
- Spring與hibernate的問題Spring
- Hibernate,Weblogic整合問題Web
- Mybatisi和Spring整合原始碼分析MyBatisSpring原始碼
- Spring mvc+struts2+Hibernate整合例項程式碼(註解詳解)SpringMVC
- [java web]Idea+maven+spring4+hibernate5+struts2整合過程JavaWebIdeaMavenSpring
- Spring MVC學習筆記和SSH的整合SpringMVC筆記
- Spring和cxf3的整合,以maven的方式SpringMaven
- Spring的Junit整合Spring
- spring:spring與mybatis的整合SpringMyBatis