IT民工窝棚qbq.blog.chinaunix.net
qbq
全部博文(708)
国产(1)
欧美(1)
SEO(1)
CSS3(5)
TestNG(4)
HTML5(2)
iBatis(3)
URLRewrite(1)
WebService(1)
WebServer(12)
PHP(8)
OGNL(1)
AS2(2)
Multimedia(0)
Flex AS3(29)
面试(9)
Commet(1)
Ivy(2)
Bat(8)
Maven(18)
CSS(7)
Ext(9)
Spring问题集(4)
Word(1)
JFreeChart(2)
Groovy on Grails(14)
Python(1)
Portlet(3)
amCharts(4)
CSharp.NET(3)
Tools(1)
S2Dao(8)
HSQL(9)
taglib(28)
Source Safe(3)
JSTL(6)
EL(2)
Seasar-SAStruts(3)
Prototype(0)
JQuery(3)
DWR(7)
AJAX(14)
Guice(13)
Digit(2)
Notebook(4)
Log4J(8)
Servlet(2)
JSP(4)
Eclipse(12)
VB.NET(3)
DotNet(3)
JavaScript(63)
Thinking In Soft(10)
Framework(11)
English(0)
Struts2(14)
Struts(38)
Hibernate(10)
Spring(30)
HTML(14)
Web(5)
MYSQL(9)
SQLSERVER(1)
ORACLE(2)
SQL(3)
数据库(0)
DATABASE(0)
Windows(8)
JAVA(67)
Software(1)
Hardware(3)
OpenSource(2)
Microsoft(0)
Excel(4)
DIY(5)
Linux(4)
分类: Java
2008-05-28 08:49:19
remoting-config.xml:<destination id="TestSpring"> <properties> <factory>spring</factory> <source>springTest</source> <!--此处注入IOC注入--> </properties> </destination>==============================================================services-config.xml: <factories> <factory id="spring" class="flex.samples.factories.SpringFactory" /> </factories>==============================================================web.xml: 和struts整合spring一样 <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>============================================================ applicationContext.xml springTest" class="flex.samples.SpringTest"> Hello Flex To Spring SpringFactory.java文件package flex.samples.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;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; } 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; } } }} =============================================SpringTest.java package flex.samples; public class SpringTest { private String description; public String getDescription() { return "This description from String. [" + description + "]"; } public void setDescription(String description) { this.description = description; }}
remoting-config.xml:<destination id="TestSpring"> <properties> <factory>spring</factory> <source>springTest</source> <!--此处注入IOC注入--> </properties> </destination>==============================================================services-config.xml: <factories> <factory id="spring" class="flex.samples.factories.SpringFactory" /> </factories>==============================================================web.xml: 和struts整合spring一样 <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>============================================================ applicationContext.xml springTest" class="flex.samples.SpringTest"> Hello Flex To Spring
remoting-config.xml:<destination id="TestSpring"> <properties> <factory>spring</factory> <source>springTest</source> <!--此处注入IOC注入--> </properties> </destination>==============================================================services-config.xml: <factories> <factory id="spring" class="flex.samples.factories.SpringFactory" /> </factories>==============================================================web.xml: 和struts整合spring一样 <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>
applicationContext.xml
springTest" class="flex.samples.SpringTest"> Hello Flex To Spring
SpringFactory.java文件package flex.samples.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;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; } 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; } } }}
=============================================SpringTest.java
package flex.samples;
public class SpringTest {
private String description;
public String getDescription() { return "This description from String. [" + description + "]"; }
public void setDescription(String description) { this.description = description; }}
Flex.mxml:
TestSpring" />
上一篇:按位截取一个数的小数
下一篇:hsql简介
登录 注册