Spring Framework

To use Spring objects with Flex BlazeDS the Spring factory can be registered in BlazeDS. Spring beans can be referenced as remote services objects in BlazeDS.

A better way is to manage the Spring beans in a Spring way. Therefor the BlazeDS messagebroker is configured as a Spring bean and Flex messenges are routed to Spring.

Security

There are several ways to integrate Spring Security with the BlazeDS Security process. How this can be done is out of scope here but remains to be solved when building a solid J2EE application.

Person case - Configuration 1

Spring is used to manage the actual configuration of the Flex services for BlazeDS. Configuration in BlazeDS itself can be reduced to a minimum.

There are three steps to realize this. First all Flex calls must be routed via Spring. Secondly Spring must be connected to BlazeDS. Lastly Spring must manage all remote services for BlazeDS.

The routing of Flex calls via Spring is solved in the web.xml. A servlet is defined to do this. When Spring is also used for other purpose it is wise to seperate BlazeDS definitions from the 'normal' Spring application context.

The web.xml may look like this.


<?xml version="1.0" encoding="UTF-8"?>
<web-app id="BlazeDS_Application" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                             http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>BlazeDS</display-name>
	<description>BlazeDS Application</description>

	<listener>
		<listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
	</listener>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/config/web-application-config2.xml</param-value>
	</context-param>

	<filter>
		<filter-name>encoding-filter</filter-name>
		<filter-class>
            org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
	</filter>

	<filter-mapping>
		<filter-name>encoding-filter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<!-- MessageBroker Servlet -->
	<servlet>
		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>/WEB-INF/config/flex-application-config.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<!-- Map all *.spring requests to the DispatcherServlet for handling -->
	<servlet-mapping>
		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
		<url-pattern>/spring/*</url-pattern>
	</servlet-mapping>

	<welcome-file-list>
		<welcome-file>index.htm</welcome-file>
	</welcome-file-list>
</web-app>