Introduction to Spring blazeds integration

Source: Internet
Author: User
Tags config http request advantage

At the end of last year, Adobe and Spring announced jointly to develop a new project: Spring blazeds integration. The goal: Developers can use the spring development model to create RIA through Adobe Flex, BlazeDS, spring, and Java technologies. This allows us to expose spring-managed services through BlazeDS without additional configuration files. The advantage is to integrate spring's ease of use with Flex, BlazeDS, and Java to create applications together.

I'll explain in this article how the Spring BlazeDS integration project has changed the way traditional development works, as well as showing some relevant examples. First, let's look at how it changes the way applications are integrated and how to transform existing spring projects so that they can take advantage of new integrations. Finally, I will introduce the other features and advantages of the project appropriately.

Developing RIA in spring mode

Spring's emergence completely subverts the traditional Java server development approach. It encourages the assembly of Pojo by means of a dependency injection, which greatly simplifies the development and testing of applications.

The core configuration of spring is implemented through Java beans. With the help of beans, any Java class can be exposed as a service. For example, the following configuration fragment declares the soda service as a spring bean:

<!-- Implementation of soda bean-->
<bean id="sodaBean" class="com.gorillalogic.sodaBank.SodaService" init-method="initSodaAccounts">
  <property name="numAccounts" value="1000"/>
</bean>

In order to expose these beans to the remote services used by flex clients, the integration project uses spring Web MVC. Spring Web MVC uses Dispatcherservlet as a central distributor to handle any type of HTTP request or HTTP based remote service. We can configure the Dispatcherservlet with the same JavaBean configuration to forward the request to the appropriate processor for subsequent processing.

Before, the BlazeDS project routes the request to the corresponding BlazeDS message Broker through Messagebrokerservlet. Now with the help of Spring blazeds,spring Web MVC Dispatcherservlet has replaced Messagebrokerservlet, Next you need to configure Dispatcherservlet to transfer the request to Messagebrokerhandleradapter. The adapter itself is a spring factory bean that creates a local blazeds message broker instance in the Spring Web application context, and then exposes the spring bean as a remote service, after which the flex client can invoke the service directly.

This configuration of BlazeDS message broker can be more tightly integrated with the spring project, while also reducing the amount of configuration required to expose the spring bean to a remote service. For example, we need to declare a separate entry in Messaging.xml to expose the Java service, but it is now easy to expose the remote bean in that configuration file that declares the spring bean.

The Spring blazeds integration also uses some standard blazeds XML configuration files to configure the messaging infrastructure. This includes some of the contents of the channel definition.

The next release of the project will add integration with spring security. The initial implementation protects the BlazeDS endpoint with a pointcut advisor. Pointcut Advisor is part of Spring AOP support.

Create a new spring BlazeDS integration project-server-side

Whether it's creating new projects or adding support for existing projects, the steps are similar. The first step is to add the required jar files to the library directory. Can be downloaded from the spring source site (Http://www.springsource.org/spring-flex), or you can use the library in the sample project.

For this example, we intend to modify a simple soda service project into a spring blazeds project. First, you modify the Web.xml file. Delete all references to BlazeDS Messagebrokerservlet in the file, and then add a reference to spring Dispatcherservlet:

<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/web-application-config.xml</param-value>
  </init-param>
  <load-on-startup>1</load-on-startup>
</servlet>

   <servlet-mapping>
     <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
     <url-pattern>/gorilla/*</url-pattern>
   </servlet-mapping>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.