-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OSGi support for AsciidoctorJ #297
Comments
I have never done anything in OSGi but I know the concepts. Do you know any simple library, example who uses this approach so we can see how it can be done? |
@lordofthejars What I recommend here is an OSGi Arquillian test. It's a perfect use case because we can isolate the environment and ensure the changes function properly without manual testing. It's also a good opportunity / excuse to play with OSGi container support in Arquillian. |
Of course, one example of AsciidoctorJ in use in OSGi is SlideshowFX. |
@lordofthejars Do you need an example of how to register/use services in OSGi? I'm not sure I understand your request correctly. @mojavelinux Yes, I already had a discussion wirth @twasyl about this topic and SlideshowFX might be a good testbed/client for this feature. Currently, it's use of AsciidoctorJ differs from my view of the strived target solution: SlideshowFX (SFX) uses one single bundle to provide it's own API which uses Asciidoctor internally. That bundle embeds AsciidoctorJ and all required dependencies including JRuby. That is, IMHO, not the preferred general solution we want to provide. It think we should:
I had some spare time yesterday and experimented with it. You can find a first start in my Looks like the JRuby OSGi classes require some assumptions I weren't able to guess. |
I didn't know you are already working on it, so don't worry I do not need any example :) It was to start a PoC about what we mention on issue, but if you are already working then it is not necessary :) Thanks. |
In the next days I will not find the time to continue it. It was more some kind of over-optimistic trial to quick hack a solution. Unfortunately it wasn't as easy as I thought. :( |
Of course, the part that makes asciidoctorj-core a bundle (lefou@35a9106, lefou@d01e2d5) should be already good enough. Feel free to cherry pick. |
I opened PR #328 that makes the asciidoctorj-core JAR a proper OSGi bundle. This is only the first part of the work outlined in this ticket, but I thought I better get that (working) part in, as I don't have the time to continue my experiments for now. |
👍 |
PR #358 adds a OSGi bundle activator which registers a @twasyl could you try it out in SlideshowFX? Instead of embedding the whole Asciidoctor (and JRuby) dependencies, it should be enough to have it as a separate activated bundle and acquire the Asciidoctor service from the service registry. @mojavelinux Do you have any news about some arquillian-based infrastructure to test the bundle? |
I just tried again to do an arquillian integration test today with felix. |
I continued to test but stumbled over an error in jbosgi in https://github.com/jbosgi/jbosgi-metadata/blob/master/src/main/java/org/jboss/osgi/metadata/ManifestBuilder.java#L101 : I've just seen on Github that this issue was resolved .... TODAY! |
If the |
Hmm, the Import-Package is not very long, compared to some other OSGi bundles I've seen. What I don't understand, why do they trim the lines at all? OSGi requires a max lines length of 80 chars, longer lines continue on the next line with a leading space. The gradle build creates exactly such a manifest. |
Could it be, that you execute under Windows (line.separater = '\r\n') but the Manifest files contains linux newlines ('\n')? |
Yes, I'm on Windows. |
Ok, now I understand better. You could add some junk import as a workaround, e.g. "org.slf4j;resolution:=optional". |
I got to the point where JRuby does not find the Asciidoctor gem :) |
I'll try to prepare a PR for your branch tomorrow, maybe better that way around. |
I tried your branch and made some changes, but had no success yet. :-( Where can I find some OSGi-specific docs for Arquillian? |
As a follow up to #293 and #294, we came to the conclusion that it would be nice to have better support for running AsciidoctorJ in OSGi environments.
Currently, the bundle using the Asciidoctor API needs to set it up including knowing all the details (e.g. setup of JRuby and it's gems, classloading, ...). If more than one bundle want to do this, we end up having lots of Asciidoctor (and JRuby) instances in the same JVM, which is not so good. The proper OSGi way would be to register a service into the OSGi registry that covers the Asciidoctor API. Consumers do not need to setup Asciidoctor themselves but instead consume the service from the OSGi registry. Provided that such a service exists, classloading, versioning, bootstrapping and such things would no longer be an issue.
What's needed for this:
Asciidoctor
interface or something elseThe text was updated successfully, but these errors were encountered: