Skip to content

REST API example with OSGi framework, Apache Karaf, Apache CXF and Eclipse Jetty

License

Notifications You must be signed in to change notification settings

dushanlk/osgi-cxf-karaf-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST API with OSGi

A REST API example with following technologies,

  1. Java
  2. OSGi framework
  3. OSGi annotations
  4. Apache Karaf
  5. Apache Felix
  6. Apache CXF
  7. JAX-RS
  8. Eclipse Jetty
  9. Log4J

How to build

mvn clean install

How to run

  1. Navigate to osgi-cxf-karaf-example/server/target directory.
  2. Unzip server-<version>.zip file.
  3. Navigate to bin directory
  4. Use following commands to run;
    1. To start with the Karaf shell use: ./karaf
    2. To start in background use: ./start
    3. To check the status use: ./status
    4. To stop the background service use: ./stop

How to test

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

How to debug

  • The default log level is INFO.
  • If you want to change the log level, you can change log4j2.rootLogger.level = INFO parameter in osgi-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.

How to change the port

  • 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 in osgi-cxf-karaf-example/server/src/main/resources/etc/org.ops4j.pax.web.cfg file.

For a quick customization

Have a look on following modules,

  1. core/api - Contains POJO classes.
  2. core/rest - Implemented REST API and routes.
  3. core/service - Implemented a sample service to process REST API requests.

About

REST API example with OSGi framework, Apache Karaf, Apache CXF and Eclipse Jetty

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages