Your first step, of course, is to download the Eclipse IDE for Java EE Developers. After you get the package from the nearest Eclipse mirror, you need to install it - simply unzip it somewhere on your hard drive. Starting the IDE brings you to the Java EE perspective.
You need to update your Eclipse installation with the OpenEJB server adapter. Just go to Help > Software Updates... to show the new P2 update manager. Then switch to the Available Software tab and click on the Add Site... button. Add the location of the OpenEJB's update site:
http://people.apache.org/~jgallimore/update-site/
Wait a little bit for P2 to refresh from the new update site and select the Apache OpenEJB Eclipse Feature to install.
Now you have to overcome the temptation to click on the default Close button and to look above to the top of the dialog to find the Install... button. After clicking on it, replying blindly to some dialogs and restarting the IDE, you will have the OpenEJB Eclipse plug-in installed.
You may find this way of installing the OpenEJB server adapter a little bit odd and you would be totally right. Server adapters are typically downloaded and installed from the Server Runtime Environments preference page. We look forward to the OpenEJB team to move the server adapter's code in a separate feature.
The next steps is to download the OpenEJB runtime implementation. Go to the OpenEJB Standalone Server category and choose the appropriate package for your operating system: zip for Windows, tar.gz for Linux and MacOS. You install OpenEJB by simply unzipping it somewhere on your hard drive.
You are ready to configure the OpenEJB runtime in the Eclipse IDE. Go to Window > Preferences > Server > Runtime Environments and click on the Add... button to show the New Server Runtime Environment dialog. You will find the OpenEJB 3.0.0 runtime under the Apache folder. Click on the Create a new local server checkbox, then forward to the next page. There you have to give the location where you have unzipped OpenEJB.
Well done! You are ready for EJB development on top of OpenEJB. Try creating a new EJB project: File > New > EJB Project. Choose OpenEJB 3.0.0 as Target Runtime. You may choose between versions 2.1 and 3.0 for spec version. The OpenEJB project claims it supports also 1.1 and 2.0, but this is not reflected in the Eclipse server adapter. We may need to wait a little bit for this to change.
You may also try publishing your EJB modules to the OpenEJB server and running them. You may ask me: "How do I run EJBs when I have no web tier?". You have two approaches:
- Create an application client that calls the remote business interfaces of your session beans.
- Create JUnit tests that calls the local or remote business interfaces of your session beans. Then run the JUnit test suite with the OpenEJB runtime embedded in the suite's JVM.
I am sure the second approach tickles your curiosity. But wait, I would not give you all the sweets at once. You need to wait for my next blog post to see how this works.
The Apache OpenEJB is great alternative to full-blown application servers when we talk about lightweight EJB development environments. It does what Jetty does for Web development. Eclipse already ships with Jetty runtime embedded. The WTP project utilizes Jetty in the J2EE Preview runtime, aiming to give out-of-the-box experience for Java EE developers. The OpenEJB embeddable runtime would be a natural addition to the J2EE Preview runtime and would bring it to completeness.
Providing a lightweight Java EE development environment is an usability goal for the WTP project. Stay tuned to see our progress towards achieving this idea.
No comments:
Post a Comment