I made some additional changes to the Spring BlazeDS Integration (RC1) Test Drive:
- The Test Drive now includes an annotation-based configuration sample (the Company Manager sample). Spring annotations such as @Service, @RemotingDestination, @Autowired, @RemotingInclude, and @RemotingExclude make it really easy to configure your beans and make them available through Remoting. As an example, here is the source code for the CompanyDAO class:
package flex.spring.samples.company; import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.sql.DataSource; import org.springframework.flex.remoting.RemotingDestination; import org.springframework.flex.remoting.RemotingExclude; import org.springframework.flex.remoting.RemotingInclude; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.jdbc.core.simple.ParameterizedRowMapper; import org.springframework.jdbc.core.simple.SimpleJdbcInsert; import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; import flex.spring.samples.industry.IIndustryDAO; @Service("companyService") @RemotingDestination(channels={"my-amf"}) public class CompanyDAO implements ICompanyDAO { private final SimpleJdbcTemplate template; private final SimpleJdbcInsert insertCompany; private IIndustryDAO industryDAO; private final ParameterizedRowMapper<Company> rowMapper = new ParameterizedRowMapper<Company>(){ public Company mapRow(ResultSet rs, int rowNum) throws SQLException { Company company = new Company(); company.setId(rs.getInt("id")); company.setName(rs.getString("name")); company.setAddress(rs.getString("address")); company.setCity(rs.getString("city")); company.setState(rs.getString("state")); company.setZip(rs.getString("zip")); company.setPhone(rs.getString("phone")); company.setIndustry(industryDAO.findById(rs.getInt("industry_id"))); return company; } }; @Autowired public CompanyDAO(DataSource dataSource, IIndustryDAO industryDAO) { template = new SimpleJdbcTemplate(dataSource); insertCompany = new SimpleJdbcInsert(dataSource).withTableName("COMPANY").usingGeneratedKeyColumns("ID"); this.industryDAO = industryDAO; } @RemotingInclude public Company findById(int id) { return template.queryForObject("SELECT * FROM company WHERE id=?", rowMapper, id); } @RemotingInclude public List<Company> findAll() { return template.query("SELECT * FROM company ORDER BY name", rowMapper); } @RemotingInclude public List<Company> findByName(String name) { return template.query("SELECT * FROM company WHERE UPPER(name) LIKE ? ORDER BY name", rowMapper, "%" + name.toUpperCase() + "%"); } @RemotingInclude public Company create(Company company) { Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("name", company.getName()); parameters.put("address", company.getAddress()); parameters.put("city", company.getCity()); parameters.put("state", company.getState()); parameters.put("zip", company.getZip()); parameters.put("phone", company.getPhone()); parameters.put("industry_id", company.getIndustry().getId()); Number id = insertCompany.executeAndReturnKey(parameters); company.setId(id.intValue()); return company; } @RemotingInclude public boolean update(Company company) { int count = template.update("UPDATE company SET name=?, address=?, city=?, state=?, zip=?, phone=?, industry_id=? WHERE id=?", company.getName(), company.getAddress(), company.getCity(), company.getState(), company.getZip(), company.getPhone(), company.getIndustry().getId(), company.getId()); return (count == 1); } @RemotingExclude public boolean remove(Company company) { int count = template.update("DELETE FROM company WHERE id=?", company.getId()); return (count == 1); } } - The Test Drive is now using the M3 build of Spring 3 (as opposed to M2 in the previous builds of the Test Drive).
- I modified the configuration of the long polling channel to support more persistent connections per domain based on the browser capabilities.
- And of course compared to the M2 build, this version of the Test Drive includes a number of Messaging samples.
Using the Messaging integration, setting up a destination can be as easy as:
<flex:message-destination id="chat" />
And here is how you configure a destination mapped to a JMS topic:
<flex:jms-message-destination id="jms-chat" jms-destination="chatTopic" />
Installation Instructions:
- Download the Spring / Flex TestDrive here: http://coenraets.org/downloads/spring-flex-testdrive-RC1v2.zip
- Unzip it in your root directory
- Navigate to /spring-flex-testdrive/tomcat/bin and start Tomcat (for instance: catalina run)
- Open a browser and access http://localhost:8080
- Follow the instructions
Amazing. Thank you, Christophe for making my life easier. You’re doing some amazing work! Keep it up!
Hi, the examples work fine but it would be wonderful if you include in the archive the project’s build scripts (ant or maven) beside the source files. I am unable to find on the web an official post about how Java and Flex 3 projects should be build using maven/ant. I’m trying for about a week now to create a deployment script and still didn’t find the best way to do it, especially what maven plugins to use… It would be great to have such an example. Thanks in advance !
Hi,
It is a fantastic work. I would like to know some information related to search box, Currently I think the pop-up list position is like list.move(point.x – 30, point.y + 24);
but if I wanted to reuse this search box in many screens , where the box can be at various position, the pop up appears in different location, instead I always wanted to have it like a drop down. Can you please help on how to fix this.(since I am a java programmer and new to flex, please help, as we are planning to start a new project with spring blazeDS)
Hi Christophe, thank you, great work!
Hi, very nice,
The problem for me, and creating an environment to test. I purchased Flex Builder 3 but I do not understand how to set up for Spring-Hibernate-Mysql
help me.
Tanks.
Claudio Italy
Hi,
I am trying to upgrade my existing HelloWorld Blazeds Integration web application to 1.0.0.RC1 Release. I just annoted my Service class with @Service(“helloWorldService”) ,@RemotingDestination(channels={“my-amf”})
and method with @RemotingInclude.
I removed the bean declaration and flex:remote-service tag from web-application-config.xml. Although flex:message-broker tag still there.
With these changes in place, I am expecting the application to work, but it just deploys successfully. When tried to invoke method from flex client, nothing happens.
Am I missing something? Please help.
Cheers,
Rahul
Thanks for sharing this Christophe !
I’m glad that SpringSource finally released that annotation mechanism, that we had for long in our flex-spring-contrib lib.
cf. http://fna.googlecode.com/svn/trunk/fna/site/flex-contrib-spring/index.html
Would you Christophe if they plan on adding springsecurity/blazeds_channel_security integration annotations as well ?
Hi Christophe,
I would appreciate if you can provide some details regarding “using my-secure-amf”.
Thanks in advance!
Excellent Job!
Particularly on Spring Security and JMS Integrations. Great Updates…
Thanks for sharing Christophe and Jeremy.
Is there official support for Glassfish instead of Tomcat?
Hi Christophe,
Could you also supply a working testdrive that runs on the new Springsource dm server.
Thank you in advance
Christophe,
Excellent work !
Couple of things:
1) it would be very beneficial to everybody if there is a good documentation on these samples, e.g. describing steps to configure it in Tomcat and Flex/FlashBuilder;
2) Spring-to-Flex integration API documentation ?
3) Can you provide Flex4 version of samples? Any limitations/problems to make it work with Flex4 ?
4) Can it work with Spring2.x and earlier versions of BlazeDS & LCDS ?
Thank you,
Oleg.
Christophe,
When are you planning to release 1.0 GA testdrive.
I got latest one from SpringSource and started playing with it.
I have imported 1.0 GA testdrive source code into FlexBuilder3 and trying to run on Tomcat6 which came up with testdrive M2
(on Christophe Coenraets’ site).
I did create another app context (feedstarter1 and traderdesktop1), so it should not interfere with existing M2 ones.
Have not changed anything in the code or testdrive config.
It compiles and shows on the page fine, but as soon as I start a Market Feed, getting exception:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at traderdesktop/messageHandler()[C:\Documents and Settings\Oleg\workspace\TraderDesktop\src\traderdesktop.mxml:95]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.messaging::AbstractConsumer/http://www.adobe.com/2006/flex/mx/internal::messageHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\AbstractConsumer.as:727]
at mx.messaging::ConsumerMessageDispatcher/messageHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\ConsumerMessageDispatcher.as:251]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.messaging::ChannelSet/messageHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1363]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at PollCommandMessageResponder/resultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel.as:746]
at mx.messaging::MessageResponder/result()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\MessageResponder.as:199]
line 95 of
94: var changedStock:Stock = event.message.body as Stock;
95: var stock:Stock = stockMap[changedStock.symbol];
What am I missing ?
Please help !
TIA,
Oleg.
Christophe,
It would be great if you can implement a Flex client from the real JMS like ActiveMQ using JMSadapter, e.g. the same TraderDesktop.
Similar JMS chat with ActiveMQ & BlazeDS:
http://www.agimatec.de/blog/2008/08/extended-blazeds-and-jms-example/
Thank you,
Oleg.
I gort some error for using this update
the Spring BlazeDS Integration Test Drive
Let me download and try again
Thanks
Hi Christophe,
On the Flex side, I see you have commented the streaming-amf channel from any ChannelSet. Is there any reason for this? cause I can’t make a message destination based on this channel to work :/
Longpolling, polling, etc seem to work fine but streaming-amf channel is not working. Im using latest spring-for-blazeds jar, etc.
Any ideas?
Thank you in advance.
A.
Hi, I´m very new to java but I know flex.
Do you know a tutorial to create a new project from scratch in eclipse. like a best practices for new projects ?
Thank you very much !! … test drive is very useful.
thank you man
model ve mankenlik ajansı
fotoğraf çekimleri
program yükle Good admin than you
Christophe,
Thanks for all your hard work. It has not only taught me a LOT, but has helped me tremendously!
Thanks!
– Derrick
version tomcat 6.18???? o not
I couldn’t get it to run.
I’m trying for about a week now to create a deployment script and still didn’t find the best way to do it, especially what maven plugins to use… It would be great to have such an example. Thanks in advance !
Great coding! It’s great that you have included the codes and examples for us readers to follow.
Not Found
The requested URL /downloads/spring-flex-testdrive-RC1v2.zip was not found on this server.
Apache/2.2.21 (Amazon) Server at coenraets.org Port 80
Can someone please upload the file again?
Seems this is the new version: http://www.adobe.com/devnet/flex/articles/spring_blazeds_testdrive.html