On 06/28/2012 10:32 AM, gte619n wrote: > 1. What's the best way to share JARs between modules? Currently, they're all > rammed willy-nilly into the /lib directory. I know that I can get OSGi-fied > versions of all the libraries, but where do these things go?
Once you have OSGi versions of the jars, then use the OSGi framework itself to share classes and services. Bundles that expose web apps are just like any other bundle, and follow the same rules in terms of package exports and imports. Keep in mind some resources to find OSGi bundles of existing libraries that do not have OSGi meta-data already included. My general approach is: 1) See if the library has already been OSGi-ify'ed by the ServiceMix-Bundles project [1][2] 2) OSGi-ify it myself by adding maven-bundle-plugin to the library's build process. 3) OSGi-ify it myself by wrapping the library similar to the way ServiceMix does it. [1] Maven: http://repo1.maven.org/maven2/org/apache/servicemix/bundles/ [2] Source: https://github.com/apache/servicemix4-bundles > 1a. For the GWT stuff, (or any other library that is specific to ONE module > only) can I just create a /lib directory in that module and proceed > normally? You could, and then set the Classpath: manifest header for the bundle. However, the preferred approach is to OSGi-ify the library and access it via package imports. That gives you the appropriate visibility and option to re-use the lib elsewhere. > 2. Where do I put all these OSGI-fied JARs? Certainly, it doesn't make sense > to create a Plugin Project for each of the JARs... Do I "Add" them to my > Karaf Installation (I'm using EIT) somehow? Is there a "TOP" level project I > create in EIT or something like that? I created my own Artifactory instance that holds all of my custom bundles, as well as proxies other maven repositories. Say you modify a maven-built library to add OSGi meta-data by adding the maven-bundle-plugin and changing the packaging type to "bundle". You can then deploy it to your internal Artifactory with the "mvn deploy" command, using the -DaltDeploymentRepository parameter to specify your repo. Karaf can be configured to load artifacts from your internal Artifactory repository in etc/org.ops4j.pax.url.mvn.cfg. > 3. Packaging is a bit of a mystery to me. How do I get this badboy up and > running on my server. I see the documentation about the KAR file, which > sounds like what I need, but how do I then deploy that to my server? Do I > "install" Karaf somehow? How do I keep track of everything? You could create a features.xml file that defines all of the bundles and features your application needs. You then add your features repo into the file org.apache.karaf.features.cfg. Then installation is simply a matter of doing: feature:install my.feature in the console. You can also look into the "custom karaf" instructions if you want to customize the karaf installation further. > 4. Assumning I install Karaf on my server (much like Jetty today), is there > a standardized way to "start" it up, thinking along the lines of an init.d > script or something like that. The Karaf web site has some information about this. > 5. I'm planning on running on Amazon. My startegy is to have a base AMI > that, upon startup, goes out to a (custom?) repository and downloads the > latest versions of each module. Is this > possible to implement programatically? Could I write a servlet to kick off > this process? I think I read that there are modules in Karaf to do this > already? The PAX URL functionality included in Karaf does this for you. Just have your modules available in your maven repo, and it will go out and get them. See above. > 6. Given my implementation plan in (5), how would I upgrade Karaf itself? > Would I have to create a new AMI, or can it go find and install it's own > modules. I'm thinking for something like the recent release of 2.2.8, coming > from 2.2.7. This one requires some manual work, afaik. > Thanks for taking the time to read my questions. I really appreciate any > help I can get getting started! > > Thanks, > > E > > -- > View this message in context: > http://karaf.922171.n3.nabble.com/Getting-Started-with-OSGi-Karaf-tp4025096.html > Sent from the Karaf - User mailing list archive at Nabble.com. > Regards, Raman -- Raman Gupta President VIVO Systems
