When I first started this project, the easiest way to get it going was to make a WTP combined project, that's where Eclipse has the Java backend source and the Flex client source in the same project and it handles deployment and such for you. That worked great, to a point.
Recently, I noticed the builds getting slower and slower. I did lots of experimentation to try to get the speeds back up, but nothing was having much impact. Even moving my embedded images to another project library/SWC didn't really affect anything that much.
Then, I noticed another fun thing - once your server and your Flex client code get to a certain size, they each take a little while to compile (Flex MUCH more so than Java, sadly).. So I'd do something like this:
- Adjust Java server code slightly
- Run client
- Client would require a workspace rebuild, in my case taking up to a couple minutes. (SLOW!)
- Then it would finally launch, when all it needed to do was re-deploy the changed Java.
There was also the wonderful side effect that when you hit "launch" to launch the client, it would rebuild the workspace most of the time, then deploy it, and then launch it, but it wouldn't give the app server enough time to get it deployed and so the initial page load would fail (since the SWF wasn't fully there yet). Sometimes it would fail with really interesting error messages. What this boiled down to was pressing the refresh button the second the browser came to the front, since I knew it wasn't going to work otherwise. If I was forgetful and hit "debug" instead of just launch, this also meant launching the debug session again, since refreshing the browser breaks the debug connection. Pain.
So, I finally bit the bullet and seperated the projects. While I was at it I restructured my SVN repo to be more sane, since I expect this code base to be around for a long time.
I'll tell you the truth, it was kind of painful separating them. A couple months ago my Java know-how would have been insufficient. It's all stupid little stuff, but it is until you figure out how to fix it.
The thing that might be a problem for you that took me a bit to figure out - the Flex client and the Java server both need access to Flex's services-config.xml in WEB-INF, but you don't want to put the client in the same directory structure as the server, since when Eclipse deploys the server there it likes to wipe that directory out.
What I did was use Vista's symbolic link feature (Unix and OSX both have this, but it's fairly new in Windows. XP has something equivalent, but I can't remember if it's this easy). This just let me link from the Java deploy directory (the Java project owns the flex config files, oddly) to the Flex deploy directory.
Then, after adjusting the server settings for the Flex project, it should all work.
When all was said and done, the two projects are now separated and living in their own Eclipse workspaces and being used with seperate Eclipse installs (I also had FlexBuilder/Eclipse 3.4 reliability issues, but that's another story) - and now BOTH sides are down to few second compile times. It's amazing.
In short, WTP combined Flex/Java projects - BAD.
0 comments:
Post a Comment