How to deploy multiple processes(bundles) in 1 jar onto OSGI felix - osgi

I'm quite new to OSGI framework so I do not how to deploy multiple processes(bundles) in 1 jar onto it. Particularly, I have installed the Apache Felix With Web Console following this link. I have also tried to deploy my jar file and started it as the bundle. The jar's purpose is like a job to process some activities.
However, I would like to have multiple jobs in just 1 jar file so that when I deploy that jar on Felix the framework can identifies and presents them as individual parts.
For example, I want to have 3 jobs(A,B,C) in my jar and when I deploy that jar onto Felix, maybe the Web Console still define the jar as 1 bundle but it could present both job A, job B and Job C and I can do some bundle function on them like update/start/stop/...

Related

Creating a Executable and library from single Spring Boot codebase

I have single SpringBoot Project(has common controllers and feign clients), with an intension to use it as library in other deployable service.
With help of Gradle task i.e. 'jar' - for plain jar and 'bootjar'- executable jar, I am trying to create 2 different jar. So with the help of 2nd executable jar we can deploy them on to QA and test the changes before asking anyone else to consume the plain lib jar.
In this project I have kept #SpringBootApplicaiton -class so that it can be run as executable. But my ask is to include this only in executable jar and not in plain jar,
as plain jar will be imported in another spring boot projects, which will fail with 2 #SpringbootApplication classes.

how to change flink fat jar to thin jar

can I move the dependency jars to hdfs, so I can run a thin jar without dependency jars?
the Operation and Maintenance Engineers do not allow me to move jar to flink lib folder.
Not sure what problem you are trying to solve, but you might want to consider an application mode deployment if you are using yarn:
./bin/flink run-application -t yarn-application \
-Dyarn.provided.lib.dirs="hdfs://myhdfs/remote-flink-dist-dir" \
"hdfs://myhdfs/jars/MyApplication.jar"
In this example, MyApplication.jar isn't a thin jar, but the job submission is very lightweight as the needed Flink jars and the application jar are picked up from HDFS rather than being shipped to the cluster by the client. Moreover, the application’s main() method is executed on the JobManager.
Application mode was introduced in Flink 1.11, and is described in detail in this blog post: Application Deployment in Flink: Current State and the new Application Mode.

Package and deploy OSGi bundles and Karaf features in Karaf Container

Recently, I have been working on Apache Karaf project.
The first one is a CXF REST service example and the second one is an Apache Karaf Maven example to run and deploy a Karaf container.
What I would like to do is to combine these two. The idea is to download a couple of JAR files from a repository and then package them into a Karaf.
Building Karaf Assembly manually then deploying the created JAR files in my deploy folder under Karaf is not a good idea if the task is reccurent each day. I would very much like to automate this if possible?
To achieve automatic deploy of Java project in Karaf, follow these steps:
Create a feature project: It is a Maven project and its goal is to create a descriptor of JAR (bundles) to be deployed under Karaf. The packaging of this Maven project is feature.
For your project of Karaf Assembly, add your feature as dependency and add it as boot feature so it can be installed when Karaf is up.
Look at this project https://github.com/benson-basis/karaf-feature-version-tc.
It has all the necessary configuration to automate Karaf building and deploy.

Maven Jetty Run from Jar

Here is want I want to do. I created a maven project and configured the jetty plugin for it in eclipse...
So from Eclipse if I do run and set the maven goal there to be jetty:run it runs my project in jetty on the port specified in web.xml. Now I want to build the jar file and when I do java -jar myapp.jar it will automatically call jetty:run.
How can I do this?
If you want to package your application so that you can hand it to someone and have them run it as a standalone application without having to go through deploying a war file into a web container, then that is a different concern from doing mvn jetty:run at development time, I will call that deployment time to avoid any confusion
At deployment time, we can't assume there will be maven on the machine, thus no mvn jetty:run, and even if there was, this would not work, unless we deliver the source code to run the build as in the development environment!
A standalone web application can be packaged by bundling the jetty jars in the application war along with a Main class to start jetty programmatically, and get it to run the application war. This relies on the fact that the file and directory structure of the WAR and JAR are different, and thus there is no significant overlap between the two, which is what makes this workaround possible, and it also leaves the option of deploying the war file in a web container possible
There is a maven plugin that embeds winstone which is another lightweight servlet container
For jetty, you may start by reading Embedded Jetty 7 webapp executable with Maven

Which way is the best to go for building a webapp as osgi bundle via maven and start them with webstart?

I am looking for a way to reach my vision. What is the best way to go?
Here is my vision:
I would like to build a captain casa app via maven (as a war file).
Then i would like to create a osgi bundle from the builded war via maven.
Next i would like build a artifact which could be downloaded and started via java webstart (jnlp).
The jnlp file should be download the osgi environment with web container support (maybe jetty osgi service), next download osgi bundled war. Then the osgi container and the jetty service should be started and my war should be deployed. Finally the app is running local in a osgi environment.
There are many questions to be answered:
How can i build a captain casa app via maven to a war?
Which maven plugin should be used to build the osgi bundle (pax, maven-bundle-plugin, tycho, ...) What are the differnce?
How to build a jnlp artifact via maven which can deployed on a site?
How must be modified the osgi bundle to support java webstart?
Known informations:
Blog entry to prepare osgi bundle for java webstart.
many pages to maven plugins, such as pax, maven-bundle-plugin, tycho, bnd, ...
It might be worth asking this as 3 separate questions, but when building Web application Bundles I use the maven-bundle-plugin version 2.2.0 (currently unreleased, so you'll need to depend on a snapshot).
Then I use the following file structure:
src/main/java - any .java files
src/main/resources - any non .java files that should be on the classpath
src/main/webapp - static content, images, html files jsps and so on
Then inside the pom once you have configured the normal data for the maven-bundle-plugin you specify the following:
<_wab>src/main/webapp</_wab>
this will cause the static content to be pulled into the bundle and the bundle to be structured with the classes and resources in the WEB-INF/classes directory.

Resources