Category Archives: Tech Stuff

Flex on Grails: Take 2

A little bit of history

When I first discovered Flex, one of my first obsessions was how to make it work with a Java backend. I’m a java developer at heart and my Java backend stack of choice back then was Spring/Hibernate-based. That’s why I published a series of full-stack articles that became quite popular. But another obsession of mine has always been productivity so when I discovered Grails, it became my new preferred environment and I started looking for ways to plug a Flex frontend into a Grails backend. All of this work culminated in the release of my Grails BlazeDS plugin which worked great but had a few limitations (only Java DTO’s, run-war instead of run-app, etc.). I mean, it worked great… until it didn’t. For some obscure reason, my plugin didn’t work at all with Grails 1.3.x. I fought with this for months, but there were just too many technologies involved (Groovy, Grails, BlazeDS, Spring-Flex, Spring, etc.) and my knowledge of some of those technologies was too shallow to really understand everything happening under the hood. That’s why I called upon SpringSource and/or Adobe to help me or provide the community with a decent Flex support for Grails. And guess what! They listened. A couple of months ago, I got in touch with Burt Beckwith, from SpringSource, who intended to work on that. So he asked me for feedback and really that’s all I did: I explained to him some of the issues I had with the plugin, the typical environment that we Flex developers work with, etc. And today… TADAAAA! The new Flex support plugins are here.

Continue reading Flex on Grails: Take 2

Versioning is Just Too Complex

I’m currently trying to unlearn 10 years of CVCS and Subversion certainties to learn DVCS and Git. And although a lot of people see those as a huge leap forward, I can’t help thinking it’s still way too hard. Versioning is such a basic need, it shouldn’t require that much knowledge. Right now, whether it’s Subversion or Git (or Mercurial, or whatever), the problem is always the same for me: it’s just too low-level. Those systems are designed as if I needed to be a mechanic to drive my car. I don’t care about injectors, gearbox and all that stuff. All I want is to go faster or slower, turn left or right, and that’s about it. Now sure if I’m a mechanic, I can make my car perform much better, but if I just need to get from point A to point B, do you really think I will learn mechanics? Most people won’t. They will just walk there, or ride a bike. And that’s exactly what’s happening in too many companies: “manual versioning”, version numbers in file names, shared drives, even $harepoints, are just poor solutions to a real problem. We need versioning, but existing solutions have an unacceptable learning curve. They’re not smart enough, and they require us to be smart, even though that’s not our main purpose.

Even as a developer, sure I can understand such concepts, but I don’t want to learn what merge, pull, push, commit, branch or update mean. I want to start new projects, participate in existing projects, fix bugs, implement features, refactor my code. Whatever underlying system my company or team is using, whatever technologies I’m working with, my own workflow should not be influenced so much by the tools I use to keep track of my work and collaborate with my team. It should be transparent.

My point is: Git is a leap forward, but it’s a small one, and we need a giant one. We need a versioning system that implements workflows at a higher level, that abstracts away all those silly commands with similar names but different meanings. We need an abstraction layer that can work on top of existing lower-level tools like git, subversion and others, and that can be integrated seamlessly in development environments like IntelliJ Idea or Eclipse (sigh). Sure we will probably lose some power in the process, but we can leave it as an option.

In fact, we need to do with versioning what Maven has done to build lifecycle. Convention over configuration. What are the most common tasks we do on a daily basis:

  • start a new project
  • enter an existing project
  • start fixing a bug
  • start implementing a new feature
  • start refactoring some code
  • switch to another bugfix/feature/refactoring
  • complete a bugfix/feature/refactoring
  • share a bugfix/feature/refactoring with my team or with the world
  • what else?

And then let’s try to map those high-level tasks with lower-level command sequences. And let’s do it in such a way that I can easily change the underlying implementation, or reconfigure certain aspects of it. And why not add the possibility to define your own workflows for other things than traditional dev. In fact, to make things clearer, let’s just call git, subversion and other existing tools “versioning tools”, and let’s design a “collaboration framework”. Exactly like Maven is not a “build tool”, it’s a “build lifecycle framework”.

I’m just ranting out loud here, but what do you think?

Grails/BlazeDS/Flex/iPhone Full Stack Part 2/3

In the previous episode, we built a simple Grails backend for the todolist application. In this installment, we will create a simple Flex 4 front-end for this backend.

