1) Step for adding Spring in your web application
(This step only applies if you have not already installed spring in your web
application).
a) Download the spring.jar file from www.springframework.org file into your
WEB-INF/lib of your web application.
b) Add the spring context param and listener to your web.xml file:
contextConfigLocation/WEB-INF/applicationContext.xmlorg.springframework.web.context.ContextLoaderListener
2) Register the spring factory with FDS
a) Compile the enclosed SpringFactory.java in the src folder.
Its full class name is flex.samples.factories.SpringFactory.
b) Add the following configuration to your WEB-INF/flex/services-config.xml file:
3) Define your components in spring's XML file. Given the above spring
configuration, they would be placed in WEB-INF/applicationContext.xml. This
file can contain components which are intended to be exposed to flex clients as
remote objects as well as classes to be used as Flex Data Management Services
(FDMS) assembler implementations using the Java adapter.
Just as with all FDMS destinations that use the Java adapter, if your class is
intended to be used with FDMS, it either should implement the the
flex.data.assembler.Assembler interface or it should have fill, get,
and sync methods which are suitable to be configured via the
fill-method, get-method, and sync-method tags in the FDMS configuration.
To be constructed by Spring, your component should have a zero argument constructor so
Spring can construct an instance. Your applicationContext.xml file might look like:
4) Add your flex destination configuration for the components you want to expose to
flex clients. Since these components use the spring factory we define, we add the
additional tag spring and the attribute is used to refer
to the spring component's bean name, not the class name as with the default factory.
a) For Remote object destinations you place your destinations inside of the
tag which refers to the flex.messaging.services.RemotingService,
(by convention this may be in WEB-INF/flex/remoting-config.xml). For example, your
remote destination configuration might look like:
springweatherBean
b) For FDMS destinations that use the Java adapter, you add your destinations
to the service tag which refers to flex.data.DataService
(which by convention may be in WEB-INF/flex/data-management-config.xml). Make
sure you use the Java adapter for your destination. An example FDMS destination
might look like:
...
...
myAssemblerspring
...
See the FDMS documentation for more details on configuring FDMS destinations
which use the Java adapter.