Suppose I have one osgi plugin and then I have created one osgi fragment by keeping that plugin as host.
Now I want to use code of osgi fragment in my osgi plugin.
Please help me as I am new in osgi.
Related
I am working on integrating fabric8 for my application and need to add fabric8 kubernetes and openshift client as OSGI bundles. I can get them from following maven repositories as JAR archives.
https://mvnrepository.com/artifact/io.fabric8/openshift-client/2.5.7
https://mvnrepository.com/artifact/io.fabric8/kubernetes-client/2.5.7
And and have to convert them to OSGI bundles to add them to my application since my application is only supporting bundles.
Is there a way to directly get the OSGI bundles of the above jars from maven repository as dependencies without converting them and adding them to a central repository ?
There is no direct way to get OSGI bundles, we have to build it manually.
We can make it available but we have to prepare the bundle and there are plenty of tools available,
For reference:
http://felix.apache.org/documentation/subprojects/apache-felix-maven-bundle-plugin-bnd.html
http://wso2.com/library/tutorials/develop-osgi-bundles-using-maven-bundle-plugin/
The kubernetes-client ships bundles for all its artifacts. The bundles are available on maven central and you can use them just by using the bundle classifier.
For example:
http://repo1.maven.org/maven2/io/fabric8/kubernetes-client/2.6.2/kubernetes-client-2.6.2-bundle.jar
Can OSGi components be deployed to any Container like Tomcat/Websphere/JBoss..etc ? (just as we deploy a WAR file) or do they require any special libraries or OSGi containers to run the OSGi components ?
If you want just expose the "component" classes, you can treat the jar files as .. jar files.
If you consider the OSGi "component" as a "bundle" exposing some services and doing something, then answer is "no". You need an OSGi container (Karaf, WebSphere Liberty, Carbon, Glassfish, JBoss WildFly ...).
However - as you can see, some application servers provide OSGi support natively.
OSGi components (I guess you mean bundles) require an OSGi framework to run in. So a plain servlet container will not work. Some versions of JBoss provide support for OSGi though.
I am looking to have a dynamic artifactId in my POM file that builds an OSGi bundle. I am trying to deploy two instances of a bundle with a slightly different configurations in the same ServiceMix karaf container.
I am using the BND plugin to create the OSGi bundle, but I don't see a configuration in BND that would allow this.
Has anyone been able to dynamically set a bundle name so you can deploy two versions of the same bundle in a single ServiceMix container?
Thanks.
I'm not sure I follow what you are trying to achieve. But to me it looks a lot like you are in need of the ConfigAdmin Service. With the config Admin service you deploy your cfg in the etc folder of servicemix which is selected to configure a Service. If you want to have multiple instances of one service to be available for every configuration you should look at the ManagedService Factory pattern. It will give you a new Service Instance for every configuration available.
I'm trying to do some "hello world" example with Apache Camel. Just a simple route, deployed as OSGi bundle to Apache Karaf. And it's crazy, too many things to learn at once, Camel itself, integration with spring, integration with OSGi and Karaf...ugh.
I'm trying to follow the idea from here: http://www.andrejkoelewijn.com/wp/2008/10/19/simple-camel-dsl-osgi-bundle-example/.
I've created the bundle, the package with FileRoute.java file, etc, but I can't produce valid manifest.mf file, it's generated by "bundle plugin for maven" - so the POM file is used to generate the manifest file.
What's the problem is this in the manifest file, line with import packages:
Import-Package: com.company.foo.bar.demo;version="0.1",org.apache.ca
mel.builder;version="2.10",org.apache.camel.model;version="2.10",org.
apache.commons.logging
With error: "No available bundle exports package 'org.apache.camel.builder'" (and .model package).
Well, I understand what is the problem, but…How to expose these packages for the bundle?
Next I have there another bundle with Apache Camel context, so I thought that good idea is to expose the packages from there, through "export package", but it doesn't work, the camel bundle can't be build then.
I'm quite lost :( I'd really appreciate help or hint.
Thanks!
If you use Apache Camel 2.10 or better then the Maven archetypes is a good place to start a new Camel project. We have archetypes that can create OSGi based project for either spring-dm or OSGi blueprint. You chose which one you want to use. The project is then ready for OSGi as it setup a maven plugin that generated the needed osgi stuff for you. Only in more advanced cases you would need to tweak this plugin.
See details at: http://camel.apache.org/camel-maven-archetypes.html
If you use Maven 3.0.x then its much easier as you can just type
mvn archetype:generate
Then it runs in interactive mode, then type camel to filter only camel archetypes.
And then select the number for the archetype. eg for example the spring-dm to use OSGi with Spring.
Is it possible to have standard war deployment, which can be deployed on tomcat and also can be build as OSGi bundle and deployed with other bundles in OSGi container tomcat(i think virgo)?
Yes, there's a good deal of interoperability between WARs and WABs. Apache Aries and WebSphere Application Server will convert WARs to WABs on deployment. This is a good way to get up and running, but it's a better practice to use proper WABs in which you build in the OSGi metadata yourself. The extra OSGi headers won't interfere with the deployment in a normal Tomcat container, so the WAB has the greatest flexibility.
For your build, you have a number of options. For example, the maven bundle plugin can be configured to build WABs, or you can use Eclipse PDE's tooling support for OSGi metadata.
Pax-Url-War provides this functionality to containers like Apache Karaf. In brief, this allows you to import an URL like war:file:///path/to/myapp.war and Pax will wrap it as an OSGi bundle, optionally changing the URL root and other parameters on the fly.