The following assumes that you have already installed Flash Builder 4 (formerly known as Flex Builder), either in standalone mode or as an Eclipse plug-in.

Continue reading Grails/BlazeDS/Flex/iPhone Full Stack Part 2/3

Grails/BlazeDS/Flex/iPhone Full Stack Part1/3

A couple of years ago, I published an article on this blog entitled “Flex, Spring and BlazeDS: the full stack!” and this article became very popular. Actually it broke my daily visits record. Today I’m gonna try to break this record again.

In the last couple of years, I’ve worked a lot with Flex and Spring. But in my eternal quest for productivity and user experience, I discovered Grails. Based on the same ideas as Ruby on Rails or Django, it combines a dynamic language – Groovy – with the power of “convention over configuration” to make it possible to create web applications in no time, thus allowing you to spend more time on your user experience.

Of course it’s not the only thing that has changed since then. Flex 4 is now finally out in the open. BlazeDS 4 too. And Flash Builder is finally productive enough for me to use it… in combination with IntelliJ IDEA of course.

All those evolutions in my toolset needed to be integrated, so I ended up building a Grails plugin to do just that: Grails BlazeDS plugin. And since this plugin could not be officially released without a proper demonstration, here we are.

I prepared this tutorial for a BeJUG talk I gave last week. So I want to thank Stephan Janssen and the BeJUG for inviting me… and for staying with me without throwing vegetables at me, given all the failures I had during the live coding session. For those of you who were there: I clearly identified PermGen space as the guilty part responsible for all these blank screens. In fact, since Grails migrated from Jetty to Tomcat as their runtime server, default java memory settings are not enough anymore, so I always configure my projects for that, but of course, in live, I forgot…

Anyway. I’m going to publish this tutorial in three episodes, each one of them being accompanied by its very own screencast on Vimeo (damn Youtube and their 10-minute limit!). But I’ll also publish the tutorial transcript right here for those who want to go faster.

Important note: this tutorial covers the following set of technologies in the specified versions:

In particular, it seems that Grails 1.3 that was just released a couple of days ago breaks Grails BlazeDS plugin. I’ll update both my plugin and this tutorial when I can make them all work together again.

Continue reading Grails/BlazeDS/Flex/iPhone Full Stack Part1/3

Grails BlazeDS 4 Integration Plugin

One of the main goals I’ve been pursuing for a few months is the integration of Grails with Flex 4. I need to rework ConferenceGuide‘s administration backend to make it more ergonomic so that we can cover more events, and ever since I discovered Flex 4 niceties, I couldn’t think of doing that with anything else. The problem is that none of the existing plugins suited my needs. All of them cover Flex 3 only, some of them introduce a lot of complexity for CRUD generation, some of them use GraniteDS instead of BlazeDS, and the simplest plugin, grails-flex has never gone further than the experimental stage. I did a lot of experiments, talked a lot about it on Grails mailing lists, until Tomas Lin kindly explained to me that maybe I was approaching it the wrong way. I wanted a plugin that would set up a complete environment for Flex developement right in the middle of my Grails application. And I wanted that because I wanted to avoid using Flash Builder (you know… Eclipse… ierk!), mainly because the only advantage of Flex Builder 3 over IntelliJ Idea was the visual designer. But he was right, I was wrong. Flash Builder 4 DOES change everything. It does include a lot of very interesting features that greatly improve Flex development productivity, especially when it comes to integration with backend technologies. And for those features, I can only admit that IntelliJ is not up to par yet. I’m still gonna use it for the Grails part, but Flash Builder will be my environment of choice for Flex 4.

