I want to do operation like deploy/Active/Unistall
maven bundle through java. How can i do it in java application ?
Any help?
Asked
Active
Viewed 562 times
0

Noshaf
- 207
- 7
- 21
-
You may get inspiration from following post: https://stackoverflow.com/questions/36010963/how-to-call-karaf-console-command-in-java – gusto2 Jul 26 '17 at 12:34
-
@gusto2 the above mension link does not work for me – Noshaf Jul 26 '17 at 12:37
-
Cited from the linked post: All the shell commands use an underlying osgi service.... you can install a Bundle with BundleContext.installBundle or install a feature through the FeaturesService – gusto2 Jul 26 '17 at 12:40
-
@gusto2 karaf command execution : `session.execute( Charsequence comand );` when i pass the command `list` it works. But if the command contains whitespaces like `list -t` it gives exception : command not found .. seems it break the command – Noshaf Jul 27 '17 at 11:14
1 Answers
0
Almost every karaf component exposes it's internal components through OSGi Services and JMX MBeans, so there are several ways you can achieve what you want, like:
- Create a bundle that references Karaf OSGi Services using Blueprint, Declarative Services or Spring; For example, if you want to control a bundle install/update/refresh through your bundle you will reference the BundleContext and BundleService interfaces.
- Install Jolokia and Hawtio in your karaf, it will expose under REST Services several JMX MBeans which control bundles, instances, features and so on. With that you can create a java application that consumes those services. For a list of available Mbeans please refer to Karaf Documentation.
- Create a Java application that connects to karaf via JMX and uses the JMX MBeans, as cited above.
It's up to you to choose which solution solves your problem.

Cλstor
- 445
- 3
- 11