博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Spring Flex
阅读量:5076 次
发布时间:2019-06-12

本文共 2479 字,大约阅读时间需要 8 分钟。

  1. package springFactory;
  2. import org.springframework.context.ApplicationContext;
  3. import org.springframework.web.context.support.WebApplicationContextUtils;
  4. import org.springframework.beans.BeansException;
  5. import org.springframework.beans.factory.NoSuchBeanDefinitionException;
  6. import flex.messaging.FactoryInstance;
  7. import flex.messaging.FlexFactory;
  8. import flex.messaging.config.ConfigMap;
  9. import flex.messaging.services.ServiceException;
  10. publicclass SpringFactory implements FlexFactory
  11. {
  12. privatestaticfinal String SOURCE = "source";
  13. publicvoid initialize(String id, ConfigMap configMap) {}
  14. public FactoryInstance createFactoryInstance(String id, ConfigMap properties)
  15. {
  16. SpringFactoryInstance instance = new SpringFactoryInstance(this, id, properties);
  17. instance.setSource(properties.getPropertyAsString(SOURCE, instance.getId()));
  18. return instance;
  19. } // end method createFactoryInstance()
  20. public Object lookup(FactoryInstance inst)
  21. {
  22. SpringFactoryInstance factoryInstance = (SpringFactoryInstance) inst;
  23. return factoryInstance.lookup();
  24. }
  25. staticclass SpringFactoryInstance extends FactoryInstance
  26. {
  27. SpringFactoryInstance(SpringFactory factory, String id, ConfigMap properties)
  28. {
  29. super(factory, id, properties);
  30. }
  31. public String toString()
  32. {
  33. return"SpringFactory instance for id=" + getId() + " source=" + getSource() + " scope=" + getScope();
  34. }
  35. public Object lookup()
  36. {
  37. ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());
  38. String beanName = getSource();
  39. try
  40. {
  41. return appContext.getBean(beanName);
  42. }
  43. catch (NoSuchBeanDefinitionException nexc)
  44. {
  45. ServiceException e = new ServiceException();
  46. String msg = "Spring service named '" + beanName + "' does not exist.";
  47. e.setMessage(msg);
  48. e.setRootCause(nexc);
  49. e.setDetails(msg);
  50. e.setCode("Server.Processing");
  51. throw e;
  52. }
  53. catch (BeansException bexc)
  54. {
  55. ServiceException e = new ServiceException();
  56. String msg = "Unable to create Spring service named '" + beanName + "' ";
  57. e.setMessage(msg);
  58. e.setRootCause(bexc);
  59. e.setDetails(msg);
  60. e.setCode("Server.Processing");
  61. throw e;
  62. }
  63. }
  64. }
  65. }

services-config.xml

<services-config>

<factories>   

<factory id="spring" class="com.dys.flex.SpringFactory" />

</factories>

</services-config> remoting-config.xml <destination id="LoginService">  

<properties>   

<factory>spring</factory>   

<source>loginService</source>  

</properties>

</destination>

转载于:https://www.cnblogs.com/dingyingsi/archive/2013/02/26/2933608.html

你可能感兴趣的文章
[转]IOS UIView 之属性篇
查看>>
日志 制作--和查看
查看>>
redis 操作指令
查看>>
js中的this(二)
查看>>
Linux的NFS配置
查看>>
Codeforces 652F Ants on a Circle
查看>>
bzoj 1483 链表 + 启发式合并
查看>>
struts2完成增删改查
查看>>
Servlet(1)
查看>>
mysql高级:触发器、事务、存储过程、调用存储过程
查看>>
multitask learning 相关论文资源
查看>>
对X86汇编的理解与入门
查看>>
看破欧拉函数的奥秘
查看>>
LeetCode-Closest Binary Search Tree Value II
查看>>
cdh 的 oozie时间校准
查看>>
Work 3(工作类) (2017.07.01)
查看>>
PostgreSQL学习手册(五) 函数和操作符
查看>>
观察者模式的初始学习--自己实现
查看>>
[LeetCode] The Skyline Problem
查看>>
Servlet 的生命周期及工作原理
查看>>