This may be of interest: This is a minimal example of a Declarative
Services component that exposes a Servlet service, that plugs into the
pax whiteboard extender[1].
What the servlet does is very simple: it accepts POST messages, and
dumps each POST message body to a temp file, and writes the name of the
temp file as an INFO level log message to an OSGi log service injected
into the DS component.
What I needed it for, was to capture POST messages from SonarQube
webooks[2] for use in testing when creating a servlet that would capture
SonarQube statistics and store them for easy analyisis and graphing[3]
(we would like to show graphs for some key numbers, e.g. line number,
test coverage, complexity, for the applications in our application
portfolio over time. We have keyed them in by hand, but capturing them
automatically seemed like a better idea).
Some higlights:
1. Code example of using DS annotations to create a servlet with a log
service injection[4]
2. Maven POM configuration for a DS servlet set up with annotations[5]
3. Code example of a karaf feature template file for a DS servlet
plugging into the Pax Web whiteboard extender[6]
4. A karaf-maven-plugin config that creates, and attaches, a karaf
feature for the bundle (this config will create a feature repository
containing features (and bundles) from the template file, as well
bundles from compile dependencies to the bundle project)[7]
(all of the above took me a bit of googling to find, and it is the hope
that a small, complete, example that doesn't need to be part of a large
build, may be useful. Heh... the servlet may also be useful for what it
does: capture POST messages into files. It certainly was for me...:-) )
References:
[1] <https://github.com/steinarb/post-body-capture>
[2] <https://docs.sonarqube.org/display/SONAR/Webhooks>
[3] <https://github.com/steinarb/sonar-collector>
[4]
<https://github.com/steinarb/post-body-capture/blob/master/src/main/java/no/priv/bang/debugutils/PostBodyCaptureServlet.java#L32>
[5] <https://github.com/steinarb/post-body-capture/blob/master/pom.xml#L154>
[6]
<https://github.com/steinarb/post-body-capture/blob/master/src/main/feature/feature.xml>
[7] <https://github.com/steinarb/post-body-capture/blob/master/pom.xml#L189>
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.