What does OSGi solve?

前端 未结 15 2413
猫巷女王i
猫巷女王i 2020-11-27 08:41

I\'ve read on Wikipedia and other sites about OSGi, but I don\'t really see the big picture. It says that it\'s a component-based platform, and that you can reload modules a

相关标签:
15条回答
  • 2020-11-27 09:16

    I've been doing work with OSGi almost 8 or so years and I have to say that you should consider OSGi only if you have a business need to update, remove, install or replace a component on runtime. This also means that you should have a modular mindset and understanding what modularity means. There's some arguments that OSGi is lightweight - yes, that is true but there are also some other frameworks that are lightweight and easier to maintain and develop. Same goes to secure java blah blah.

    OSGi requires a solid architecture to be used correctly and it's quite easy to make OSGi-system that could just as easily be a standalone-runnable-jar without any OSGi being involved.

    0 讨论(0)
  • 2020-11-27 09:19
    • You can, analogically speaking, change the motor of your car without turning it off.
    • You can customize complex systems for the customers. See the power of Eclipse.
    • You can reuse entire components. Better than just objects.
    • You use a stable platform to develop component based Applications. The benefits of this are huge.
    • You can build Components with the black box concept. Other components don't need to know about hidden interfaces, them see just the published interfaces.
    • You can use in the same system several equal components, but in different releases, without compromise the application. OSGi solves the Jar Hell problem.
    • With OSGi you develop thinking to architect systems with CBD

    There are a lot of benefits (I reminded just these now), available for everyone who uses Java.

    0 讨论(0)
  • 2020-11-27 09:20

    edited for clarity. OSGi page gave a better simple answer than mine

    A simple answer: An OSGi Service Platform provides a standardized, component-oriented computing environment for cooperating networked services. This architecture significantly reduces the overall complexity of building, maintaining and deploying applications. The OSGi Service Platform provides the functions to change the composition dynamically on the device of a variety of networks, without requiring a restarts.

    In a single application structure, say the Eclipse IDE, it's not a big deal to restart when you install a new plugin. Using the OSGi implementation completely, you should be able to add plugins at runtime, get the new functionality, but not have to restart eclipse at all.

    Again, not a big deal for every day, small application use.

    But, when you start to look at multi-computer, distributed application frameworks, that's where it starts to get interesting. When you have to have 100% uptime for critical systems, the capability to hotswap components or add new functionality at runtime is useful. Granted, there are capabilities for doing this now for the most part, but OSGi is trying to bundle everything into a nice little framework with common interfaces.

    Does OSGi solve common problems, I'm not sure about that. I mean, it can, but the overhead may not be worth it for simpler problems. But it's something to consider when you are starting to deal with larger, networked, applications.

    0 讨论(0)
  • 2020-11-27 09:21

    It is also being used to bring additional portability of middleware and applications on the mobile side. Mobile side is available for WinMo, Symbian, Android for example. As soon as integration with device features occurs, can get fragmented.

    0 讨论(0)
  • 2020-11-27 09:22

    OSGi makes your code throw NoClassDefFoundError and ClassNotFoundException for no apparent reason (most probably because you forgot to export a package in OSGi configuration file); since it has ClassLoaders it can make your class com.example.Foo fail to be cast to com.example.Foo since it's actually two different classes loaded by two different classloaders. It can make your Eclipse boot into an OSGi console after installing an Eclipse plugin.

    For me, OSGi only added complexity (because it added one more mental model for me to grok), added annoyances because of exceptions; I never really needed the dynamicity it "offers". It was intrusive since it required OSGi bundle configuration for all modules; it was definitely not simple (in a larger project).

    Because of my bad experience, I tend to stay away from that monster, thank you very much. I'd rather suffer from jar dependency hell, since that's way way more easily understandable than the classloader hell OSGi introduces.

    0 讨论(0)
  • 2020-11-27 09:26

    Others have already outlined the benefits in detail, I hereby explain the practical usecases I have either seen or used OSGi.

    1. In one of our application, we have event based flow and flow is defined in plugins based on OSGi platform so tomorrow if some client wants different/additional flow then he just have to deploy one more plugin, configure it from our console and he is done.
    2. It is used for deploying different Store connectors, for example, suppose we already have Oracle DB connector and tomorrow mongodb is required to be connected then write a new connector and deploy it and configure the details through console and again you are done. deployment of connnectors is handled by OSGi plugin framework.
    0 讨论(0)
提交回复
热议问题