So, once I learnt more about Flex 4, BlazeDS 4 and Flash Builder 4 beta 2, it was time to reconsider my approach and develop a much simpler Grails plugin so that any Grails application could be used in combination with Flash Builder. I just released grails-blazeds plugin to do just that. Here is how it works:

  1. Install grails-blazeds plugin: “grails install-plugin blazeds”. This plugin copies a couple of configuration files into your application and imports all of the required libraries, including BlazeDS 4 and Spring-BlazeDS integration 1.5, both in nightly snapshot versions, since they have not been officially released yet
  2. Create a service to be exposed to your Flex application over AMF, or choose an existing one
  3. Add @RemotingDestination annotation to your service class, and @RemotingInclude annotation to all of the methods in this service that you wish to expose
  4. Edit web-app/WEB-INF/flex-servlet.xml (created when you installed the plugin): uncomment the context:component-scan element and set the base-package corresponding to your service class
  5. Make sure your exposed service methods don’t use Groovy classes, either as argument or return types. This is a known limitation I’m still working on, but if there are some Groovy classes here, Flash Builder doesn’t manage to generate ActionScript counterparts.
  6. Run your Grails application using “grails run-war” instead of “grails run-app”. Once again this is a known limitation: Flash Builder BlazeDS data connection plugin relies on a classical web app layout and doesn’t understand Grails dynamic layout (that is until someone manages to create a Grails data connection wizard for Flash Builder 4)
  7. In Flash Builder 4 beta 2, create a new Flex project with a J2EE server. Here are what your parameters shoud look like, “conferenceguide” being the name of my Grails application and “sarbogast” being my home directory:

  8. Click “Data” menu, then “Connect to BlazeDS…”
  9. In the “Authentication required” dialog box that appears, check “no password required” box, and click OK
  10. You should see your service appear, and you can select it and click Finish.

  11. Your service should appear in the Data/Services view. You can then compose your user interface and drag and drop your service methods to the relevant components to connect them with your Grails backend.
  12. Don’t forget to configure a channelset on your service:
    <adminservice:AdminService id="adminService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true">
    <adminservice:channelSet>
    <s:ChannelSet>
    <s:AMFChannel uri="http://localhost:8080/conferenceguide/messagebroker/amf"/>
    </s:ChannelSet>
    </adminservice:channelSet>
    </adminservice:AdminService>
    

And there you go. Special thanks to James Ward, whose screencasts really helped me get it right. Now the only thing that this plugin misses, beyond the 2 known limitations, is integration with Spring Security, but this is just a start.

Enjoy!

Fear, Uncertainty and Doubt

I have hesitated for a long time… a few hours that is. But given my geek reputation (of which I’m still proud by the way), I could just not avoid it: I have to say something about the iPad. Of course I was following the keynote live yesterday with a bunch of geeks in Café Numérique, in Brussels. And of course I was very excited about it. Now instead of writing long sentences about what I like and don’t like about it, I’ll just go over my impressions quickly:

  • I don’t really like the name, but iSlate would have been worst and Macbook Touch was clearly not adapted
  • I love the device itself, and yes I’m gonna get one as soon as it’s released. I’m planning a trip to WWDC in June and hopefully I can bring one back
  • it really is yet another game changer. Apple did with the iPad to the Tablet PC segment what they did with the iPhone to the smartphone segment: bypass the professional market, make it a general public appliance. Brilliant!
  • it will create a whole new market for new applications on the App Store, I can think of a few ones myself
  • I don’t care that it doesn’t have multi-tasking, I’ve never needed it and reactivity is too important for me
  • demonstrations in a couch, what a great communication symbol!
  • I don’t care about the batteries being sealed, so long as it gets me more battery-life
  • I hope there will be an Apple Care on this one
  • Absence of SMS and phone capabilities: it’s not a phone anyway
  • No front camera: who really uses video-conference in the general public anyway? Video-conference in a couch? Come on!
  • The price tag is just awesome. The top one is cheaper than my 3GS
  • I’m so glad I didn’t get a Kindle DX or a Nook as I intended to. By the way, even though e-ink is more comfortable to use, I think the generic aspect of the device and the availability of the iBooks store are going to marginalize specialize eBook readers
  • Stop it with the “giant iPhone” complaint. And laptops are mini-desktops, so what?

Now in parallel to all those impressions, I couldn’t help to see those floating images in my head, of websites with big blank areas and a blue logo, I could even hear those blank areas whisper in my ears: “No Flash support…. ouuuuuuuuhh… No Flash support”. Yes, I know, I’m going nuts. My first thought was “how are you going to explain your daughter that she cannot use the iPad to access her favourite color painting site with her fingers because there’s no Flash?” For such a general public family appliance, it just doesn’t make sense.

But then I started reading blog posts and comments about the announcement, and the frustration turned into anger. Anger against Apple and Adobe who can’t seem to find a common ground on this issue. But more importantly angry against all those self-proclaimed death prophets, all those open standard ayatollahs claiming that they don’t care about Flash since Flash is dead anyway, and Flash is closed and proprietary, and Adobe is all evil, and HTML5 is going to rule the world. And it kind of woke up the Flex developer beast in me, I turned all green, I tore my shirt apart, going all…

