Flex跟spring集成时需要的SpringFactory

Flex和spring集成时需要的SpringFactory}public Object lookup(){ApplicationContext appContext WebApp

Flex和spring集成时需要的SpringFactory

  1. }
  2. public Object lookup() {
  3. ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext()); String beanName = getSource();
  4. try
  5. { return appContext.getBean(beanName);
  6. } catch (NoSuchBeanDefinitionException nexc)
  7. { ServiceException e = new ServiceException();
  8. String msg = "Spring service named '" + beanName + "' does not exist."; e.setMessage(msg);
  9. e.setRootCause(nexc); e.setDetails(msg);
  10. e.setCode("Server.Processing"); throw e;
  11. } catch (BeansException bexc)
  12. { ServiceException e = new ServiceException();
  13. String msg = "Unable to create Spring service named '" + beanName + "' "; e.setMessage(msg);
  14. e.setRootCause(bexc); e.setDetails(msg);
  15. e.setCode("Server.Processing"); throw e;
  16. } }
  17. }
  18. }