package org.whu.sklse.utils;
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;
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Flex_Spring3_Hibernate3整合Demo,使用RemoteObject调用java代码。主要配置为applicationContext.xml,web.xml,services-config.xml,remoting-config.xml。另外要引入SpringFactory类。
资源推荐
资源详情
资源评论
收起资源包目录
FSH.rar (88个子文件)
FSH
.project 2KB
flex_libs
bin
.settings
com.adobe.flexbuilder.project.prefs 79B
org.eclipse.core.resources.prefs 88B
org.eclipse.wst.common.component 514B
org.eclipse.jdt.core.prefs 330B
org.eclipse.wst.common.project.facet.core.xml 269B
org.eclipse.jst.common.project.facet.core.prefs 359B
.mymetadata 285B
.actionScriptProperties 964B
html-template
AC_OETags.js 8KB
index.template.html 4KB
history
history.js 24KB
historyFrame.html 827B
history.css 371B
playerProductInstall.swf 657B
.myeclipse
src
org
whu
sklse
utils
SpringFactory.java 6KB
dao
StudentDAO.java 918B
BaseDAO.java 4KB
ro
HelloWorld.java 659B
entity
Student.hbm.xml 1KB
Student.java 1KB
.springBeans 482B
WebContent
WEB-INF
flex
messaging-config.xml 513B
remoting-config.xml 519B
services-config.xml 4KB
version.properties 73B
proxy-config.xml 826B
web.xml 3KB
src
applicationContext.xml 2KB
lib
org.springframework.orm-3.0.5.RELEASE.jar 326KB
commons-logging.jar 37KB
org.springframework.web.portlet-3.0.5.RELEASE.jar 171KB
org.springframework.jdbc-3.0.5.RELEASE.jar 377KB
org.springframework.instrument-3.0.5.RELEASE.jar 2KB
org.springframework.web.struts-3.0.5.RELEASE.jar 31KB
org.springframework.aop-3.0.5.RELEASE.jar 314KB
org.springframework.core-3.0.5.RELEASE.jar 373KB
org.springframework.web-3.0.5.RELEASE.jar 386KB
jta-1.1.jar 11KB
javassist-3.12.0.GA.jar 618KB
cfgatewayadapter.jar 15KB
hibernate3.jar 3.95MB
org.springframework.web.servlet-3.0.5.RELEASE.jar 409KB
org.springframework.oxm-3.0.5.RELEASE.jar 60KB
flex-messaging-proxy.jar 65KB
mysql-connector-java-5.1.11.jar 715KB
org.springframework.test-3.0.5.RELEASE.jar 200KB
org.springframework.instrument.tomcat-3.0.5.RELEASE.jar 6KB
commons-httpclient-3.0.1.jar 273KB
org.springframework.expression-3.0.5.RELEASE.jar 166KB
org.springframework.context-3.0.5.RELEASE.jar 653KB
ejb3-persistence.jar 49KB
commons-collections-3.1.jar 546KB
org.springframework.asm-3.0.5.RELEASE.jar 52KB
flex-messaging-remoting.jar 18KB
commons-codec-1.3.jar 46KB
org.springframework.jms-3.0.5.RELEASE.jar 181KB
dom4j-1.6.1.jar 307KB
org.springframework.transaction-3.0.5.RELEASE.jar 226KB
org.springframework.beans-3.0.5.RELEASE.jar 542KB
flex-messaging-common.jar 94KB
slf4j-api-1.6.1.jar 25KB
org.springframework.aspects-3.0.5.RELEASE.jar 35KB
flex-messaging-core.jar 669KB
flex-messaging-opt.jar 20KB
antlr-2.7.6.jar 433KB
org.springframework.context.support-3.0.5.RELEASE.jar 99KB
flex-rds-server.jar 53KB
xalan.jar 3MB
classes
org
whu
sklse
utils
SpringFactory.class 2KB
SpringFactory$SpringFactoryInstance.class 3KB
dao
StudentDAO.class 300B
BaseDAO.class 3KB
ro
HelloWorld.class 1KB
entity
Student.hbm.xml 1KB
Student.class 2KB
bin
AC_OETags.js 8KB
FSH.swf 815KB
FSH.html 4KB
history
history.js 24KB
historyFrame.html 827B
history.css 371B
playerProductInstall.swf 657B
META-INF
MANIFEST.MF 254B
.classpath 772B
flex_src
FSH.mxml 640B
.myhibernatedata 599B
.flexProperties 313B
共 88 条
- 1
资源评论
- nanfengbubai2014-10-13不是很好用
- 该昵称已被占用了2013-03-07没运行起来,但还是谢谢。
- duanchunxiao20082013-12-23eclipse 没运行起来
春文秋武
- 粉丝: 125
- 资源: 48
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 光储并网VSG系统Matlab simulink仿真模型,附参考文献 系统前级直流部分包括光伏阵列、变器、储能系统和双向dcdc变器,后级交流子系统包括逆变器LC滤波器,交流负载 光储并网VSG系
- file_241223_024438_84523.pdf
- 质子交膜燃料电池PEMFC Matlab simulink滑模控制模型,过氧比控制,温度控制,阴,阳极气压控制
- IMG20241223015444.jpg
- 模块化多电平变器(MMC),本模型为三相MMC整流器 控制策略:双闭环控制、桥臂电压均衡控制、模块电压均衡控制、环流抑制控制策略、载波移相调制,可供参考学习使用,默认发2020b版本及以上
- Delphi 12 控件之FlashAV FFMPEG VCL Player For Delphi v7.0 for D10-D11 Full Source.7z
- Delphi 12 控件之DevExpressVCLProducts-24.2.3.exe.zip
- Mysql配置文件优化内容 my.cnf
- 中国地级市CO2排放数据(2000-2023年).zip
- smart200光栅报警程序
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功