What is the difference between OSGI Architecture and Maven multi module project?
I am trying to understand OSGI, as per definition it says
OSGi technology is a set of specifications that define a dynamic
component system for Java. These specifications enable a development
model where an application is composed of several components which are
packaged in bundles. Components communicate locally and across the
network through services.
But I am confused here as the same dynamic module creation can be done with Maven multi module project structure too. So my question is how OSGI architecture is different from Maven multi module projects.
java maven osgi apache-felix
add a comment |
I am trying to understand OSGI, as per definition it says
OSGi technology is a set of specifications that define a dynamic
component system for Java. These specifications enable a development
model where an application is composed of several components which are
packaged in bundles. Components communicate locally and across the
network through services.
But I am confused here as the same dynamic module creation can be done with Maven multi module project structure too. So my question is how OSGI architecture is different from Maven multi module projects.
java maven osgi apache-felix
2
OSGi is runtime whereas multi modules are build time...and organising code and modules..
– khmarbaise
Nov 15 '18 at 11:24
@khmarbaise, thanks for the response. Does that mean if I create a simple maven multi module project and create its bundle and deploy in Apache Felix, will it still be following OSGI or I need something special to do in my project structure also?
– Balwinder Singh
Nov 15 '18 at 11:52
Of course you need to be sure your bundle definitions etc. are or and your dependencies are correct (need to look into felix part) in particular related to MANIFEST.MF based dependencies?...
– khmarbaise
Nov 15 '18 at 16:31
add a comment |
I am trying to understand OSGI, as per definition it says
OSGi technology is a set of specifications that define a dynamic
component system for Java. These specifications enable a development
model where an application is composed of several components which are
packaged in bundles. Components communicate locally and across the
network through services.
But I am confused here as the same dynamic module creation can be done with Maven multi module project structure too. So my question is how OSGI architecture is different from Maven multi module projects.
java maven osgi apache-felix
I am trying to understand OSGI, as per definition it says
OSGi technology is a set of specifications that define a dynamic
component system for Java. These specifications enable a development
model where an application is composed of several components which are
packaged in bundles. Components communicate locally and across the
network through services.
But I am confused here as the same dynamic module creation can be done with Maven multi module project structure too. So my question is how OSGI architecture is different from Maven multi module projects.
java maven osgi apache-felix
java maven osgi apache-felix
edited Nov 15 '18 at 11:18
jonrsharpe
78.3k11109218
78.3k11109218
asked Nov 15 '18 at 11:11
Balwinder SinghBalwinder Singh
4516
4516
2
OSGi is runtime whereas multi modules are build time...and organising code and modules..
– khmarbaise
Nov 15 '18 at 11:24
@khmarbaise, thanks for the response. Does that mean if I create a simple maven multi module project and create its bundle and deploy in Apache Felix, will it still be following OSGI or I need something special to do in my project structure also?
– Balwinder Singh
Nov 15 '18 at 11:52
Of course you need to be sure your bundle definitions etc. are or and your dependencies are correct (need to look into felix part) in particular related to MANIFEST.MF based dependencies?...
– khmarbaise
Nov 15 '18 at 16:31
add a comment |
2
OSGi is runtime whereas multi modules are build time...and organising code and modules..
– khmarbaise
Nov 15 '18 at 11:24
@khmarbaise, thanks for the response. Does that mean if I create a simple maven multi module project and create its bundle and deploy in Apache Felix, will it still be following OSGI or I need something special to do in my project structure also?
– Balwinder Singh
Nov 15 '18 at 11:52
Of course you need to be sure your bundle definitions etc. are or and your dependencies are correct (need to look into felix part) in particular related to MANIFEST.MF based dependencies?...
– khmarbaise
Nov 15 '18 at 16:31
2
2
OSGi is runtime whereas multi modules are build time...and organising code and modules..
– khmarbaise
Nov 15 '18 at 11:24
OSGi is runtime whereas multi modules are build time...and organising code and modules..
– khmarbaise
Nov 15 '18 at 11:24
@khmarbaise, thanks for the response. Does that mean if I create a simple maven multi module project and create its bundle and deploy in Apache Felix, will it still be following OSGI or I need something special to do in my project structure also?
– Balwinder Singh
Nov 15 '18 at 11:52
@khmarbaise, thanks for the response. Does that mean if I create a simple maven multi module project and create its bundle and deploy in Apache Felix, will it still be following OSGI or I need something special to do in my project structure also?
– Balwinder Singh
Nov 15 '18 at 11:52
Of course you need to be sure your bundle definitions etc. are or and your dependencies are correct (need to look into felix part) in particular related to MANIFEST.MF based dependencies?...
– khmarbaise
Nov 15 '18 at 16:31
Of course you need to be sure your bundle definitions etc. are or and your dependencies are correct (need to look into felix part) in particular related to MANIFEST.MF based dependencies?...
– khmarbaise
Nov 15 '18 at 16:31
add a comment |
1 Answer
1
active
oldest
votes
The main difference between maven and OSGi is how modules depend on each other.
In maven a module depends on a list of other maven modules. This is a simple model but often leads into problems in transitive dependencies. If the same module appears in the dependency tree with different versions maven simply chooses the highest version. This is a good guess but does not always work. Another typical case is having two modules with the same packages but different names (split packages).
In OSGi dependencies are expressed as requirements and capabilities. The OSGi resolver is then used at assembly time of your application to find a closure over the candidate bundles (repository) that satisfy a set of initial requirements. Most commonly these initial reuirements are your top level user bundles. The resolver then determines a closure over the bundles that solves the requiremnts. So the obvious advantage is that when using the resolver you have a high confidence that the set of bundles you run will actually work. In plain java you simply run some jars together and hope for the best.
The most common requirement is on a package in a version range. Another bundle may offer the package in a suitable version. It is then a candidate for the resolver.
Luckily at build time creating bundles from maven builds is easy. You use the bnd-maven-plugin or maven-bundle-plugin. It typically figures out the requirements and capabilities on its own.
In OSGi you always try to develop against APIs (API-jars) instead of runtime jars. This makes your code more loosely coupled.
At assembly time in OSGi you need to provide a set of bundles to form the repository for the resolver to work on. This is often done using a pom. So actually this is not too different from plain maven. The main difference is that the resolver gives you a validates minimal set of bundles to run while a typical mavne build simply gives you a set of jars that represent all transitive dependencies.
As an example see the new enroute microservice example. It shows how to create the individual bundles and how to assemble them into a running application. See also the tutorial for the example.
Thanks Christian, great explanation. BTW I am following your Karaf-Tutorials to understand OSGi. Thanks for these awesome tutorials.
– Balwinder Singh
Nov 18 '18 at 15:56
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53318178%2fwhat-is-the-difference-between-osgi-architecture-and-maven-multi-module-project%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The main difference between maven and OSGi is how modules depend on each other.
In maven a module depends on a list of other maven modules. This is a simple model but often leads into problems in transitive dependencies. If the same module appears in the dependency tree with different versions maven simply chooses the highest version. This is a good guess but does not always work. Another typical case is having two modules with the same packages but different names (split packages).
In OSGi dependencies are expressed as requirements and capabilities. The OSGi resolver is then used at assembly time of your application to find a closure over the candidate bundles (repository) that satisfy a set of initial requirements. Most commonly these initial reuirements are your top level user bundles. The resolver then determines a closure over the bundles that solves the requiremnts. So the obvious advantage is that when using the resolver you have a high confidence that the set of bundles you run will actually work. In plain java you simply run some jars together and hope for the best.
The most common requirement is on a package in a version range. Another bundle may offer the package in a suitable version. It is then a candidate for the resolver.
Luckily at build time creating bundles from maven builds is easy. You use the bnd-maven-plugin or maven-bundle-plugin. It typically figures out the requirements and capabilities on its own.
In OSGi you always try to develop against APIs (API-jars) instead of runtime jars. This makes your code more loosely coupled.
At assembly time in OSGi you need to provide a set of bundles to form the repository for the resolver to work on. This is often done using a pom. So actually this is not too different from plain maven. The main difference is that the resolver gives you a validates minimal set of bundles to run while a typical mavne build simply gives you a set of jars that represent all transitive dependencies.
As an example see the new enroute microservice example. It shows how to create the individual bundles and how to assemble them into a running application. See also the tutorial for the example.
Thanks Christian, great explanation. BTW I am following your Karaf-Tutorials to understand OSGi. Thanks for these awesome tutorials.
– Balwinder Singh
Nov 18 '18 at 15:56
add a comment |
The main difference between maven and OSGi is how modules depend on each other.
In maven a module depends on a list of other maven modules. This is a simple model but often leads into problems in transitive dependencies. If the same module appears in the dependency tree with different versions maven simply chooses the highest version. This is a good guess but does not always work. Another typical case is having two modules with the same packages but different names (split packages).
In OSGi dependencies are expressed as requirements and capabilities. The OSGi resolver is then used at assembly time of your application to find a closure over the candidate bundles (repository) that satisfy a set of initial requirements. Most commonly these initial reuirements are your top level user bundles. The resolver then determines a closure over the bundles that solves the requiremnts. So the obvious advantage is that when using the resolver you have a high confidence that the set of bundles you run will actually work. In plain java you simply run some jars together and hope for the best.
The most common requirement is on a package in a version range. Another bundle may offer the package in a suitable version. It is then a candidate for the resolver.
Luckily at build time creating bundles from maven builds is easy. You use the bnd-maven-plugin or maven-bundle-plugin. It typically figures out the requirements and capabilities on its own.
In OSGi you always try to develop against APIs (API-jars) instead of runtime jars. This makes your code more loosely coupled.
At assembly time in OSGi you need to provide a set of bundles to form the repository for the resolver to work on. This is often done using a pom. So actually this is not too different from plain maven. The main difference is that the resolver gives you a validates minimal set of bundles to run while a typical mavne build simply gives you a set of jars that represent all transitive dependencies.
As an example see the new enroute microservice example. It shows how to create the individual bundles and how to assemble them into a running application. See also the tutorial for the example.
Thanks Christian, great explanation. BTW I am following your Karaf-Tutorials to understand OSGi. Thanks for these awesome tutorials.
– Balwinder Singh
Nov 18 '18 at 15:56
add a comment |
The main difference between maven and OSGi is how modules depend on each other.
In maven a module depends on a list of other maven modules. This is a simple model but often leads into problems in transitive dependencies. If the same module appears in the dependency tree with different versions maven simply chooses the highest version. This is a good guess but does not always work. Another typical case is having two modules with the same packages but different names (split packages).
In OSGi dependencies are expressed as requirements and capabilities. The OSGi resolver is then used at assembly time of your application to find a closure over the candidate bundles (repository) that satisfy a set of initial requirements. Most commonly these initial reuirements are your top level user bundles. The resolver then determines a closure over the bundles that solves the requiremnts. So the obvious advantage is that when using the resolver you have a high confidence that the set of bundles you run will actually work. In plain java you simply run some jars together and hope for the best.
The most common requirement is on a package in a version range. Another bundle may offer the package in a suitable version. It is then a candidate for the resolver.
Luckily at build time creating bundles from maven builds is easy. You use the bnd-maven-plugin or maven-bundle-plugin. It typically figures out the requirements and capabilities on its own.
In OSGi you always try to develop against APIs (API-jars) instead of runtime jars. This makes your code more loosely coupled.
At assembly time in OSGi you need to provide a set of bundles to form the repository for the resolver to work on. This is often done using a pom. So actually this is not too different from plain maven. The main difference is that the resolver gives you a validates minimal set of bundles to run while a typical mavne build simply gives you a set of jars that represent all transitive dependencies.
As an example see the new enroute microservice example. It shows how to create the individual bundles and how to assemble them into a running application. See also the tutorial for the example.
The main difference between maven and OSGi is how modules depend on each other.
In maven a module depends on a list of other maven modules. This is a simple model but often leads into problems in transitive dependencies. If the same module appears in the dependency tree with different versions maven simply chooses the highest version. This is a good guess but does not always work. Another typical case is having two modules with the same packages but different names (split packages).
In OSGi dependencies are expressed as requirements and capabilities. The OSGi resolver is then used at assembly time of your application to find a closure over the candidate bundles (repository) that satisfy a set of initial requirements. Most commonly these initial reuirements are your top level user bundles. The resolver then determines a closure over the bundles that solves the requiremnts. So the obvious advantage is that when using the resolver you have a high confidence that the set of bundles you run will actually work. In plain java you simply run some jars together and hope for the best.
The most common requirement is on a package in a version range. Another bundle may offer the package in a suitable version. It is then a candidate for the resolver.
Luckily at build time creating bundles from maven builds is easy. You use the bnd-maven-plugin or maven-bundle-plugin. It typically figures out the requirements and capabilities on its own.
In OSGi you always try to develop against APIs (API-jars) instead of runtime jars. This makes your code more loosely coupled.
At assembly time in OSGi you need to provide a set of bundles to form the repository for the resolver to work on. This is often done using a pom. So actually this is not too different from plain maven. The main difference is that the resolver gives you a validates minimal set of bundles to run while a typical mavne build simply gives you a set of jars that represent all transitive dependencies.
As an example see the new enroute microservice example. It shows how to create the individual bundles and how to assemble them into a running application. See also the tutorial for the example.
answered Nov 18 '18 at 7:43
Christian SchneiderChristian Schneider
15.7k12447
15.7k12447
Thanks Christian, great explanation. BTW I am following your Karaf-Tutorials to understand OSGi. Thanks for these awesome tutorials.
– Balwinder Singh
Nov 18 '18 at 15:56
add a comment |
Thanks Christian, great explanation. BTW I am following your Karaf-Tutorials to understand OSGi. Thanks for these awesome tutorials.
– Balwinder Singh
Nov 18 '18 at 15:56
Thanks Christian, great explanation. BTW I am following your Karaf-Tutorials to understand OSGi. Thanks for these awesome tutorials.
– Balwinder Singh
Nov 18 '18 at 15:56
Thanks Christian, great explanation. BTW I am following your Karaf-Tutorials to understand OSGi. Thanks for these awesome tutorials.
– Balwinder Singh
Nov 18 '18 at 15:56
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53318178%2fwhat-is-the-difference-between-osgi-architecture-and-maven-multi-module-project%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
OSGi is runtime whereas multi modules are build time...and organising code and modules..
– khmarbaise
Nov 15 '18 at 11:24
@khmarbaise, thanks for the response. Does that mean if I create a simple maven multi module project and create its bundle and deploy in Apache Felix, will it still be following OSGI or I need something special to do in my project structure also?
– Balwinder Singh
Nov 15 '18 at 11:52
Of course you need to be sure your bundle definitions etc. are or and your dependencies are correct (need to look into felix part) in particular related to MANIFEST.MF based dependencies?...
– khmarbaise
Nov 15 '18 at 16:31