Skip to content

Commit c3577f7

Browse files
authored
Merge pull request #243 from chrisrueger/add-collection-title-to-pagination
Add back enRoute Classic Tutorial on JAR Wrapping
2 parents 28994b6 + cbf219b commit c3577f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1357
-22
lines changed

_book/100-introduction.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
---
2-
title: Guide
3-
layout: default
2+
title: Introduction about OSGi enRoute Classic
3+
layout: prev-next-collection
4+
summary: Is OSGi enRoute for You?
5+
noindex: true
46
---
57

8+
The enRoute Classic section is a collection of content helping to get you started into the OSGi mindset.
9+
10+
<div>
11+
<table>
12+
13+
{% for book in site.book %}{%unless book.noindex%}<tr><td><a href="{{book.url}}">{{book.title}}</a></td><td>{{book.summary}}</td></tr>
14+
{%endunless%}{% endfor %}
15+
16+
</table>
17+
</div>
18+
19+
620
We _strongly_ believe that OSGi's Service Oriented Systems is the best paradigm available today for software development. But we are also frustrated when we see how hard it is for people to cross the chasm to reach that new paradigm. Out of this frustration, the OSGi enRoute project was born.
721

822
This OSGi Alliance initiative is about removing the barriers to adoption. It is about creating an environment where development of applications is almost as easy to get started with as Ruby on Rails applications without loosing the key advantages of OSGi/Java for projects that grow beyond their initial size.
@@ -38,7 +52,7 @@ We're here to prime the pump.
3852

3953
## How to Get Started?
4054

41-
If you're new to OSGi we suggest you follow the [quick start tutorial](200-quick-start.html) and then the more [complete tutorial](220-tutorial-base.html). If you're already into OSGi, you can check out the [data sheets](400-services.html).
55+
If you're new to OSGi we suggest you follow the [tutorials](/book/150-tutorials.html). If you're already into OSGi, you can check out the [services catalog](/book/400-services.html).
4256

43-
[enroute-doc]: https://github.com/osgi/osgi.enroute.site
57+
[enroute-doc]: https://github.com/bndtools/bndtools.github.io/tree/master/_book
4458

_book/150-tutorials.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Tutorials
3-
layout: default
3+
layout: prev-next-collection
4+
summary: List of tutorials.
45
---
56

67
This section is an entry to the hopefully growing collection of tutorials that OSGi enRoute provides. If you want to develop an additional tutorial, please submit a PR.
@@ -86,7 +87,9 @@ The Maven Bnd Repository Plugin provides full bi-drectional access to the local
8687

8788
Quite often you need to use a dependency (a JAR file) which is not yet an OSGi bundle. To use this dependency in an OSGi project you need to learn how to _wrap_ a JAR to become a Bundle. Wrapping a JAR means that we need add the required OSGi manifest headers but also _design_ the contents of the bundle. bnd and bndtools provide tooling to make this process relatively simple.
8889