FUCK HTML5 !!!

And then I started punching around.

First off, Flash has evolved a lot in the past few years: Flash is not just used for ads anymore. It powers the vast majority of videos on the web, plus a lot of multimedia websites that we love and use everyday (Deezer for example, Google Finance, etc.)

Second, Flash is not completely open, but it is far less closed than what a lot of people know: Tamarin, the Flash virtual machine, the basis of the Flash plugin, has been donated as Open Source to the Mozilla foundation 3 years ago, SWF (Flash file format), AMF (Flash remoting protocol), RTMP (Flash realtime communication protocol) are all open specifications that allow anyone to write their own Flash plugin (with a licence, but still) or generator. Plus Adobe has gone a long way in opening up its tools and processes for the Flash platform as a whole by open sourcing the Flex SDK, creating the Open Screen Project, and I could go on and on. I’ve met some of the openness evangelists inside Adobe and I can tell you that they’re doing a great job opening up what used to be a very protective and old-school company. And it’s just the beginning.

Third: being an open standard is not a f***ing feature for Steve’s sake! If using committee standards means I have to wait for 10 years before any evolution becomes available (how long has W3C been working on HTML5? how long before it is finalized), if it means going back in time on problems we thought had been solved for good (like the video codec hell coming back from the dead), if it means having to spend hours tweaking my web applications so that they look and behave the same in all browsers, then I don’t give a sh*t about open standards. Where is the added value?

Fourth, I can already hear you yell at me about the last argument: “we just can’t let one (evil) company have so much control about a web technology!”. And still that’s exactly what Sun has been doing with another omnipresent web technology: Java. And very few people ever complained about it. And what about Google with Android? The truth is that, from a developer standpoint, having one company orchestrating the evolution of such a huge technology is very good: it guarantees a certain level of consistency, so that we don’t have to deal with compatibility issues between different implementations. It’s also a good point for stability, knowing that you will always have backwards compatibility and professional support on the long term, and that you can invest safely in the technology. And of course it’s excellent for efficiency, because they don’t have to waste time on endless arguments about who’s got the bigger video codec or whatever, so it evolves fast.

So that’s it. I hate HTML, Javascript and CSS, I do it when I have to, but it’s not development, it’s tinkering. And I hate all those people spreading FUD about Flash without knowing what they’re talking about. And I love the Flash platform, and what Adobe is doing with it. I just hope Adobe and Apple will eventually reach an agreement to bring Flash to the iPhone and iPad. And I hope Adobe will do some PR to fix their image because there’s a big problem there.

Just my 2 cents…

Here Comes Grails APNs Plugin

That’s it. I’ve released my first Grails plugin ever. Woooo! Champagne!

If you follow my Twitter feed, you’ve probably noticed that I’ve been playing a lot with Apple Push Notification service lately (APNs for friends). Indeed, ConferenceGuide still requires a data connection, which can be problematic on a lot of events because they’re usually abroad (and roaming fees are waaaaaay too expensive), and even when you do have a data connection, it’s usually pretty slow… at best. That’s probably why one of the most requested features for ConferenceGuide is Offline Mode.

But getting all the data directly from the server does have at least one advantage: you’re always up-to-date. And experience has shown that sh** happens: sometimes sessions are cancelled at the last minute, or a global sound mixer reboots out of nowhere, thus shifting all sessions by 15 minutes. Those of you who were at Devoxx last November know what I’m talking about. So I needed a way to combine the best of both worlds: being able to browse schedule and speaker information without a data connection, and still get updates whenever something changes and I can find a wifi hotspot or something.

The first part of the solution is the local database. The second part involves sending push notifications. The problem with the latter is that the API provided by Apple is pretty low-level and the documentation is rather scarce. And it’s understandable because they expose a service that should be usable by any server technology, whether it is Java, .Net, PHP, Rails, etc. Fortunately, Java has a huge community and a great Open Source spirit, so it wasn’t long before a few projects were created to build an abstraction layer on top of APNs API. The simplest and most documented one I found is java-apns by Mahmood Ali. But ConferenceGuide server is not plain Java. It’s Grails 1.1 (I haven’t taken the risk to migrate to 1.2 yet). So I wanted to ease the integration of java-apns into any Grails application. And voilà! Grails APNs Plugin.

Special thanks to Burt Beckwith for helping me get started, and Mahmood Ali for developing java-apns!