I have developed a plugin for the Eclipse Web Tools Platforms (WTP). The plugin provides a project facet, which is used to add Flex Data Services (FDS) functionality to a dynamic web project.
What is the Eclipse Web Tools Platform?
The Eclipse Web Tools Platform is an open source project that provides an “extensible development platform and application frameworks for building software”. The Eclipse WTP is a top-level project that “extends the Eclipse platform with tools for developing J2EE web applications”. The WTP project contains two subprojects:
- Web Standards Tools (WST) – the WST subproject aims to “provide common infrastructure to any Eclipse-based development environment targeting Web-enabled applications”.
- J2EE Standard Tools (JST) – the JST subproject aims to “provide a basic Eclipse plug-in for developing applications based on J2EE 1.4 targeting J2EE-compliant application servers, as well as a generic J2EE tooling infrastructure for other Eclipse-based development products.”.
Why the Eclipse Web Tools Platform?
To-date within Adobe Consulting EMEA we have delivered all our Flex 2 FDS projects on the Eclipse WTP for the following reasons:
- Java Support – Flex Builder doesn’t add the Java nature to an FDS project therefore you have no support for Java development within the web module.
- Version Control – Flex Builder creates an FDS project in-place on an external application server, as a result the web module assets are not part of the project under Eclipse and hence not subject to version control, especially if you are using the Eclipse team support. I believe you should always version control your web module e.g. all the files within flex.war. Within an enterprise it is highly likely that you will be running multiple FDS projects on different versions of Flex. When a developer or a deployer checks out a project they should receive the complete application. In addition, if you label or branch the codebase you should tag all files related to that version e.g. source files, library files, configuration files, deployment descriptors, API-implementations otherwise it becomes difficult to re-constitute the application at that version.
- J2EE Support – if you are developing an enterprise application it is unlikely to contain just Flex and FDS artificats, for example business logic could be encapsulated in EJBs running in the mid-tier.
- Debugging – within the Eclipse environment you are able to configure end-to-end debugging that allows you to step-through your Flex RIA-code and your server-side code (e.g. RPC services, EJBs, etc.).
From a runtime perspective FDS fits within the J2EE architecture, however from a development perspective within the IDE it doesn’t fit in to the J2EE development model. Eclipse provides an excellent Java development environment, which is extended by the WTP to aid the development of J2EE web applications. The WTP tooling understands the structure of a web module and an EJB JAR and how they combine to form an Enterprise application (EAR). With this in mind FDS is simply a unit of functionality within a web module, which is the concept of a project facet. A project facet allows you to add units of functionality to a web module, other examples include XDoclet and indeed Java support.
How to install the FDS Plugin
The plugin has been developed against Eclipse 3.1.2 + WTP 1.0.2 + Flex Builder 2. I downloaded the all-in-one WTP + Eclipse and then installed the Flex Builder plugins.
The plugin is developed against Java 5, so you will need the Java 5 JRE installed. I normally put a shortcut to the eclipse.exe on my desktop and edit the properties as follows:
C:\apps\adobe\flex2.0\wtp1.0.3\eclipse.exe -vm “C:\apps\java\jre1.5.0_06\bin\javaw.exe”
Remember to replace “C:\apps\java\jre1.5.0_06\bin\javaw.exe” with the path to “javaw.exe” on your PC.
The plugin is distributed using an Eclipse update site. To install the plugin start Eclipse and open Help > Software Updates > Find and Install. Create a new remote site with the following URL:
Note: The update site is currently on the iteration::two web site as there are file size restrictions on the Adobe blog server. I hope to get it moved to a more permanent home in the near future.
You can also download the plugin from the Flex Exchange.
How to create an FDS aware Web project
You can create an FDS enabled web project one of two ways:
- Open File > New > Project and select Web > Dynamic Web Project. Follow the wizard and select the Flex Data Services facet.
- Open File > New > Project and select Flex Data Services > Flex Data Services Web Project.
You can of course add or remove a project facet at a later date using the project properties.
Hello World Example
The WTP platform comes with a number of server adapters, for example Tomcat. As yet there is currently no adapter for JRun. The compulsory "Hello World" example shows how to create an FDS Web project running on Tomcat.
- Download and install Tomcat 5.5.
- Start Eclipse.
- Create an FDS project called HelloWorld.
- The FDS project facet creates a default application (Main.mxml) under the content directory (WebContent) by default.
- Open Main.mxml and add the following: <mx:Label text="Hello World" />
- Open the Servers view, Window > Show View > Other > Server > Servers.
- In the Servers view right-click and select New > Server.
- Select Apache > Tomcat v5.5 Server.
- On the next page configure the Tomcat installation directory and the JRE.
- On the last page add the HelloWorld application.
- Start your Tomcat server, right-click > Start.
- Open the Run > Run….
- Select Flex Application and click New.
- Configure the application as follows, you will need to override the URL defaults:
- Click Run.
You could also right-click Main.mxml and select Run As > Flex Application, however you would need to edit the configuration to manually configure the URLs as Flex Builder won’t resolve them correctly.
You can now use that same run configuration to debug your application, just click the debug icon on your main toolbar. You can also start the server in debug mode and set breakpoints in your Java code. You can control your embedded server (e.g. start, stop, debug, etc.) by using the icons on the Servers view .
The source code is included in the plugin (com.adobe.flex.enterprise.ui).