FLEX BlazeDS+Spring+Hibernate 配置成功(结合自己公司框架)
}
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;
}
}
}
}
=========================================================================================
3.services-config.xml:
<factories>
<factory id="spring" />
</factories>
=========================================================================================
4.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;
}
}
======================================================================================5.applicationContext.xml
<bean id="springTest" destination="TestSpring" />
<mx:Button x="25" y="80" label="Call Spring" width="100" click="myspring.getDescription();" />
<mx:Label x="25" y="100" width="334" text="{myspring.getDescription.lastResult}"/>