Flex 开发学习笔记2 - 采用的架构 BlazeDS + Spring + Hibernate

本文介绍如何使用BlazeDS实现Flex与Spring的集成,包括配置步骤、Flex页面访问远程对象的示例代码,以及如何从Spring容器中获取Bean。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

自己原来的项目架构是 WebWork2 + Spring + Hibernate,现在通过FLex替代了WebWrok2来表显视图层,而Flex与Spring通讯采用了BlazeDS这个开源免费的Flex服务程序。

 

       BlazeDS是Adobe公司发布的免费开源产品,与该公司的另一款收费产品LCDS功能相近,应该是LCDS简化开源免费版。目前我通过RemoteObject的方式访问后台Service感觉比较方便。BlazeDS下载地址:http://opensource.adobe.com/wiki/display/blazeds/download+blazeds+3

 

       如何通过RemoteObject访问Spring管理的Bean,我参照另一篇教程文档 进行了设计与开发,在这篇文章中,用的是Adobe非免费Flex服务程序,只需要将LCDS中的flex.war换成BlazeDS中的flex.war就可以了。另外,这里有一篇“使用BlazeDS实现Java Flex 通信 ”的文章,讲解了如何在eclipse中配置Flex工程。

 

       以下是一个Flex页面访问RemoteObject的代码:

Xml代码
  1. <? xml   version = "1.0"   encoding = "utf-8" ?>   
  2. < mx:Application   xmlns:mx = "http://www.adobe.com/2006/mxml"   layout = "absolute" >   
  3.     < mx:Script >   
  4.         <![CDATA[  
  5.             import mx.rpc.events.ResultEvent;  
  6.             import mx.controls.Alert;  
  7.             private function callRO(str:String):void{  
  8.                 Alert.show("flexSpringBeanTest");  
  9.                 firstRO.say(str);  
  10.                 firstRO.addEventListener(ResultEvent.RESULT,getROResult);  
  11.             }  
  12.               
  13.             private function getROResult(e:ResultEvent) :void {  
  14.                 Alert.show(e.result.toString());  
  15.             }  
  16.             //flexObjectTest  
  17.         ]]>   
  18.     </ mx:Script >   
  19.       
  20.     < mx:RemoteObject   id = "firstRO"   destination = "flexSpringBeanTest" />   
  21.     < mx:TextInput   x = "109"   y = "28"   id = "input"   text = "hello!" />   
  22.     < mx:Button   x = "270"   y = "28"   click = "callRO(input.text)"   label = "请求" />   
  23. </ mx:Application >   
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.ResultEvent;
			import mx.controls.Alert;
			private function callRO(str:String):void{
				Alert.show("flexSpringBeanTest");
				firstRO.say(str);
				firstRO.addEventListener(ResultEvent.RESULT,getROResult);
			}
			
			private function getROResult(e:ResultEvent) :void {
				Alert.show(e.result.toString());
			}
			//flexObjectTest
		]]>
	</mx:Script>
	
	<mx:RemoteObject id="firstRO" destination="flexSpringBeanTest"/>
	<mx:TextInput x="109" y="28" id="input" text="hello!"/>
	<mx:Button x="270" y="28" click="callRO(input.text)" label="请求"/>
</mx:Application>

 

   在remote-config.xml配置里,映射一个Spring管理的Bean是这么写的

Xml代码
  1. < destination   id = "flexSpringBeanTest" >   
  2.       < properties >   
  3.               < factory > springFactory </ factory >    
  4.               < source > flexObjectTest </ source >   
  5.       </ properties >   
  6. </ destination >   
  <destination id="flexSpringBeanTest">
        <properties>
                <factory>springFactory</factory> 
                <source>flexObjectTest</source>
        </properties>
  </destination>

 

    在services-config.xml配置自定义的SpringFactory类,即我们要实现从从spring容器中去取得bean。

Xml代码
  1. < factories >   
  2.       < factory   id = "springFactory"   class = "cn.org.coral.core.flex.factory.FlexSpringFactory"   />    
  3. </ factories >   
  <factories>
        <factory id="springFactory" class="cn.org.coral.core.flex.factory.FlexSpringFactory" /> 
  </factories>

    这个工厂类的定义:

Java代码
  1. package  cn.org.coral.core.flex.factory;  
  2.   
  3. import  flex.messaging.FactoryInstance;  
  4. import  flex.messaging.FlexFactory;  
  5. import  flex.messaging.config.ConfigMap;  
  6.   
  7. /**  
  8.  * 要对某个java类实现自己定义的切入,可以使用工厂配置,需要在ro访问前,从spring里去getbean<br>  
  9.  *   
  10.  * @author Libin  
  11.  *  
  12.  */   
  13. public   class  FlexSpringFactory  implements  FlexFactory{  
  14.   
  15.     @Override   
  16.     public  FactoryInstance createFactoryInstance(String id, ConfigMap properties){  
  17.         SpringFactoryInstance instance = new  SpringFactoryInstance( this , id, properties);  
  18.         instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId()));  
  19.         return  instance;  
  20.     }  
  21.     @Override   
  22.     public  Object lookup(FactoryInstance inst)  {  
  23.         SpringFactoryInstance factoryInstance = (SpringFactoryInstance) inst;  
  24.         return  factoryInstance.lookup();  
  25.     }   
  26.   
  27.     @Override   
  28.     public   void  initialize(String arg0, ConfigMap arg1) {  
  29.         // TODO Auto-generated method stub   
  30.           
  31.     }  
  32.   
  33. }  
