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
- 【SSH框架】系列之 Spring 整合 Hibernate 框架框架Spring
- Quartz - Spring和Quartz的整合quartzSpring
- [java web]Idea+maven+spring4+hibernate5+struts2整合過程JavaWebIdeaMavenSpring
- JavaFX 整合 Sqlite 和 Hibernate 開發爬蟲應用JavaSQLite爬蟲
- MyBatis和Spring整合的奧祕MyBatisSpring
- SSH三大框架的搭建整合(Spring+Hibernate+Struts2)實現增刪改查登入框架Spring
- spring:spring與mybatis的整合SpringMyBatis
- Shiro和Spring MVC、Mybatis整合教程SpringMVCMyBatis
- Mybatisi和Spring整合原始碼分析MyBatisSpring原始碼
- Spring中如何配置Hibernate事務Spring
- Spring MVC學習筆記和SSH的整合SpringMVC筆記
- Spring的Junit整合Spring
- Spring 4.2.2以上版本和swagger整合方案和踩過的坑SpringSwagger
- spring+redis的整合,使用spring-data-redis來整合SpringRedis
- 手寫一個Redis和Spring整合的外掛RedisSpring
- 彈性盒模型中flex-grow 和flex的區別模型Flex
- Spring 對Mabatis的整合SpringBAT
- Dozer的使用: 整合SpringSpring
- 使用 Hibernate 和 H2 的多租戶Spring Boot開源原始碼專案Spring Boot原始碼
- Hibernate/JPA中@OneToOne和@MapsId的使用
- Spring Boot 整合 MyBatis和 SQL Server實踐Spring BootMyBatisSQLServer
- Spring Boot整合Spring SecuritySpring Boot
- Spring Boot整合Spring BatchSpring BootBAT
- Spring Boot整合Spring AopSpring Boot
- SpringBoot整合Hibernate Validator實現引數驗證功能Spring Boot
- MyBatis(九) 整合Spring、整合SpringMVCMyBatisSpringMVC
- Spring MVC整合redis的配置SpringMVCRedis
- Mybatis 的使用(整合Spring、SpringBoot)MyBatisSpring Boot
- Spring+SpringMVC+MyBatis的整合SpringMVCMyBatis
- mybatis整合springMyBatisSpring
- ActiveMq整合SpringMQSpring
- Spring Cloud 整合SpringCloud
- Spring 整合 MyBatisSpringMyBatis
- Spring整合WebSocketSpringWeb
- Spring整合JUnitSpring
- Spring整合MyBatisSpringMyBatis
- Apache Camel與Spring-boot和Kafka的整合開源案例ApacheSpringbootKafka
- Spring boot入門(二):Spring boot整合MySql,Mybatis和PageHelper外掛Spring BootMySqlMyBatis