https://github.com/bdelacretaz/osgi-for-mere-mortals
Sample code for my "OSGi for mere mortals" presentation at ApacheCon NA 2011
https://github.com/bdelacretaz/osgi-for-mere-mortals
apachecon java osgi tutorial
Last synced: about 2 months ago
JSON representation
Sample code for my "OSGi for mere mortals" presentation at ApacheCon NA 2011
- Host: GitHub
- URL: https://github.com/bdelacretaz/osgi-for-mere-mortals
- Owner: bdelacretaz
- Created: 2011-10-12T15:13:28.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2014-11-27T15:09:57.000Z (about 11 years ago)
- Last Synced: 2025-03-28T15:11:22.374Z (8 months ago)
- Topics: apachecon, java, osgi, tutorial
- Language: Java
- Homepage:
- Size: 212 KB
- Stars: 26
- Watchers: 5
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# OSGi for mere mortals
This is the code of my "OSGi for mere mortals" presentation at [ApacheCon](http://apachecon.com) NA 2011, EU 2012 and EU 2014.
It's a minimal standalone RESTful server built from scratch using OSGi Declarative Services, meant
to demonstrate that OSGi is not only for superhuman guru programmers.
This example demonstrates the complete lifecycle of an OSGi application,
from starting the framework and installing the required bundles to running
the app itself.
It also demonstrates the svelteness of the OSGi framework and core services: the total size of the build-time
dependencies (jar files) is around 3 megabytes and additional runtime baggage amounts to ten OSGi bundles (also jar files) representing about 2 megabytes more, including all runtime features like the OSGi web console, interactive OSGi shell, the OSGi configuration mechanism and front-end and the servlet engine. Startup time is around 300 msec on my laptop.
The Maven build is also a useful example of how to create OSGi bundles in a simple way.
The slides at http://www.slideshare.net/bdelacretaz/osgi-for-mere-mortals should help you walk through the code.
## How to build and start
To build the runnable jar, run `mvn clean install` at the top of the source
code tree (using Apache Maven
3.0.3 or later).
You can then start the server from the *launcher* subfolder by running
java -jar target/osgi-for-mere-mortals-launcher-0.0.1-SNAPSHOT.jar
(or whatever the name of that jar file is).
The OSGi console shown in the slides is at http://localhost:8080/system/console - use admin/admin to log in.
## How to use the server
The server doesn't do much, that's not the point, the goal is just to demonstrate how it is assembled.
You can store data via HTTP POST requests:
$ date | curl -X POST -D - http://localhost:8080/store/testing
HTTP/1.1 201 Created
Location: /store/testing
Content-Type: text/plain; charset=utf-8
Content-Length: 149
Server: Jetty(6.1.x)
Stored at /store/testing
StoredBy:ch.x42.osgi.samples.osgi101.app.servlets.StorageServlet
StoredAt:Fri Nov 14 17:03:36 CET 2014
And retrieve it via HTTP GET:
curl http://localhost:8080/store/testing
StoredBy:ch.x42.osgi.samples.osgi101.app.servlets.StorageServlet
StoredAt:Fri Nov 14 17:03:36 CET 2014
Path:/store/testing