A REST API example with following technologies,
- Java
- OSGi framework
- OSGi annotations
- Apache Karaf
- Apache Felix
- Apache CXF
- JAX-RS
- Eclipse Jetty
- Log4J
mvn clean install
- Navigate to
osgi-cxf-karaf-example/server/target
directory. - Unzip
server-<version>.zip
file. - Navigate to bin directory
- Use following commands to run;
- To start with the Karaf shell use:
./karaf
- To start in background use:
./start
- To check the status use:
./status
- To stop the background service use:
./stop
- To start with the Karaf shell use:
Use following CURL command,
curl -v -k -0 -H "Content-Type: application/json" -d "{\"username\": \"hello\", \"password\": \"foo\"}" -X POST http://localhost:7005/cxf/api/example
Or simply run ./sample.curl.sh
- The default log level is
INFO
. - If you want to change the log level, you can change
log4j2.rootLogger.level = INFO
parameter inosgi-cxf-karaf-example/server/src/main/resources/etc/org.ops4j.pax.logging.cfg
file. - You can check/tail
server-1.0-SNAPSHOT/data/log/karaf.log
file for logs.
- This service will start at port no
7005
- If you want to change the port, you can change
org.osgi.service.http.port=7005
parameter inosgi-cxf-karaf-example/server/src/main/resources/etc/org.ops4j.pax.web.cfg
file.
Have a look on following modules,
- core/api - Contains POJO classes.
- core/rest - Implemented REST API and routes.
- core/service - Implemented a sample service to process REST API requests.