2. Spring Configuration

Setting up the Spring BlazeDS Integration configuration is very simple. The flex:message-broker initializes BlazeDS and it's configuration files, which by default are expected in '/WEB-INF/flex' and for the main configuration to be called 'services-config.xml'. Two services are loaded, 'personDao' and 'personService'. It's not best practice to expose the DAO directly as a service, but for this example it was done to illustrate exposing a remoting service using annotations and the custom namespace. One from the context:component-scan and the other is exposed using the Spring BlazeDS Integration custom namespace. The PersonService exposed through scanning will be shown later in the Code Example section, and the JPA Person DAO is exposed using flex:remoting-destination. It's created just by referencing the Person DAO. To have a remoting destination name other than the bean name the destination-id could specify something different.

/WEB-INF/flex-servlet-context.xml
                
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:flex="http://www.springframework.org/schema/flex"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/flex
                           http://www.springframework.org/schema/flex/spring-flex-1.0.xsd">

    <context:component-scan base-package="org.springbyexample.web.service" />

    <flex:message-broker/>  1

    <flex:remoting-destination ref="personDao" /> 2

</beans>
                
            
1 Spring BlazeDS Integration configuration of the BlazeDS message broker, which handles remoting and messaging requests.
2 Exposes the personDao bean as a BlazeDS remoting destination.