Attention: This is old stuff. New build instructions here
You feel that JAX-RS is really nice but you still don't know how you could use it in a real application. This quick post shows an ExtJS app that interacts with TomEE to manage its data. There is no servlets. The interaction is via restful webservices only.
This is a full webapplication, but It will eventually be the authentication layer of our photodb project. We will use it to manage the photodb users.
Feel free to use this application as starting point for your own apps, but be aware of the ExtJS licensing structure. The code that I implemented is distributed under the Apache 2 license, but Ext JS uses GPL with some exceptions (more information here). Basically, you can use the code I did for whatever you want. But, if you plan to create non-opensource application, you will need to buy an ExtJS license.
Ok, no more boring licensing issues. Let's grab our source code.
mkdir -p ~/dev/ws/faceid-ws cd ~/dev/ws/faceid-ws git clone https://github.com/tveronezi/faceid.git cd faceid mvn clean install -DskipTests=true
Done. You have just built the application in your computer. Go ahead and download the latest TomEE+ server. Extract the server, put the faceid-gui.war file under the webapps directory and start it. Your application will start at http://localhost:8080/faceid-gui.
Are you lazy? If you are using a linux box, you are also lucky. :O) Just copy and paste the lines below to a terminal and execute it. These lines will:
- checkout the faceid source code;
- build the application;
- download Apache TomEE+;
- unzip the server;
- copy faceid-gui.war to the "tomee/webapps" directory;
- start the server;
- tail the catalina.out log file
mkdir -p ~/dev/ws/faceid-ws &&\ cd ~/dev/ws/faceid-ws &&\ git clone https://github.com/tveronezi/faceid.git &&\ cd faceid &&\ mvn clean install -DskipTests=true &&\ cd .. &&\ wget http://www.apache.org/dist/openejb/openejb-4.5.1/apache-tomee-1.5.1-plus.tar.gz &&\ tar -xvzf apache-tomee-1.5.1-plus.tar.gz &&\ mv apache-tomee-plus-1.5.1 tomee &&\ cp faceid/faceid-gui/target/faceid-gui.war tomee/webapps/ &&\ ./tomee/bin/startup.sh &&\ tail -f ./tomee/logs/catalina.out
What does this application give to you?
- Real example of an ExtJS application with the mvc architecture.
- An use case for rest webservices (GET, POST, PUT, DELETE).
- Placeholder for your junit tests.
- Placeholder for your Jamine tests (see Makefile. Run "make run-jasmine").
- Lint integration with jslint4java (see Makefile. Run "make run-lint").
- Groovy integration.
- Yet another example of how easy is to use our beloved TomEE :O)