89-
[Go to the JAR Wrapping section](https://bnd.bndtools.org/chapters/390-wrapping.html) of the bnd manual.
90+
[Go to the JAR Wrapping Tutorial](/tutorial_wrap/050-start.html)
91+
92+
Or alternativly [visit the JAR Wrapping section](https://bnd.bndtools.org/chapters/390-wrapping.html) of the bnd manual.
9093

9194
{: style='clear:both;' }
9295

_book/180-examples.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Example Projects
3-
layout: default
3+
layout: prev-next-collection
4+
summary: Some example projects.
45
---
56

67
This section is an entry to the hopefully growing collection of examples that OSGi enRoute provides. If you want to develop an additional example, please submit a PR.

_book/210-doc.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
---
22
title: About OSGi
33
summary: Provides an introduction into OSGi and explains how OSGi enRoute uses OSGi
4-
noindex: true
5-
layout: default
4+
layout: prev-next-collection
65
---
76

87
Provides an introduction into OSGi and explains how OSGi enRoute uses OSGi.

_book/400-services.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Service Catalog
3-
layout: default
3+
layout: prev-next-collection
4+
summary: Services available in OSGi.
45
---
56

67
This is the OSGi enRoute Base Profile service catalog. The following services are currently available and documented.

_book/450-osgi-specs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: OSGi Specifications
33
summary: Provides an overview of the OSGi Specifications with links
4+
layout: prev-next-collection
45
---
56

67
OSGi technology is a set of

_book/680-appnotes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: App Notes
3-
layout: default
3+
layout: prev-next-collection
4+
summary: Application notes are documenting a design or a tool in a way that is useful for people that implement application.
45
---
56
Application notes are documenting a design or a tool in a way that is useful for people that implement application. They often show how to do things with the whole system.
67

_book/700-links.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Where to Find Stuff
3-
layout: default
3+
layout: prev-next-collection
4+
summary: List of interesting links
45
---
56

67
## Where to Find Stuff

_book/710-videos.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Videos
3-
layout: default
3+
layout: prev-next-collection
4+
summary: Some video tutorials or presentations.
45
---
56

67
<div>

_book/800-known-issues.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

_book/900-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Frequently Asked Questions
3-
layout: default
3+
layout: prev-next-collection
44
---
55

66

_config.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ collections:
2828
output: true
2929
doc:
3030
output: true
31+
faq:
32+
output: true
3133
tutorial_base:
3234
output: true
3335
tutorial_rsa:
@@ -38,6 +40,10 @@ collections:
3840
output: true
3941
tutorial_maven:
4042
output: true
43+
tutorial_wrap:
44+
output: true
45+
videos:
46+
output: true
4147

4248
defaults:
4349
-

_data/sidebar.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ nav:
4343
external: true
4444
- title: enRoute classic
4545
links:
46+
- name: Introduction
47+
url: "/book/100-introduction.html"
4648
- name: About OSGi
4749
url: "/book/210-doc.html"
4850
urlprefix: "/doc/"

_faq/class-not-found-exception.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: What is NoClassDefFoundError?
3+
summary: Explains the consequences of the class loading architecture
4+
---
5+
6+
A very common question for new users of OSGi is as follows:
7+
8+
> “My bundle throws a NoClassDefFoundError on 'org.example.FooBar' even
9+
> though FooBar is on the classpath. What's going on??”
10+
11+
In OSGi, it doesn't even make sense to say that something is “on the
12+
classpath” because **there is no global classpath in OSGi**. Instead,
13+
each bundle has its own isolated class loader. The loader inside each
14+
bundle can *only* load classes that are either inside the bundle, or
15+
*explicitly imported* from another bundle.
16+
17+
The preferred way to import from other bundles is to use
18+
`Import-Package`. You must import **every** package used by your bundle,
19+
with the exception of packages that are already part of your bundle and
20+
packages that begin with “java.” (for example `java.net`, `java.util`
21+
etc... these packages are treated specially by the JRE).
22+
23+
If this sounds like a lot of work, don't worry! Many developers use
24+
[Bnd] to build their bundles, or a tool based on it such as [Bndtools]
25+
or [Maven Bundle Plugin]. All of these tools automatically generate the
26+
`Import-Package` header for your bundle, by inspecting all of the
27+
dependencies in your class files.
28+
29+
Note that if your bundle imports a package, there must be another bundle
30+
installed in the OSGi Framework that exports the same package using the
31+
`Export-Package` header. At runtime the Framework matches each import
32+
with a corresponding export. If it can't find a matching export then
33+
your bundle will fail to resolve. This happens early in the lifecycle of
34+
a bundle, before any code is loaded, so as long as your imports are
35+
correct then you should never see errors like ClassNotFoundException or
36+
NoClassDefFoundError.
37+
38+
### Differences between ClassNotFoundException and NoClassDefFoundError
39+
40+
Both the `ClassNotFoundException` and `NoClassDefFoundError` may be seen
41+
when using Java libraries that try and load classes reflectively. This
42+
typically involves a Java library using `Class.forName` to load a class.
43+
44+
#### ClassNotFoundException
45+
46+
A `ClassNotFoundException` is generated by a call to `Class.forName()`
47+
with a `String` that contains a class not available on the bundle's
48+
class path. Unless the bundle has a
49+
[Import-Package](Import-Package "wikilink") or
50+
[Require-Bundle](Require-Bundle "wikilink") for the package in question
51+
(or a [DynamicImport-Package](DynamicImport-Package "wikilink")), the
52+
runtime will not be able to find the appropriate `.class`.
53+
54+
#### NoClassDefFoundError
55+
56+
A `NoClassDefFoundError` is generated when a class has been found, but
57+
one of its dependencies (typically, that involved in a static
58+
initialiser block) cannot be. For example, if class `A` refers to `B`,
59+
and `B` refers to `C`, then a client looking up A may work, but B (or C)
60+
could be missing. This would generate the error message
61+
`NoClassDefFoundError: A`.
62+
63+
[Bndtools]: http://bndtools.org
64+
[Maven Bundle Plugin]: http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html
65+
[Bnd]: http://bnd.bndtools.org

_faq/ds-inheritance.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Why does DS Annotations not support inheritance?
3+
summary: It seems logical to inherit the annotations for the bind methods and activate from a super class. This FAQ explains why it is not officially supported so far.
4+
---
5+
6+
Felix Meschberger answered this question very eloquently on a question on the Bndtools list:
7+
8+
> You might be pleased to hear that at the Apache Felix project we once had this feature in our annotations. From that we tried to standardize it actually.
9+
>
10+
> The problem, though, is that we get a nasty coupling issue here between two implementation classes across bundle boundaries and we cannot express this dependency properly using Import-Package or Require-Capability headers.
11+
>
12+
> Some problems springing to mind:
13+
>
14+
> Generally you want to make bind/unbind methods private. Would it be ok for SCR to call the private bind method on the base class ?(It can technically be done, but would it be ok).
15+
> What if we have private methods but the implementor decides to change the name of the private methods — after all they are private and not part of the API surface. The consumer will fail as the bind/unbind methods are listed in the descriptors provided by/for the extension class and they still name the old method names.
16+
> If we don’t support private method names for that we would require these bind/unbind methods to be protected or public. And thus we force implementation-detail methods to become part of the API. Not very nice IMHO.
17+
Note: package private methods don’t work as two different bundles should not share the same package with different contents.
18+
>
19+
> We argued back then that it would be ok-ish to have such inheritance within a single bundle but came to the conclusion that this limitation, the explanations around it, etc. would not be worth the effort. So we dropped the feature again from the roadmap.
20+
21+
This all said, if you still want to try to shoot yourself in the foot: Bnd already supports this with -dsannotations-options: inherit.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
title: Unable to resolve org.example.foo.api version=1.0.0.201603042130 missing requirement false
3+
summary: When the resolver fails to resolve and says the missing requirement is false.
4+
---
5+
6+
The resolve error indicates that the only exporter is the API project but that this project says it should not resolve because in enRoute we highly recommend to include the API package in the provider so a resolution does not just consist of APIs without implementations. If you look in your bnd.bnd file in the org.example.foo.api project then you'll see the following lines:
7+
8+
Require-Capability: \
9+
compile-only
10+
11+
This is a requirement that cannot be resolved. Adding the package to the provider will then make the provider the preferred exporter.
12+
13+
This model (exporting the API from the provider) is explained extensively in the [Base Tutorial][1]. For a more information you can also look in the [bnd manual about versioning][2].
14+
15+
You should there have some org.example.foo.provider bundle that provides the implementation and this should export the API. Exporting it is simple, just drag the package and drop it on the Contents Export list of the provider's `bnd.bnd` file. See the Base tutorial for details.
16+
17+
That said, in the OSGi we now have implementation capabilities and the next OSGi enRoute setup will use those. It is slightly cleaner but also a bit less practical. For now, just export the API from the provider it is the last amount of trouble.
18+
19+
20+
[1]: /tutorial_base/300-api.html
21+
[2]: http://bnd.bndtools.org/chapters/170-versioning.html

_faq/unable-to-resolve.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Can't Resolve!
3+
summary: What to do when you cannot resolve a bndrun file
4+
---
5+
6+
If you run in the problem that you can't resolve and have a problem understanding, here are some tips.
7+
8+
First, try to resolve ONLY the provider (i.e. is the only requirement in the bndrun file) and see what it says. Likely the provider has a problem. You could also add the bundle that is reported as the last item in the diagnostic information from the resolver in the blacklist in your bndrun file. For example:
9+
10+
-runblacklist.eval: \
11+
osgi.identity;filter:=‘(osgi.identity=com.example.foo.provider)
12+
13+
The resolver will then probably provide the next thing it cannot resolve. Which unfortunately is often quite logical and simple :-(
14+
15+
The resolver is pretty bad in telling what the culprit is. The reason is that it uses back-tracking. So the diagnostics are basically the last thing that was tried.

_faq/what-does-osgi-stand-for.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: What does OSGi stand for?
3+
summary: Is it an acronym or a name?
4+
---
5+
6+
It doesn't stand for anything any more, it's just OSGi. Note the
7+
lower-case i when writing the name.
8+
9+

_tutorial_wrap/050-start.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: JAR Wrapping Tutorial
3+
layout: prev-next-collection
4+
noindex: true
5+
---
6+
7+
This tutorial is under review. Feedback appreciated (PRs on [Github](https://github.com/bndtools/bndtools.github.io/tree/master/_tutorial_wrap))
8+
{: .note }
9+
10+
## Why to wrap JAR files?
11+
12+
OSGi developers face a challenge when using third-party libraries that are not supplied as OSGi bundles. Though an increasing number of libraries are available from their original sources as OSGi bundles, and a large number are available as wrapped OSGi bundles from external repositories, it is still sometimes necessary to build such a wrapper ourselves. This tutorial details an approach to OSGi bundle production using bnd/bndtools/gradle.
13+
14+
## What you learn in this tutorial.
15+
16+
In this quick start we learn how to _wrap_ a JAR to become a Bundle. Wrapping a JAR means that we need add the required OSGi manifest headers but also _design_ the contents of the bundle. Modularity is not about fences, modularity is about what you put inside those fences and what passages you allow. The bnd tool provides an overwhelming amount of instructions and features to create the Bundle you want; this tutorial tries to shine light on what forces are in play and what tools are available.
17+
18+
This tutorial teaches the wrapping from the perspective of a Bndtools user. For any command line zealots this should not be too hard to map to `vi` since all we do is write a `bnd.bnd` file in Bndtools, which is also usable in for example Maven. The key advantage of Bndtools is that it shows you the missing packages interactively. If you want to stay on the command line, then you could take a look at [bnd Wrapping](https://bnd.bndtools.org/chapters/390-wrapping.html).
19+
20+
In the coming chapters it is assumed you have a workspace ready. If you've no clue what we're talking about suggest you follow the [Quick Start] tutorial first.
21+
22+
**A disclaimer.** This wrapping tutorial is about learning to use wrapping bundles inside the OSGi enRoute tool chain, it is not about learning Java, Git, nor Eclipse. It is assumed that you have basic experience with these tools and that you have at least followed the [Quick Start] tutorial.
23+
24+
If you're just interested in the end result, you can look at the (archived) [osgi.enroute.examples.wrapping.dom4j.adapter] project.
25+
26+
If you have any questions about this wrapping tutorial, please discuss them in the [Forum].
27+
28+
## Sections
29+
30+
<div>
31+
<table>
32+
<colgroup>
33+
<col style="width:50%">
34+
<col style="width:50%">
35+
</colgroup>
36+
<tbody>
37+
{% for qs in site.tutorial_wrap %}{%unless qs.noindex%}<tr><td><a href="{{qs.url}}">{{qs.title}}</a></td><td>{{qs.summary}}</td></tr>
38+
{%endunless%}{% endfor %}
39+
</tbody>
40+
</table>
41+
</div>
42+
43+
44+
## End
45+
46+
So, you've finished this wrapping tutorial! What's next?
47+
48+
Well, first, since we're still in beta, we'd love feedback. Our most favorite feedback is a pull request on the documentation. We, and others like you, highly appreciate these kind of contributions.
49+
50+
If you've become interested in what bnd can do for you, then you could look at the [wrapping with bnd] chapter in the bnd manual.
51+
52+
However, running into real problems is the best way to learn a technology. If you run into problems, use the [Forum] to ask questions and get answers.
53+
54+
[forum]: https://bnd.discourse.group/
55+
[Quick Start]: /qs/050-start
56+
[wrapping with bnd]: https://bnd.bndtools.org/chapters/390-wrapping.html
57+
[-conditionalpackage]: https://bnd.bndtools.org/instructions/conditionalpackage.html
58+
[133 Service Loader Mediator Specification]: https://blog.osgi.org/2013/02/javautilserviceloader-in-osgi.html
59+
[semanticaly versioned]: https://bnd.bndtools.org/chapters/170-versioning.html
60+
[135.3 osgi.contract Namespace]: https://blog.osgi.org/2013/08/osgi-contracts-wonkish.html
61+
[BSD style license]: https://dom4j.sourceforge.net/dom4j-1.6.1/license.html
62+
[supernodes of small worlds]: https://en.wikipedia.org/wiki/Small-world_network
63+
[OSGiSemVer]: https://www.osgi.org/wp-content/uploads/SemanticVersioning.pdf
64+
[osgi.enroute.examples.wrapping.dom4j.adapter]: https://github.com/osgi/osgi.enroute.examples/tree/485624f6cb66df91f668d6eb9a5c8e491312c8c4/osgi.enroute.examples.wrapping.dom4j.adapter

0 commit comments

Comments
 (0)