Book - OSGi in Practice

I am currently writing a book on OSGi entitled “OSGi in Practice”. This will be a free book, released as a PDF under a Creative Commons license.

Lacking a traditional publisher, I would like to ask for your help to review my book, check it for inaccuracies, run the example code, and critique my writing style. In return, you will get early access to sections of the book. All contributions, no matter how small, will be acknowledged in the foreword. I have set up a bug tracker for reporting errors and giving feedback.

Here is the download. For those who downloaded earlier previews, note that I am no longer releasing individual chapters: this is a single PDF of the whole book as it stands, albeit with several chapters missing.

Also please note that at the moment this is a very rough draft. Do not rely on it as being in any way authoritative — if in doubt, always check the specification.

114 Comments

  1. jayagopi jagadeesan:

    Hi Neil,

    This venture of yours is long awaited. Such a book is really desired by all of us deeply interested in this exciting and “working” technology OSGi. Will provide my feedback as and when I get time to go through the chapters. Keep up this great work man! cheers, jay

  2. Murad Juraev:

    Dear Neil,

    I agree with Jay. Developers do need such a book. And thank you a lot for choosing CCL and your valuable contribution to the Open Source Community. I am sure CCL will not prevent you from getting huge profit if you decide to publish your book in Apress, OReilly, etc.

  3. MB:

    Hi,

    I hope this book becomes a success, nice to see a free ebook. Now some feedback;

    1. Maybe you could spice up the book abit like change the fonts , the chapter heading styles etc. instead of using the defaults … :)
    2. Did you compress the pdf? take a look at pg. 10, 15, the fonts are not so sharp.
  4. Neil:

    Hi MB, thanks for your feedback.

    Regarding the fonts and style issues… yes I may play around with those later. At the moment I’m concentrating on getting the actual content written!

    You’re right about the blurriness, I hadn’t noticed this before. It’s probably an artifact of the tool I’ve used to take an extract from the book, which is the LaTeX “pdfpages” package. It seems to be taking an image of the original pages and embedding them in a new PDF!

    Does anybody know of a better way to extract a range of pages from a large PDF, and prepend it with a page of boilerplate?

    Many thanks, Neil

  5. jayagopi jagadeesan:

    Hi Neil,

    Just reading through your chapter 2. Easy reading and fun stuff. Well written tutorial. Just a few minor points : 1) better to rename ch-2 to “Getting Started” 2) It is better to keep the “helloworld” and “bundlecounter” bundles in separate packages, say, osgi.tutorial.helloworld and osgi.tutorial.bundlecounter. Also make the changes in the “Private-Package” entries in the helloworld.bnd and bundlecounter.bnd files. This way, the helloworld class files don’t get into the bundlecounter.jar unnecessarily. Good work Neil! cheers, jay

  6. Scott Rosenbaum:

    If you want to work with PDF like that, try iText.

    I haven’t tested, but it should look something like this.

    public static void split(File inf, int pageStart, int pageEnd, File outputFile) throws Exception {

    FileOutputStream fos = new FileOutputStream(outputFile);
    Document doc = new Document();
    
    // use a RandomAccessFileOrArray to limit memory size
    // during extraction
    
    PdfReader reader = new PdfReader(new RandomAccessFileOrArray(inf.getAbsolutePath()), null);
    
    PdfCopy writer = new PdfCopy(doc, fos);
    doc.open();
    
    for (int pageno = pageStart; pageno <= pageEnd; pageno++) {
        PdfImportedPage page = writer.getImportedPage(reader, pageno);
        writer.addPage(page);
    }
    
    doc.close();
    writer.close();
    fos.close();
    

    }

  7. Kevin Conner:

    Hiya Neil.

    Congratulations on starting this endeavour, it is a topic that has been crying out for good books. I am confident that this will be a big success for you. :)

    I would also like to echo the thanks of others for choosing to release under CCL and look forward to reading the work as it progresses.

    Good luck, Kev

  8. Sud:

    Neil,

    Thank for this effort. I’ve used eclipse for about 2 years. Your chapter on getting started with OSGi has finally helped me understand where OSGi (equinox) ends and Eclipse starts. Looking forward to the remaining chapters.

    I especially like how you take the route of using Felix for your examples. It keeps things simple and clearly demystifies OSGi when using it from Eclipse.

    -sud

  9. Link:

    Hi, Neil. I appreciate your working on writing such a book. I begin to learn OSGi recently, and looking for a suitable book all the time. Your aticle <> has help me a lot. I hope this book will be finished as soon as possible. :)

  10. Rajkumar Vakkada:

    All the best for you. I wish this book will lay the foundation for the next generation java/jvm applications

  11. ron:

    Thanks very much for writing this book. I’ve only read one chapter so far, and I’ve already learned a lot. I find your writing style to be very readable and I think it was brilliant to approach osgi without PDE.

  12. Jean-Pierre Fortune:

    Hi Neil,

    Thanks for this great work! We have a strong OSGi community in France. I intend to translate it into french. What do you think?

    Best regards,

    Jean-Pierre

  13. Raghuram Sripada:

    Neil,

    Thanks for deciding to release this under Creative Commons.

    All the best!!

    -Raghuram

  14. Neil:

    Jean-Pierre,

    That would be absolutely formidable! Yes please! I will contact you by email to discuss.

    Neil

  15. Danny:

    This is great work! I can’t wait for the rest of the chapters to be written.

  16. ZiglioNZ:

    Hi Neil, great work! Talking about OSGi services and Eclipse, I’ve just seen a presentation that talked about the Equinox Application Model. Is that the same as Declarative Services? If the Equinox Application Model were already available then you could have probably used Eclipse and the Equinox console for your examples :-) I appreciate though your OSGi rather than Eclipse -centric approach.

  17. Neil:

    Hi ZiglioNZ,

    Thanks for your feedback. Actually the Equinox App Model is a mechanism for launching “applications” built on Equinox. One example of such an application is the Eclipse IDE itself. In fact the application model is based on the standard OSGi Application Admin service, which is documented in Chapter 116 of the OSGi Compendium specification. It is unrelated to Declarative Services.

    App Admin doesn’t have anything to do with the OSGi console either, so unfortunately it doesn’t solve the problem of choosing which console implementation to use for the examples. Each OSGi framework implements its own console and they’re all a little bit different. Worse, Equinox’s console is implemented directly in the core framework JAR rather than in a separate bundle, so you can’t run it on other OSGi implementations, whereas the Felix console is in a separate bundle so you can run it on Equinox and KF. Therefore it seems to make more sense to standardise on Felix’s console for the examples.

    Neil

  18. Jean-Jacques:

    HI Neil,

    Thanks, for all articles and now starting a book on OSGI =)

    One of the feature that interest me on OSGI is pluggability of external module by partner for example.

    However, if I want to integrate external code on a server side platform using OSGI : How it can be secured ? (Policy file could be used to deny access to some API or files) Is there any plan to handle it in API way ? How to ensure that one bundle is no going to get all resources of the server ?

    Any help appreciate =)

    Thanks

  19. Heath:

    Thanks very much for these great chapters. I especially like the documentation on the bnd tool. I really dislike using PDE build to make my bundles/plugins. I hope you can include a thorough chapter on the building a large application comprised of many bundles with bnd. Additionally, it would be nice to have a chapter on the best ways to integration-test an application comprised of many interdependent bundles, especially from a continuous integration server like cruisecontrol.

  20. Robert Burrell Donkin:

    Thanks for start a book on OSGi :-)

    I have some stylistic comments. I’ve done some technical reviewing in the past so I know some authors can be prickly about stuff like that. Interested in stylistic comments? If so, ok posting them in public or would you prefer private?

    Robert

  21. Mirko Jahn:

    Hi Neil,

    I like your idea of writing a book with the help of the community. I think this is a very interesting approach and case study on “open projects”. To help you with your effort, here are my first two cents…

    During my work with OSGi I found the hardest part for people is not getting started with OSGi, but how to migrate their existing infrastructure into an OSGi based one. This includes not only typical design issues of the software itself, but also the build environment. As far as I can tell, there are only very few projects starting from a scratch. Maybe it is worth considering a section on that as well. I guess you have plenty of experience on that too, but if you’re seeking for input, just let me know ;-)

    Mirko

  22. Jeff Trent:

    Hi Neil,

    I second Mirko’s suggestion and offer…

    OSGi seems to lend itself to new development efforts. Unless you have an isolation tier in place that was developed with the foresight to delegate classloader, logging, file i/o, and object lookup / creation to it, then it seems to be a much more involved effort to transition to OSGi.

    I also am bothered by how global and flat the services are. They all have equal visibility to the others and don’t support a notion of application or call context. Most enterprise patterns don’t lend well to the transition.

    Regardless, I think you are doing an awesome job (and service to the developer community) with your book. Keep up the good work!

    Cheers, Jeff

  23. Richard Emerson:

    Neil, many thanks for this work. It really is excellent.

    It’s so refreshing to read a proper well-written tutorial introduction to OSGi, especially after such a long time trying to piece together information from various specs, blog posts and mailing lists. The tone and level of the content is pretty much spot-on too.

    I urge you to pitch it to O’Reilly. The OSGi world needs this book!

  24. Angelo Tata:

    Hi, Neil.

    I’m adding my “thanks” to the list. I’ve been digging into Eclipse programming (read “plugins”) and I’ve always wondered how to approach OSGi as a separate entity. Now there’s a clear path… :-)

    Angelo

    P.S. Following Jean-Pierre example, I was thinking about a translation into Italian. Would you care to talk about it?

  25. Lawrence Mandel:

    Neil,

    Have you considered publishing with Lulu.com? I haven’t used the service but it looks like a good way to get your book into print for people who prefer this format. Plus, you can get an ISBN and perhaps even make a little money for your effort.

    Lawrence

  26. Christian Rühl:

    Hi Neil,

    your installments from “Getting started with OSGi” were a perfect help for me with my latest project. I just wanted to say that I can’t wait to see more chapters of your new book and that I’d definetly buy one copy if you intend to publish it one day.

    Thanks so much!

    Chris

  27. Akira:

    Hi Neil,

    congratulations for your initiative. The feedback list is already getting big. In a while, this will get unmanageable for you. Why don’t you try something new and use a bug tracking system to help you writing your book?

    Akira

  28. Jacques Ledoux:

    Hi Neil,

    We are early adopters of OSGi and already have written quite a bit of code as server applications. In the process, we (sometimes painfully) acquired hands on knowledge about the beast. Me and members of my team will be glad to review and comment the book. I am sure that in the process, we will acquire new insights as well.

    Bravo and be assure of all our support.

    Jacques

  29. Charlie:

    Excellent resource! I look forward to purchasing a hard copy.

  30. Thomas:

    Hi Neil,

    I would like to publish your book as an Eclipse help plugin on my website http://eclipsedocs.berlios.de.

    Can you also publish the book as HTML for easy packaging as a help plugin?

    Best regards, -Thomas

  31. Pawel Kowalski:

    Hey Neil,

    Great Book!

  32. Ruben:

    Neil,

    Thanks so much for this awesome contribution on your part. Can’t wait to the remaining chapters!

    Cheers, -Ruben

  33. Josef:

    Neil, Excellent work! One question on the “Introduction to Services” chapter. You give the impression that services must be Java Interfaces, whereas, if I’m reading correctly, the spec says that they can be Java classes too. Sure, we should program to Interfaces and all that…..

    — Josef

  34. Eelco:

    Hey Neil,

    Thank you for the excellent work. I read your chapters with great interest, especially your ideas about concurrency. As I am new to OSGi and concurrency I wondered with reference is behind number 13. You refer to it as invaluable and it might help me to get a better understanding about the choices you made to tackle the concurrency issues.

  35. Confluence: 7000 Product Development:

    OSGI und WebServices…

    OSGI in Practice…

  36. Markus:

    Hey Neil,

    Comment to Introduction to services on page 23

    This syntax is borrowed directly from LDAP search filters, as defined in [?-> RFC 1960].

    Cheers, Markus

  37. Ben Hutchison:

    The standard of this book is excellent: well explained & organized content and a writing style that’s really pleasant to read.

  38. Keesun:

    Hi Nell.

    I’d like to specilly thank you for this book. It is really helping me understand and study OSGi. I’m now practicing some exersices on chapter “First Step In OSGi”.

    Now, I have no idea what is the volatile keyword’s role from examples. Please let me know if you have some time to explain that.

    on page 38.

    private volatile BundleContext context;

  39. Jane:

    Hi,

    This intro to OSGI was very helpful in getting me started using OSGI. Thanks!

    I am having trouble using bind tool with eclipse. I followed the instructions as mentioned in the chapter steps chapter but when I try to “make bundle” I get “Jar is Empty” error and the reason is blank. Could you please tell me what I could be doing wrong?

    Thanks a lot!

  40. Tina:

    What about some pointers on how best to test OSGI applications? I’m thinking here of unit-testing, as well as integration testing between components or verifying component configurations, all preferably executable in a continuous integration environment.

  41. Hossam:

    you are the man to publish a strong book like this ….

  42. Eugene:

    Very helpful stuff. Thank you!

  43. Slamet Cahyadi:

    Firstly, I thank you for the book you’ve written. It was a really good book.

    There is one thing bothers in my mind, and pardon for being rude. Are you the same person as in this small article ‘RIP Neil Bartlett’ from “http://neilbartlett.name/blog/”?

  44. Tim Peoples:

    Thank you so very much for this excellent work. I’ve really found each chapter to be quite helpful.

    When might we be seeing the next installment?

  45. Jm Wowchuk:

    Overall, very good! However, could I suggest you include a chapter on Preferences and Configuration? I’m happy to contribute as well.

  46. architecting's me2DAY:

    [짱가™]의 생각…

    OSGi.In.Practice?…

  47. Eugene:

    Neil, Since you said that you don’t have a publisher, I thought you may find this useful. Have you heard of Qoop? (http://www.qoop.com/?tab=documents?) It provides on-demand printing services - you upload digital content and people can order hard copies on demand.

  48. Wim Jongman:

    hi, great book!! Here are some edits:

    Chapter 1 page 6: 5. class loader “files” to find the class page 7: par:1.2.3 first sentence gets lost in the end (at least i don’t understand it) page 11: footnote [2] Is it really impossible? You told us on page 4 that we could override the class loaders finding process page 13: 1.4 ..eliminates almost all of “the” problems…

  49. Thierry Templier:

    Hello,

    It’s really a good idea to translate that in french. Do you work on that since May and do you need some help? Thierry

  50. Michael McGrady:

    Great book. Where is the source code for the examples?

  51. Iskender Yigitel:

    Dear Neil, I have been following your tutorials and blog on OSGI. I must admire that your tutorials had been very useful for me. And finally this book is a very very useful for OSGI developers, and people who are interested in OSGI. Great effort. Thank you very much.

    Best Regards Iskender Yigitel

  52. Neil Laurance:

    Hi Neil, Attended your course at QCon/SkillsMatter yesterday (8th October), and for me it was the highlight of the day. Thanks for cutting through the hype and clearly explaining what OSGi is all about.

  53. Helen Hunt:

    Hi Neil, I couldn’t attend the talk at the QCon/SkillsMatter on the 8th due to other pressing commitments. However, I hope to make it this time to your next talk on Eclipse DemoCamp on 25 November.

    See you all there!

  54. Claus Augusti:

    Hi Neil,

    just wanted to drop in and say thank you for work and licensing it under CC.

  55. Thomas Singer:

    Thank you, Neil, for your effort. What I really would like to read is some information about using Felix as a framework to update an application - similar to, lets say, Firefox. Also it would be of interest, to be able to define where the repository will be created, so one could use it for multiple applications on the same machine which are installed in a read-only directory (each application should have its own repository).

  56. Giovanni:

    I am reading your book and I am finding it really interesting. Thanks for deciding to release this under Creative Commons. All the best!!

    -Giovanni

  57. Paul Ruest:

    Thank you for doing this! Nice level of detail. Very readable. Left a few requests in the bug tracking system. Definately looking forward to the chapters on Testing OSGi Bundles and Using Third-Party Libraries.

  58. Angelica:

    Hi Neil, Thank you very much for your effort. Your book is very interesting. I have a special interest on the EventAdmin Service. I’m trying to remote this service using the Equinox implementation. Normally i have to implement a new service that communicates with the EventAdmin Service in order to get the remote aspect. Have you an idea, how can i do it?

    Thanks & regards Angelica

  59. Bart:

    Typo on page 94: Boolean “ANT” should be AND of course :-)

  60. al werner:

    Hi Neil,

    I have found out about your publishing project on “JoelOnSoftware”. It was a great surprise for me to flick through the first 100 pages of your book, and note how much information I had actually retained during this exercise.

    Your skills to kindle the readers desire to learn more abour OSGi, while keeping him alert at the same time, with an excellent introduction and good examples put you at the forefront of a fine author and communicator.

    Good luck in all your future publishing projects.

    Kind regards

    Al:

  61. cenyongh:

    Hi Neil,

    I have just finished the book. The content is great. But I think the layout should be improved, some paragraph is seperarated by a pretty long code which make reading the content and reading code a little bit harder.

  62. Saravanan:

    Hi Neil,

    This timely content is both interesting and applicable to one of my projects!

    I started reading it sometime ago and wondering if you have plans to include these topics as well:

    iPOJO, Spring Dynamic Services and a comparision of these frameworks with Declarative Services.

  63. ackerulr:

    Seems the download link is broken. :( Would really like to have a look at the book since the “Getting started with OSGi” articles served me well!

    Thanks, Ulrich

  64. OSGi Bookshelf « The OSGi Look:

    [...] OSGi in Practice, by Neil Bartlett Not complete yet, but it’s free, and it’s, in my opinion, the most well-written book on the topic. Donwload it here [...]

  65. href » OSGi in Practice -kirja:

    [...] Bartlett tarjoaa hyvän perusesityksen OSGi:stä vapaasti saatavilla olevan kirjan [...]

  66. Tor Arne kvaløy:

    Hey Neil,

    Thank you so much for the OSGI book, I have found it very useful!

    However, I found something that didn’t make sense to me, and it has to do with how you describe classloading in a classical J2EE application server.

    On page 15 you write: ?They cause class conflicts: classes found higher in the tree always take precedence over the classes that are shipped with the application. In fact, every application in the server must now use the same version of the library.?

    As far as I know this is not true. In an article called “J2EE Class Loading Demystified” at Developworks(http://www.ibm.com/developerworks/websphere/library/techarticles/0112_deboer/deboer.html) they say that the classloader at the war-level can be configured to load its own jar-files before jar-files of its parents. This is when delegation is turned off.

    “When delegation is turned off, the classloader first attempts to load the class itself. If it can’t load the class, it asks its parent to load the class.”

    I hope this can be useful for clarifying this issue with classloading.

    Tor

  67. Provisioning Amazon EC2 with OSGi « The OSGi Look:

    [...] a comment » Neil Bartlett, the author of OSGi in Practice, has came up with S3Install, a a very simple runtime OSGi bundle for provisioning an Amazon EC2 [...]

  68. Razec:

    Hi Neil,

    Congratulations thank you so much for the good book. Now I can understand about OSGi, I wrote in my blog a post in portuguese(Brazil) and I commented about your book.

    Thank you very much =)

    See yaa

  69. eldn:

    THX a lot for your great work. Very Helpful!

    eldn

  70. Geert Schuring:

    Neil,

    I’ll be reading a large part of your book, and I’d like to send you my comments. How would you like to receive them… as comments on this post, or in your mail, etc?

    For starters: The line “This hinders collaboration amongst different business areas.” on page 15 doesn’t really make it clear to me why shipping all dependencies with every application would hinder collaboration between business area’s. You might want to explain that a bit further.

    Hope to hear from you!

  71. Rafael:

    Neil,

    Thank you very much for your wonderful book !

    Regarding using Felix inside Eclipse, I wanted to avoid copying all Felix startup bundles in each project. So I have found an alternative.

    I have all my felix.jar ans startup bundles in a fixed, read-only location (i.e. /usr/local/java/felix-1.4.2). I created a User Library Felix pointing to /usr/local/java/felix-1.4.2/felix.jar and also another user library named ‘Felix Bundles’ with all three other JARs.

    Then, I only need to setup a conf/config.properties in each project. However, the paths inside this file must be edited where the startup bundles reside on disk. The run configuration needs a VM configuration argument -Dfelix.config.properties=file:conf/config.properties

  72. Slawomir Zielinski:

    Hi Neil, hope you finish that book very soon - so far it is wonderful!

    One little remark (for now…): on page 16 you write “Optionally, information about the minimum Java version that the bundle needs to run on.”

    I assume you are writing about JRE version. But OSGi is expected to run on many platforms, including e.g. J2ME. Does the metadata contain more specific info (e.g. the required profile and its version)? I guess it does. Of course, chapter 1 is not the place to deal with details, but “Java version” says nothing.

    Well, that’s chapter 1. Now I’m getting to chapter 2…

    Regards, Slawek

  73. taknev:

    Thanks for taking up such an endeavor. Not yet started reading, but will update my comments once I complete it.

  74. roger schildmeijer:

    errata: p.52 fourth row from the end. should be Export-Package instead of Import-Package

  75. roger schildmeijer:

    page 119, section 6.3 safe publications before: “Initialise an object …” after: “• Initialize an object…”

  76. OSGi Training « EclipseSource Blog:

    [...] OSGi in Practice, by Neil Bartlett [...]

  77. dev:

    where can i download the sourcecode of the book?

  78. Slawomir Zielinski:

    Page 81: “Users of non-Windows operating systems tend to know how to find their home directory already.” :)=) !!! More sentences like that, please!!! SZ

  79. Slawomir Zielinski:

    page 145: “the broker will have a much longer life than the individual observers or listeners” — shouldn’t there be “observables” instead of “observers”? The same (mistake?) occurs a few times in that section.

    page 96: boolean “ANT”… i.e. a little binary creature ;) ?

    Regards, SZ

  80. Jared MacDonald:

    Hi Neil,

    It’s great to have this book - I’m about to dive in.

    I am eagerly anticipating the section on testing OSGi bundles - this has been the hardest part for me in our OSGi usage so far (knowing things are in stable before you can actually start asserting anything, for example).

    Thanks again, Jared

  81. rt:

    Great Book, however I’m stuck on chapter 3, if anyone could help please. I copied the interface bundle, but I can’t get bnd to import it into the fixedmailbox bundle. I’m using Eclipse and the imports for the Message (and the other) interfaces are unresolved. Doing a “make Bundle” (in the fixedmailbox bundle), does not work as described in the book. All teh .java files are in error hence my package appears empty to bnd. Any ideas would be great

  82. Breton:

    I ve just read chapter 1 and 2. I can already say I m very pleased to read this book. This is a very good introduction for me in OSGI world Thanks to Neil …

    Breton.

  83. Gary:

    Neil (and others).. Hoping you could answer a quick question that reading your book raised.. I was looking for a “pattern” on how to package up some functionality and when I saw the section on Fragments I thought “this is it!”.. What I can’t seem to square is how to use Fragments with Declarative Services.. Since the fragment never gets “started” I can’t see how DS knows about the service(s) contained in the fragment. The reason I want to do this is the fragment implements an interface described by the Host Bundle.. The Host will then use the fragments implementation.. I don’t want to expose the fragment to the general public.. It’s really private to the Host.. But I didn’t want to include the impl inside the host bundle because then I’d need to swap the entire bundle if I wanted to change out the impl.. Anyways. Hoping you could explain how Fragments play with DS (if at all)..

    Thanks!!! Gary

  84. Gary:

    By the way.. Forgot to mention this.. I love the book.. Just what I needed.

    Thanks again Gary

  85. Johnny:

    Nice book! Thx for sharing this!

  86. Johnny:

    Nice work on the book and thx for sharing.

  87. Richard Clayton:

    Neil,

    This really jump-started my OSGi development. I’ve been scouring the web for information/tutorials on the different implementations and came across your book. I would have to say that it is by far one of the better technical books I have read. I know that you are publishing this under the CC license, but will there eventually be a print copy? I realize that I could just “print out” the pdf copy, but I would rather reward you for your efforts.

  88. Li Shu Qiang:

    Thx Man

  89. OSGi Bookshelf, update 1 « The OSGi Look:

    [...] OSGi in Practice, by Neil Bartlett No big news on this side, the book is not complete yet, but it’s free, and it’s, in my opinion, the most well-written book on the topic. Donwload it here [...]

  90. Li Shu Qiang:

    good book

  91. Will:

    Hi Neil,

    Thanks for the book as well as the series on OSGi and the interview you did with InfoQ on OSGi technology.

    I have a question regarding OSGi…

    I am doing a project where I am using OSGi to add modularity to my application. I am following the extender based model with the OSGi framework hosted in the application itself. I am using Apache Felix. When the app starts it creates an instance of Felix and can search out and install bundles. So far this is working ok.

    My question is in regards to writing the bundle extensions for my main app. The application has an api which is basically in a package org.xyz.api and bundles written for my app will need to import this package. I am confused as to how exactly this would happen. My idea is to have a ‘plugins’ folder where bundle .jars would be placed and the app can search them out and install them (which I have managed to work out successfully by deploying a simple ‘Hello, World’ bundle in there).

    However, I am unsure as to how someone would develop a bundle utilizing my API package and how they would test it. I am trying to write a bundle to test this and I am stuck on how to test - If I import org.xyz.api.* in the test bundle will it compile so I can create the .jar to place in the ‘plugins’ folder and then run the app to test the bundle…?

    Any assistance will be greatly appreciated. I am very new to OSGi so forgive me if I am mixing up issues. You can email me directly. Thanks.

  92. Franck:

    Hi Neil,

    many thanks for the book! I’m just about to try the first example but the annoying thing is that the examples are not directly usable from a copy/paste: I get text like i m p o r t org . osgi . f r a m e w o r k . B u n d l e A c t i v a t o r ; instead of import org.osgi.framework.BundleActivator;

    Could you change the way the examples are written or provide alink to the source code?

    Thanks! Franck

  93. OSGi Bookshelf, update 1 | The OGSi Look:

    [...] OSGi in Practice, by Neil Bartlett No big news on this side, the book is not complete yet, but it’s free, and it’s, in my opinion, the most well-written book on the topic. Donwload it here [...]

  94. Modular Java: a review | The OGSi Look:

    [...] target is probably not the OSGi absolute beginner, who will benefit more from reading a book like OSGi in Practice (or the specification itself), but the OSGi practitioner who wants to start developing its OSGi [...]

  95. Josh’s prever » Adopting OSGi requires patience and money, but development flexibility results:

    [...] blogs and articles, and in some recently published books, such as Modular Java by Craig Walls and OSGi in Practice by Neil [...]

  96. Daniel Beck:

    Hi Neil,

    it is difficult to read books in the PDF format on a ebook reader (like the SONY ebook reader). would it be possible to release “OSGI in action” in the EPUB format? EPUB is a free and open standard.

    Thanks Daniel

  97. Mike:

    Where’s Neil?

    Has anyone noticed that Neil has stopped answering these comments? Too bad, because in addition to a very useful book having direct access to the author for questions could be a great help.

    Maybe we can try to help each other right here?

    For instance I have a question I’ll pose for Neil but if anyone else has an answer feel free to jump in.

    As an example I’d like to try and answer rt’s question.

    rt, I have not had the problem you described. You do not have to “do” anything to get bnd to import a referenced bundle; it does this automaticaly. Here are a few things to check, make sure when you created the API bundle, you exported the packages. Also make sure you have no errors in your fixedmailbox code and you are implementing the interfaces in the StringMessage and FixedMailbox classes and have imported the API package (without the right import statements you will get build errors anyway).

    Hope this helps.

    Let’s try to help one another. I’m sure Neil is a busy guy.

    Neil it would be great to get your input where you can, but anyway thanks for a very good book. Can’t wait to see the final product.

  98. Mike:

    Now for my question!

    When working with the fixedmailbox example the book first has us create a bundle with only the StringMessage and FixedMailbox classes. Recall that these classes are in the org.osgi.book.reader.fixedmailbox package. We then create a bundle called fixed_mailbox.jar. So far all’s well.

    Next we create a class called WelcomeMailboxActivator in the fixedmailbox package. We then create a bundle called welcome_mailbox.jar.

    Now we have two different bundles built from the same packages. The welcomemailbox.jar bundle contains all the classes in the fixedmailbox package. The fixedmailbox.jar bundle contains only the StringMessage and FixedMailbox classes, as it should since WelcomeMailboxActivator was not part of the package when the fixed_mailbox.jar bundle was built.

    But say we now needed to go back and rebuild the fixedmailbox.jar bundle for some reason (i.e. a change to one of the classes in the bundle). When we rebuild the resulting fixedmailbox.jar bundle is now the same as the welcome_mailbox bundle.

    Does anyone think there is an error in the book and the WelcomeMailboxActivator class should have been put in a serarate package? If not, then doesn’t the two similar bundles seem to be a problem?

    I’m looking at this not only from a code viewpoint, but also from a design viewpoint. I would not want to design in this way, would anyone else?

    Neil if you’re still around, can you expalin?

    Can anyone else?

    Thanx!

  99. Mike:

    rt,

    Another very simple reason why your bundle .jar is empty is because you have not built your project, either because you just have not built it or your source code has errors!

    No build, no .class files; no .class files, no bundle!

    I know there is am OSGi forum on this site, but if questions are raised here I see no reason to answer them here.

    Mike

  100. Eng Sing:

    Hi Neil,

    First of all, thanks for making a book on OSGI and make it freely available to everyone.

    I like the way you write this topic, particularly on the introduction where you describe the most difficult challenge in any engineering projects is complexity.

    In fact, Java suffers the same, where the core remains simple, but on the other hand, Java EE is pretty complex. So, for you to write a topic on OSGI using a simplistic approach is remarkable.

    Keep it up!

  101. Alex Dvoretsky:

    Hi Nell, can you provide the draft in .epub format too? Or at least as source files (TeX)?

    TIA

  102. JVerstry:

    Great draft, really clear… Just make sure you include a section explaining how to start OSGi from scratch !!!

  103. Eddie:

    good book

  104. Behrang Saeedzadeh:

    In Figure 1.5 at page 14, the EJB class loader and the WAR class loader are shown as siblings, however the WAR class loader should be a child of the EJB class loader, as all EJB classes are visible to WAR classes.

  105. Behrang Saeedzadeh:

    Thanks for the great book by the way!

  106. Ana Rossello:

    Hi!

    I´m just getting started with OSGi and I am reading your book.

    I think I found a mistake in page 8 in the numbered list, point 5, I think it should say fails instead of files:

    1. The extension class loader files to find the class, so the application class loader tries to find it, looking first in log4j.jar.
  107. Timo:

    I’m getting started with OSGi and I am reading your book. It’s increadible useful and the best I source for an introduction I came across yet.

    That’s either it’s the best source available or I am just no good at finding something better. Most likely it’s a mix of both of it (though I stopped searching after I found the book…)

  108. Nathan Moos:

    Great book. Once it’s finished, I’ll be looking forward to seeing it completed!

  109. Philipp Kursawe:

    Is there a newer version of this book available as pdf? This one is from January last year. I am particular interested in the Configuration Admin and how it works with DS and the MetaType service.

  110. Wang Feng:

    Just finish reading first 3 chapter. It’s a very good book. Thank you Neil!

Leave a comment