package cn.org.coral.core.flex.factory;

import flex.messaging.FactoryInstance;
import flex.messaging.FlexFactory;
import flex.messaging.config.ConfigMap;

/**
 * 要对某个java类实现自己定义的切入,可以使用工厂配置,需要在ro访问前,从spring里去getbean<br>
 * 
 * @author Libin
 *
 */
public class FlexSpringFactory implements FlexFactory{

	@Override
	public FactoryInstance createFactoryInstance(String id, ConfigMap properties){
        SpringFactoryInstance instance = new SpringFactoryInstance(this, id, properties);
        instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId()));
        return instance;
    }
	@Override
	public Object lookup(FactoryInstance inst)  {
        SpringFactoryInstance factoryInstance = (SpringFactoryInstance) inst;
        return factoryInstance.lookup();
    } 

	@Override
	public void initialize(String arg0, ConfigMap arg1) {
		// TODO Auto-generated method stub
		
	}

}

 

该factory需要实现FlexFactory接口。实现createFactoryInstance方法和lookup方法

Java代码
  1. package  cn.org.coral.core.flex.factory;  
  2.   
  3. import  org.springframework.beans.BeansException;  
  4. import  org.springframework.beans.factory.NoSuchBeanDefinitionException;  
  5. import  org.springframework.context.ApplicationContext;  
  6. import  org.springframework.web.context.support.WebApplicationContextUtils;  
  7.   
  8. import  flex.messaging.FactoryInstance;  
  9. import  flex.messaging.config.ConfigMap;  
  10. import  flex.messaging.services.ServiceException;  
  11.   
  12. public   class  SpringFactoryInstance  extends  FactoryInstance  
  13. {  
  14.     SpringFactoryInstance(FlexSpringFactory factory, String id, ConfigMap properties)  
  15.     {  
  16.         super (factory, id, properties);  
  17.     }  
  18.     public  Object lookup()   
  19.     {  
  20.         //这就是从spring容器中getbean了   
  21.         ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());  
  22.         String beanName = getSource();  
  23.   
  24.         try   
  25.         {  
  26.             return  appContext.getBean(beanName);  
  27.         }  
  28.         catch  (NoSuchBeanDefinitionException nexc)  
  29.         {  
  30.             ServiceException e = new  ServiceException();  
  31.             throw  e;  
  32.         }  
  33.         catch  (BeansException bexc)  
  34.         {  
  35.             ServiceException e = new  ServiceException();  
  36.             throw  e;  
  37.         }   
  38.     }  
  39.       
  40. }   
package cn.org.coral.core.flex.factory;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import flex.messaging.FactoryInstance;
import flex.messaging.config.ConfigMap;
import flex.messaging.services.ServiceException;

public class SpringFactoryInstance extends FactoryInstance
{
    SpringFactoryInstance(FlexSpringFactory factory, String id, ConfigMap properties)
    {
        super(factory, id, properties);
    }
    public Object lookup() 
    {
        //这就是从spring容器中getbean了
        ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());
        String beanName = getSource();

        try
        {
            return appContext.getBean(beanName);
        }
        catch (NoSuchBeanDefinitionException nexc)
        {
            ServiceException e = new ServiceException();
            throw e;
        }
        catch (BeansException bexc)
        {
            ServiceException e = new ServiceException();
            throw e;
        } 
    }
    
} 

 

   后台service的定义:

Java代码
  1. package  cn.org.coral.sample.flex.manager;  
  2.   
  3. public   class  FlexObjectTest {  
  4.   
  5.     public  String say(String str){  
  6.         return   "say : "  + str;  
  7.     }  
  8.       
  9. }  
package cn.org.coral.sample.flex.manager;

public class FlexObjectTest {

	public String say(String str){
		return "say : " + str;
	}
	
}

 

  spring-context.xml的配置

Xml代码
  1. <? xml   version = "1.0"   encoding = "UTF-8" ?>   
  2. <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">   
  3. < beans >   
  4.   
  5.     < bean   id = "flexObjectTest"   
  6.         class = "cn.org.coral.sample.flex.manager.FlexObjectTest" >   
  7.     </ bean >   
  8.   
  9. </ beans >  
