====== Karaf Web ====== ====== Example: pax-whiteboard ====== * http://www.modio.io/angularjs-using-the-http-whiteboard-service/ * http://coding.alasdair.info/2011/01/creating-web-application-bundle-using.html ===== 1. Generate bundle project with Web Bundle Archetype ===== mvn archetype:generate -DarchetypeGroupId=org.ops4j.pax.web.archetypes -DarchetypeArtifactId=wab-archetype ===== 2. Add dependencies ===== org.ops4j.pax.web pax-web-extender-whiteboard ==== Parent pom.xml ==== 2.3.7 2.5 6.0.3 org.ops4j.pax.web pax-web-extender-whiteboard ${org.ops4j.pax.web.version} ===== 3. Blueprint ===== We move html to src/main/webapp. The folder content will be configured to be placed in bundle root (build config). So we also put blueprint.xml file there. mkdir -p src/main/webapp/OSGI-INF/blueprint vim src/main/webapp/OSGI-INF/blueprint/blueprint.xml cat src/main/webapp/OSGI-INF/blueprint/blueprint.xml index.html ===== 4. mvn build configration ===== Configure bundle root <_wab>src/main/webapp/ This means everything in src/main/java is compiled and put in WEB-INF/classes. Everything in src/main/resources is put in WEB-INF/classes. This is pretty much what you would expect because these locations are used to put files that are loadable via the classloader. The content in src/main/webapp is then placed in the root. In fact in this scenario you put the web.xml in the src/main/webapp/WEB-INF directory, and if your WAB contains blueprint your blueprint would go in src/main/webapp/OSGI-INF/blueprint. * http://coding.alasdair.info/2011/01/creating-web-application-bundle-using.html org.apache.felix maven-bundle-plugin ${maven-bundle-plugin.version} true ${project.artifactId} ${project.version} * /services <_wab>src/main/webapp/ jar bundle war generate-manifest process-classes manifest maven-war-plugin ${project.build.outputDirectory}/META-INF/MANIFEST.MF The resulting jar: jar tvf target/sd-web-webapp-1.0.jar 698 Fri Apr 21 19:20:58 CEST 2017 META-INF/MANIFEST.MF 0 Fri Apr 21 19:20:58 CEST 2017 META-INF/ 0 Fri Apr 21 19:20:58 CEST 2017 META-INF/maven/ 0 Fri Apr 21 19:20:58 CEST 2017 META-INF/maven/com.gtarc.servicedirectory/ 0 Fri Apr 21 19:20:58 CEST 2017 META-INF/maven/com.gtarc.servicedirectory/sd-web-webapp/ 147 Fri Apr 21 19:20:58 CEST 2017 META-INF/maven/com.gtarc.servicedirectory/sd-web-webapp/pom.properties 2742 Fri Apr 21 19:20:10 CEST 2017 META-INF/maven/com.gtarc.servicedirectory/sd-web-webapp/pom.xml 0 Fri Apr 21 19:20:58 CEST 2017 OSGI-INF/ 0 Fri Apr 21 19:20:58 CEST 2017 OSGI-INF/blueprint/ 974 Fri Apr 21 18:15:48 CEST 2017 OSGI-INF/blueprint/blueprint.xml 328 Fri Apr 21 18:10:58 CEST 2017 index.html ===== 5. Load & run ===== karaf@root()> install -s mvn:com.gtarc.servicedirectory/sd-web-webapp/1.0 feature:repo-add mvn:com.gtarc.servicedirectory/sd-feature/1.0/xml/features