Reputation: 594
I am using Equinox. I wanna execute osgi command in code.
ex. install bundle command
public void start(BundleContext context) throws Exception {
String cmd = "install file:///e://testBundle.jar"
// How can I execute cmd in code?
...
}
thanks for help
Upvotes: 2
Views: 1066
Reputation: 11022
You can manage bundles through the BundleContext, or an instance of a Bundle:
BundleContext.installBundle
allow you to install a bundle from an URL
You can find a Bundle
instance with the BundleContext. See for example BundleContext.getBundles()
. On a Bundle
instance, you can call start()
, stop()
, update()
or uninstall()
See: BundleContext and Bundle
If you really want to access to a shell and execute commands, Equinox uses Apache Felix Gogo Shell. You should get a reference to a CommandProcessor
, create a CommandSession
from this processor, and call execute
on this session.
@Reference
CommandProcessor commandProcessor;
...
CommandSession commandSession = commandProcessor.createSession(System.in, System.out, System.err);
commandSession.execute("..");
Upvotes: 4