内容概要:《中文大模型基准测评2025年上半年报告》由SuperCLUE团队发布,详细评估了2025年上半年中文大模型的发展状况。报告涵盖了大模型的关键进展、国内外大模型全景图及差距、专项测评基准介绍等。通过SuperCLUE基准,对45个国内外代表性大模型进行了六大任务(数学推理、科学推理、代码生成、智能体Agent、精确指令遵循、幻觉控制)的综合测评。结果显示,海外模型如o3、o4-mini(high)在推理任务上表现突出,而国内模型如Doubao-Seed-1.6-thinking-250715在智能体Agent和幻觉控制任务上表现出色。此外,报告还分析了模型性价比、效能区间分布,并对代表性模型如Doubao-Seed-1.6-thinking-250715、DeepSeek-R1-0528、GLM-4.5等进行了详细介绍。整体来看,国内大模型在特定任务上已接近国际顶尖水平,但在综合推理能力上仍有提升空间。 适用人群:对大模型技术感兴趣的科研人员、工程师、产品经理及投资者。 使用场景及目标:①了解2025年上半年中文大模型的发展现状与趋势;②评估国内外大模型在不同任务上的表现差异;③为技术选型和性能优化提供参考依据。 其他说明:报告提供了详细的测评方法、评分标准及结果分析,确保评估的科学性和公正性。此外,SuperCLUE团队还发布了多个专项测评基准,涵盖多模态、文本、推理等多个领域,为业界提供全面的测评服务。
资源下载链接为: https://pan.quark.cn/s/f989b9092fc5 单点定位是卫星导航技术的核心方法,通过接收卫星信号来确定接收器在地球上的位置。它主要涉及分析卫星发射的时间戳、伪距以及卫星轨道信息。MATLAB凭借其强大的数值计算和数据处理能力,可以用来编写程序实现单点定位。RINEX(Receiver Independent Exchange Format)观测文件是一种通用格式,用于存储各种接收机产生的观测数据,如伪距、载波相位和多普勒频移等,便于不同软件进行数据交换和处理。 在MATLAB中实现单点定位的程序通常包括以下步骤:首先,读取RINEX观测文件,解析卫星信号数据,包括处理文件头信息、识别有效观测时段以及提取卫星ID、伪距和时间戳等关键信息。其次,利用星历数据计算卫星在特定时间的位置。星历数据由卫星导航系统地面站提供,包含卫星的精确轨道参数。接下来,对原始伪距进行改正,考虑大气延迟、卫星钟偏和接收机钟偏等因素,这需要对大气折射率进行建模以及估计卫星和接收机的时钟误差。然后,基于改正后的伪距,利用三角定位原理计算接收机的位置,通常采用最小二乘法或其他优化算法来获得最佳解。最后,将计算出的接收机位置与已知点坐标进行比较,评估定位精度,并以经纬度、海拔高度等形式输出结果。 在MATLAB程序single_point_position.m中,可以看到上述步骤的具体实现。代码可能包含RINEX文件解析函数、卫星轨道计算模块、伪距改正函数以及定位计算和输出部分。通过学习和理解该源码,不仅可以深入掌握单点定位原理,还能提升MATLAB编程和处理导航数据的能力。单点定位在实际应用中常用于初步定位或作为更复杂定位方法的基础,如差分定位和动态定位。它在科学研究、导航设备测试和大地测量等领域具有重要价值。通过不断优化这些程序,可以提高定位精度,满足实际需求。
资源下载链接为: https://pan.quark.cn/s/67c535f75d4c Verilog-A是一种高级硬件描述语言,广泛应用于模拟和混合信号电路设计。它具备强大的数学运算能力,能够精确地描述电路的行为和特性。在“用Verilog-A编写的电路模块示例”压缩包中,包含了多种重要的电子电路元件模型,例如PLL(锁相环)、resistor(电阻)、bjt(双极型晶体管)、opamp(运算放大器)、psfet(P沟道金属氧化物半导体场效应晶体管)、deadband(死区)以及sinewave(正弦波)生成器。以下是对这些模块的详细说明。 PLL(锁相环):PLL是数字通信系统中的关键部件,主要用于使接收端的时钟频率与发送端的信号频率同步。通过Verilog-A,可以精确描述PLL的各个组成部分,如压控振荡器(VCO)、分频器、鉴相器和低通滤波器。设计者能够利用Verilog-A精确控制PLL的动态特性,例如环路带宽和锁定时间等。 Resistor(电阻):在Verilog-A中,电阻模型定义了电流与电压之间的关系,遵循欧姆定律。设计者可以指定电阻的温度系数和其他非线性特性,从而更真实地模拟实际电路中的电阻行为。 BJT(双极型晶体管):BJT是模拟电路中的基础元件,具有电流控制电流的特性。在Verilog-A中,BJT模型需要描述基极、发射极和集电极之间的电流关系,以及BJT的放大系数和非线性特性。 Opamp(运算放大器):运算放大器是模拟电路设计的核心元件,常用于信号放大或构建反馈电路。在Verilog-A中,opamp模型包括输入失调电压、增益、共模抑制比等关键参数,以及理想化特性,如无限输入阻抗和零输出阻抗。 Psfet(P沟道金属氧化物半导体场效应晶体管):P沟道MOSFET是数字和模拟电路中的常见开关元件。Verilog-A模型需要描述其阈值电压、亚阈值
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值