Java EE 6 CDI Examples: Accessible To All SVN, Git or Just Download The Zip
Java EE 6 CDI Examples: Accessible To All SVN, Git or Just Download The Zip
The first set of samples is based on the samples that ship with Weld, the reference implementation of CDI. This version of the samples include a working Eclipse Java EE IDE project files as well as a simplified maven pom.xml that will work with Maven 2 and Maven 3.
To download the code using svn, use this from the command line: $ svn co http://jee6-cdi.googlecode.com/svn/samples/trunk jee6samples
Requirements:
You need a Java 6 EE server. Dont worry we explain how to download a lightweight one. The samples should work with Resin, Glassfish, JBoss or any other application server that supports the Java EE 6 Web Profile. You need Java 6 SDK. If you plan on building with maven, then you need maven (it works with maven 2 and maven 3).
$ cd jee6samples $ cd numberguess $ mvn clean install At this piont you should have a war file that will run in any JEE 6 Web Profile Server container (Resin, JBoss and Glassfish). The war file will be in the ./target director. You can copy this war file to the deployment directory of your server and start it up. You can build login in a similar manner.
If you dont have the Java EE IDE from Eclipse, you should download it. As you can see, we used Helios Server Release 2 for this. If you dont have Eclipse go to http://www.eclipse.org/downloads/ and download the Java EE IDE. To import the projects, run the File->Import menu item. Then under General select Existing Projects Into Workspace.
At this point, the candi-jsf-login and the candi-jsf-numberguess projects should be imported into your Eclipse workspace. All that is left is to install a Server, and run them.
http://www.caucho.com/download/ This example is using the 4.0.X series. Once you download it, you can configure it in Eclipse, but first you need to install the Resin Plugin for Eclipse WTP. (WTP stands for Web Tools Project and it allows you to use Eclipse with many different sever vendors). Go to the Help->Install New Software menu item. Then click o the Add button. Then enter the Name Caucho (the company that makes Resin) and the Location as http:// caucho.com/eclipse as shown below.
Next from the Tree List Select expand the Caucho Resin Node and Select the Resin Eclipse Feature. Then click the Finish button. You have now installed the Resin plugin for Eclipse. Now to run one of the projects on Resin from Eclipse, you just Right Click the Project and select Run As->Run On Server. The first time you do this you will need to setup a Resin server in Eclipse as follows:
Keep hitting the Next > button until it deploys the application to the server (accept the defaults). You only have to setup Resin once. Subsequent times, it just works. At this point you should have a running application.
You can run and debug this application in Eclipse and you can use it as a template to develop your own application to explore CDI and Java EE 6. Happy coding! Let us know what you think.
Additional References: