Labelx="109"y="82"text="name:
"/>
Labeltext="{say.sayHelloTo.lastResult}"x="44"y="162"width="448"height="71"id="lblView"color="#FCEE09"fontSize="20"fontWeight="bold"textDecoration="underline"fontStyle="normal"/>
Application>
5.)启动tomcat,等tomcat启动好后,右键单击HCS.mxml,选中RunAs—>Web应用程序,效果如下
到了这一步,flex+bleazeds已经完成
14.添加Spring框架,在MyEclipseJavaEnterprise视图下的步骤如下:
点击HCS工程—>MyEclipse—>AddSpringCapabilities
点击Next
点击Finish
点击KeepExisting
15.添加mon,添加SpringFactory.java(网上的)
packagemon;
importorg.springframework.context.ApplicationContext;
importorg.springframework.web.context.support.WebApplicationContextUtils;
importorg.springframework.beans.BeansException;
importorg.springframework.beans.factory.NoSuchBeanDefinitionException;
importflex.messaging.FactoryInstance;
importflex.messaging.FlexFactory;
importflex.messaging.config.ConfigMap;
importflex.messaging.services.ServiceException;
/**
*Thisinterfaceisimplementedbyfactorycomponentswhichprovide
*instancestotheflexmessagingframework.Toconfigureflexdataservices
*tousethisfactory,addthefollowinglinestoyourservices-config.xml
*file(locatedintheWEB-INF/flexdirectoryofyourwebapplication).
*
*<factories>
*<factoryid="spring"class="flex.samples.factories.SpringFactory"/>
*</factories>
*
*Youalsomustconfigurethewebapplicationtousespringandmustcopythespring.jar
*fileintoyourWEB-INF/libdirectory.Toconfigureyourappservertousespring,
*youaddthefollowinglinestoyourWEB-INF/web.xmlfile:
*
*<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>
*
*ThenyouputyourspringbeanconfigurationinWEB-INF/applicationContext.xml(asperthe
*lineabove).Forexample:
*
*<?
xmlversion="1.0"encoding="UTF-8"?
>
*<!
DOCTYPEbeansPUBLIC"-//SPRING//DTDBEAN//EN""http:
//www.springframework.org/dtd/spring-beans.dtd">
*
*<beans>
*<beanname="weatherBean"class="dev.weather.WeatherService"singleton="true"/>
*</beans>
*
*Nowyouarereadytodefineadestinationinflexthatmapstothisexistingservice.
*Todothisyou'daddthistoyourWEB-INF/flex/remoting-config.xml:
*
*<destinationid="WeatherService">
*<properties>
*<factory>spring</factory>
*<source>weatherBean</source>
*</properties>
*</destination>
*
*@authorJeffVroom
*/
publicclassSpringFactoryimplementsFlexFactory
{
privatestaticfinalStringSOURCE="source";
/**
*Thismethodcanbeusedtoinitializethefactoryitself.Itiscalledwithconfiguration
*parametersfromthefactorytagwhichdefinestheidofthefactory.
*/
publicvoidinitialize(Stringid,ConfigMapconfigMap){}
/**
*Thismethodiscalledwhenweinitializethedefinitionofaninstance
*whichwillbelookedupbythisfactory.Itshouldvalidatethat
*thepropertiessuppliedarevalidtodefineaninstance.
*Anyvalidpropertiesusedforthisconfigurationmustbeaccessedto
*avoidwarningsaboutunusedconfigurationelements.Ifyourfactory
*isonlyusedforapplicationscopedcomponents,thismethodcansimply
*returnafactoryinstancewhichdelegatesthecreationofthecomponent
*totheFactoryInstance'slookupmethod.
*/
publicFactoryInstancecreateFactoryInstance(Stringid,ConfigMapproperties)
{
SpringFactoryInstanceinstance=newSpringFactoryInstance(this,id,properties);
instance.setSource(properties.getPropertyAsString(SOURCE,instance.getId()));
returninstance;
}//endmethodcreateFactoryInstance()
/**
*Returnstheinstancespecifiedbythesource
*andpropertiesarguments.Forthefactory,thismaymean
*constructinganewinstance,optionallyregisteringitinsomeother
*namespacesuchasthesessionorJNDI,andthenreturningit
*oritmaymeancreatinganewinstanceandreturningit.
*Thismethodiscalledforeachrequesttooperateonthe
*givenitembythesystemsoitshouldberelativelyefficient.
*
*Ifyourfactorydoesnotsupportthescopeproperty,it
*reportanerrorifscopeissuppliedintheproperties
*forthisinstance.
*/
publicObjectlookup(FactoryInstanceinst)
{
SpringFactoryInstancefactoryInstance=(SpringFactoryInstance)inst;
returnfactoryInstance.lookup();
}
staticclassSpringFactoryInstanceextendsFactoryInstance
{
SpringFactoryInstance(SpringFactoryfactory,Stringid,ConfigMapproperties)
{
super(factory,id,properties);
}
publicStringtoString()
{
return"SpringFactoryinstanceforid="+getId()+"source="+getSource()+"scope="+getScope();
}
publicObjectlookup()
{
ApplicationContextappContext=WebApplicationContextUtils.getWebApplicationContext(flex.messaging.FlexContext.getServletConfig().getServletContext());
StringbeanName=getSource();
try
{
returnappContext.getBean(beanName);
}
catch(NoSuchBeanDefinitionExceptionnexc)
{
ServiceExceptione=newServiceException();
Stringmsg="Springservicenamed'"+beanName+"'doesnotexist.";
e.setMessage(msg);
e.setRootCause(nexc);
e.setDetails(msg);
e.setCode("Server.Processing");
throwe;
}
catch(BeansExceptionbexc)
{
ServiceExceptione=newServiceException();
Stringmsg="UnabletocreateSpringservicenamed'"+beanName+"'";
e.setMessage(msg);
e.setRootCause(bexc);
e.setDetails(msg);
e.setCode("Server.Processing");
throwe;
}
}
}
}
16.在WEB-INF/flex中的services-config.xml中注册SpringFactory工厂
17.在WEB-INF文件夹下建立conf文件夹,将applicationContext.xml移入此中,在WEB-INF/web.xml中加入对spring的支持
--Spring配置-->
--Backendconfiguration-->
contextConfigLocation
/WEB-INF/conf/*/spring-*.xml,
/WEB-INF/conf/applicationContext.xml
SpringContextServlet
org.springframework.web.context.ContextLoaderServlet
1
Sprin