Hello,
I succeeded to integrate "New Spring/BlazeDS Integration Test Drive" tutorial of Christophe Coenraets (http://coenraets.org/blog/2009/01/ne...on-test-drive/) in DM Server environment.
Some modifications have to be performed anyway. I had some problems to load JDBC driver "org.h2.Driver" because of the use of Class.forName (incompatible with OSGi environement to load external bundle class) so I used instead apache DBCP. Here it is the bundle list you must have in /repository/bundles/usr :
Code:
org.springframework.flex-1.0.0.CI-56.jar
com.springsource.flex.messaging.common-3.2.0.3978.jar
com.springsource.flex.messaging-3.2.0.3978.jar
com.springsource.flex.messaging.services.remoting-3.2.0.3978.jar (see discussion above to repair MANIFEST.MF)
com.springsource.flex.messaging.services.http-3.2.0.3978.jar (IDEM)
com.springsource.org.apache.xalan-2.7.0.jar
com.springsource.org.jgroups-2.5.1.jar
com.springsource.org.apache.bcel-5.2.0.jar
com.springsource.org.apache.xerces-2.8.1.jar
com.springsource.org.apache.xmlcommons-1.3.3.jar
com.springsource.org.apache.xml.resolver-1.2.0.jar
com.springsource.org.apache.commons.httpclient-3.1.0.jar
com.springsource.org.apache.commons.codec-1.3.0.jar
com.springsource.edu.emory.mathcs.backport-2.2.0.jar
org.springframework.security-2.0.4.A.jar
com.springsource.org.apache.commons.collections-3.2.0.jar
com.springsource.org.h2-1.0.71.jar
com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar
com.springsource.org.apache.commons.pool-1.4.0.jar
Now : here it is the application context you must have in your web module :
Code:
<?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"
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">
<!-- Maps request paths at /* to the BlazeDS MessageBroker -->
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/*=mySpringManagedMessageBroker
</value>
</property>
</bean>
<!-- Dispatches requests mapped to a MessageBroker -->
<bean class="org.springframework.flex.messaging.servlet.MessageBrokerHandlerAdapter"/>
<!-- Bootstraps and exposes the BlazeDS MessageBroker -->
<bean id="mySpringManagedMessageBroker" class="org.springframework.flex.messaging.MessageBrokerFactoryBean" />
<!-- Implementation of ProductDAO using low-level JDBC -->
<bean id="productDAO" class="flex.spring.samples.product.ProductDAO" >
<constructor-arg ref="dataSource"/>
</bean>
<!-- Expose the productDAO bean for BlazeDS remoting -->
<bean id="product" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
<property name="messageBroker" ref="mySpringManagedMessageBroker"/>
<property name="service" ref="productDAO"/>
</bean>
<!-- Implementation of ContactDAO using Spring's JdbcTemplate -->
<bean id="contactDAO" class="flex.spring.samples.contact.ContactDAO" >
<constructor-arg ref="dataSource"/>
</bean>
<!-- Expose the contactDAO bean for BlazeDS remoting -->
<bean id="contact" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
<property name="messageBroker" ref="mySpringManagedMessageBroker"/>
<property name="service" ref="contactDAO"/>
</bean>
<!-- Implementation of CompanyDAO using Spring's JdbcTemplate -->
<bean id="companyDAO" class="flex.spring.samples.company.CompanyDAO" >
<constructor-arg ref="dataSource"/>
<constructor-arg ref="industryDAO"/>
</bean>
<!-- Expose the companyDAO bean for BlazeDS remoting -->
<bean id="company" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
<property name="messageBroker" ref="mySpringManagedMessageBroker"/>
<property name="service" ref="companyDAO"/>
</bean>
<!-- Implementation of IndustryDAO using Spring's JdbcTemplate -->
<bean id="industryDAO" class="flex.spring.samples.industry.IndustryDAO" >
<constructor-arg ref="dataSource"/>
</bean>
<!-- Expose the IndustryDAO bean for BlazeDS remoting -->
<bean id="industry" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
<property name="messageBroker" ref="mySpringManagedMessageBroker"/>
<property name="service" ref="industryDAO"/>
</bean>
<!-- Create and populate the tables if the springflexdemodb database -->
<bean id="dbInit" class="flex.spring.samples.util.DatabaseInitializer">
<constructor-arg ref="dataSource"/>
</bean>
<!-- Simple Spring-managed DataSource for embedded h2 database (http://www.h2database.com). H2 is used instead of HSQLDB in this Test Drive
because it has better support for retrieving autogenerated keys using the JDBC 3 approach which is used by Spring's JdbcTemplate.
The "jdbc:h2:~/sprinflexdemodb/sprinflexdemodb" URL points to a springflexdemodb database in the springdemodb directory
under the user's directory (represented by ~). H2 creates the database automatically if it doesn't exists, in which case, the dbInit bean
takes care of creating and populating the sample tables.
-->
<!-- Not OSGi compliant
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.h2.Driver" />
<property name="url" value="jdbc:h2:~/sprinflexdemodb/sprinflexdemodbmic" />
</bean>
-->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
p:driverClassName="org.h2.Driver" p:url="jdbc:h2:~/sprinflexdemodb/sprinflexdemodb"/>
</beans>
The manifest to use :
Code:
Manifest-Version: 1.0
Bundle-Version: 1.0.0
Bundle-Name: Webskin Flex Bundle
Bundle-ManifestVersion: 2
Bundle-SymbolicName: fr.webskin.maquette.web.flex
Module-Type: Web
Import-Library: org.springframework.spring;version="[2.5.6.A,2.5.6.A]"
Web-ContextPath: coenraets <-- choose what you want but don't forget to fullfill the same string in your flex project context root
Web-DispatcherServletUrlPatterns: /spring/*
Import-Bundle: org.springframework.flex;version="[1.0.0.CI-56,1.0.0.CI-56]",
com.springsource.flex.messaging;version="[3.2.0.3978,3.2.0.3978]",
com.springsource.flex.messaging.common;version="[3.2.0.3978,3.2.0.3978]",
com.springsource.flex.messaging.services.http;version="[3.2.0.3978,3.2.0.3978]",
com.springsource.flex.messaging.services.remoting;version="[3.2.0.3978,3.2.0.3978]",
com.springsource.org.apache.commons.dbcp;version="[1.2.2.osgi,1.2.2.osgi]",
com.springsource.org.h2;version="[1.0.71,1.0.71]"
Import-Package: javax.sql
Here, the procedure proposed by Christophe Coenraets (and modified by me) to simply test Christophe Coenraets samples :
Code:
Opening the Samples Source Code in Flex Builder 3
Create a Flex Builder project for each sample application you are interested in.
There are several approaches to create a Flex Builder project for a Flex application that works with BlazeDS. We describe a simple approach here:
- Select File>New>Project... in the Flex Builder menu.
- Expand Flex Builder, select Flex Project and click Next.
- Provide a project name. Use the exact name of the sample folder. For example spring-blazeds-101.
- Specify C:\spring-blazeds-testdrive\projects\flex as the Project location.
- Select Web Application as the application type.
- Select J2EE as the application server type.
- Check use remote object access service.
- Uncheck Create combined Java/Flex project using WTP.
- Click Next.
- Make sure the root folder for LiveCycle Data Services matches the root folder of your BlazeDS web application. If you are using the Tomcat integrated server on Windows, the settings should look similar to this (you may need to adjust the exact folder based on your own settings):
Root Folder: C:\workspaceDMServer\coenraets.web.module\src\main\resources\MODULE-INF or directly in DM server work directory D:\springsource-dm-server-1.0.1.RELEASE\work\com.springsource.server.deployer\Module\coenraets.web.module.jar-0\coenraets.web.module.jar\MODULE-INF
Root URL: http://localhost:8080
Context Root: /coenraets/ (as said before choose the context you want)
- Click Validate Configuration, then Finish.
Enjoy yourself.
Mickaël.