aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes What is OSGi? Is it appliable to any Java application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "What is OSGi? Is it appliable to any Java application?" Watch "What is OSGi? Is it appliable to any Java application?" New topic
Author

What is OSGi? Is it appliable to any Java application?

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
Hi,

What is OSGi and what are its advantages?


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1824
    
    7

If you're unfamiliar with OSGi, this article on TSS might be worth checking out.

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Kirk Knoernschild
author
Ranch Hand

Joined: Apr 16, 2012
Posts: 41
OSGi is the dynamic module system for Java. In OSGi parlance, a module is known as a bundle. OSGi provides a framework for managing bundles that are packaged as regular Java JAR files with an accompanying manifest. The manifest contains important metadata that describes the bundles and its dependencies to the OSGi framework. However, OSGi is not a prerequisite for using the modularity patterns. OSGi simply provides a runtime environment that enables and enforces modularity on the Java platform. OSGi offers the following capabilities:
  • Modularity: Enables and enforces a modular approach to architecture on the Java platform.
  • Versioning: Supports multiple versions of the same software module deployed within the same Java Virtual Machine (JVM) instance.
  • Hot deployments: Permits modules to be deployed and updated within a running system without restarting the application or the JVM.
  • Encapsulation: Allows modules to hide their implementation details from consuming modules.
  • Service orientation: Encourages service-oriented design principles in a more granular level within the JVM. To accomplish this, OSGi uses ╬╝Services.
  • Dependency management: Requires explicit declaration of dependencies between modules.


  • You can read all about OSGi at the OSGi Alliance website.

    OSGi is certainly applicable for any type of application, especially if any of the above advantages interest you. One of the greatest advantages of OSGi is that it enforces modularity. To use OSGi today, you have to embed an OSGi framework, such as Equinox or Apache Felix, into your application. For Java web apps that run on an app server, this can be a bit challenging if the app server itself doesn't do it for you since OSGi uses a different classloader model (i.e. peer) than most app servers (i.e., hierarchical). However, almost all app server platforms are incorporating OSGi and exposing it to the developer and allow you to take advantage of OSGi.

    The beauty of the Java Application Architecture book is that it shows you how to develop modular software even if you cannot use OSGi today (i.e., lack of platform support) so that in the future, you can easily take advantage of the benefits of OSGi (or even Jigsaw in Java 8) when it's available. So the book allows you to start developing modular software today in anticipation of platform support for modularity in the future. Part 3 in the book shows you exactly how easy this can be.

    Visit the book's website at modularity.kirkk.com where you can review all 18 patterns and download an excerpt of the book. There is also a mobile web application available that you can take with you wherever you go.
    Gary Marshall
    Ranch Hand

    Joined: Feb 19, 2007
    Posts: 121
    Talk about timing.

    I am being presented a job opportunity where I would learn and develop using OSGI. The project is being defined to me as a two-year long project, with, thus far, "possible" additional opportunities; the additional work mostly dependent upon the success of this two-year project.

    Now I am a complete newbie at OSGI. And while I always welcome the opportunity to learn new technologies, I have to admit I have a little bit of fear over this one. That is because I'm not sure where this OSGI thing is going.

    See, I had not heard of OSGI until my first interview with this project manager a couple of weeks ago. The project manager stated to me that the project involves OSGI, JBoss and Postgres (sp?). He wanted me to know further that there are no Java EE frameworks involved here. As I stated, this is a two year long project. So my fear is that if I go to work on this project for two years and learn all there is to know about this platform, then if I find that I have to put myself back on the job market, will my skill set still be marketable? For two years I will not be working with Java EE, or Spring or Struts, or JPA and Hibernate, the technologies that most java shops are looking for on a job candidate's resume. Will I be able to find another decent java developer position if I work on OSGI for two years? This is the question that keeps nagging me concerning this opportunity.

    I certainly welcome and thank you all for your professional perspective concerning my opportunity and my concern.
    Thank you
    Gary


    G
    Jelle Klap
    Bartender

    Joined: Mar 10, 2008
    Posts: 1824
        
        7

    Gary Marshall wrote:
    The project manager stated to me that the project involves OSGI, JBoss and Postgres (sp?). He wanted me to know further that there are no Java EE frameworks involved here.


    How exactly does that work? JBoss pretty much IS a JEE application server, so if they're not planning on using JEE technology I find that a particularly curious choice.
    Further more, if they'll be using Postgres that certainly implies persistence of some kind. I kind of doubt they'll be taking the native SQL approach to that - JPA with a provider like Hibernate or EclipseLink would seem more likely.
    I'm thinking you should probably take the statments made by that project manager with a grain of salt and not worry too much about the negative effects this project might have on the marketability of your skill set.
    Kirk Knoernschild
    author
    Ranch Hand

    Joined: Apr 16, 2012
    Posts: 41
    Gary,

    You have a valid concern. I'd wouldn't be too worried about not using Java EE. I would be worried if they said you won't be using any other Java frameworks. You sure the PM is correct on this? I can't imagine developing a Java application without using some other Java framework. Teams almost always use a combination of several frameworks and OSGi doesn't preclude you from using other frameworks. In fact, Spring DM (now known as Blueprint services) is basically the Spring framework for use in an OSGi environment. And it's fantastic! If you don't have the book, you can still see this in action if you download the excerpt and take a look at the example at the end of Chapter 3 (link below). So, in a nutshell, just because you're using OSGi doesn't mean you can't use other frameworks and I'd be more concerned that the team isn't using other proven frameworks than the fact they're using OSGi.

    Something else to keep in mind...Modularity is coming to the Java platform. Every major app server vendor is building their product atop OSGi and many are exposing it's use for development too. Java 8 (due in 2013) is introducing a new module system called Jigsaw that will supposedly be compatible with OSGi. By the end of 2013, modularity is going to be something that every developer is going to need to know to build Java applications. By using OSGi now, you're gaining a lot of really good experience in designing modular software. And even if you're not using OSGi, the book prepares you for impending platform support for modularity by helping you build modular software on the Java platform right now.

    But like I said, if they aren't planning to use any other framework (Spring, Hibernate, etc.), then I'd question what they're doing in the first place. They should be using at least some other frameworks, I would imagine.

    Visit the book's website at modularity.kirkk.com where you can review all 18 patterns and download an excerpt of the book. There is also a mobile web application available that you can take with you wherever you go.

    --kirk
    Jignesh Patel
    Ranch Hand

    Joined: Nov 03, 2001
    Posts: 626

    Gary,

    The somebody choose OSGI for the project. That means there is a smart architect sitting there who knows importance of modularity. I believe there must be other supporting frameworks will be used on need basis, and project manager may not aware of it.


    And what made you think that learning something new in software industry will reduce job opportunity for you?

    -Jignesh
    Gary Marshall
    Ranch Hand

    Joined: Feb 19, 2007
    Posts: 121

    Thank you all for your time in responding.

    I'm so terribly new at the OSGI thing that its possible I did not understand what the PM was telling me in our first interview. A week ago I asked him again, via email, about using J2EE in the development work - which, I now recall is the development of a "framework" for the modular applications, not the applications themselves. The app development could possibly happen in the future. Here is a snippet of his email response to me:

    "....... I suspect we will be writing some J2EE web apps but right now we are testing that under OSGI Pax-Wicket which departs from the normal J2EE model of doing web app deployment...."

    So there you go. That's what he meant by not using any J2EE frameworks, I guess.

    @Jignesh Patel: What is concerning me is NOT learning something new but rather possibly silo-ing myself into a technology that may or may not be in demand in two years. However thanks to the news from Mr. Knoerschild concerning Java 8 and its relation to OSGI, perhaps I don't need to be concerned about marketability.

    Thanks again
    Gary
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: What is OSGi? Is it appliable to any Java application?