How should I implement the OSGi console into a Bun

2019-05-22 21:53发布

I'm new on OSGi and I'm trying to implement the osgi console into a bundle.

I need to manage the other bundles/services from my bundle. So I need to be able to use the "ss", "install" and "unistall" commands at least on other services already installed or not. All this commands must be managed without human interaction, so I must to implement this into my application. This program will be installed on a uPC without a continuous monitoring.

I've googled the way to implement the OSGi console into a bundle but i cant found nothing relevant.

I'm using OSGi 3.7.1 and trying to deply on an Equinox.

4条回答
女痞
2楼-- · 2019-05-22 22:44

you can checke the org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider class and org.eclipse.core.runtime.internal.adaptor.EclipseCommandProvider class , you will see the command implement. and every Command can access by services with " (classobject=org.eclipse.osgi.framework.console.CommandProvider)" filter.

查看更多
一夜七次
3楼-- · 2019-05-22 22:45

Use the OSGi Framework API, from the org.osgi.framework package. This is the API that the console itself invokes in order to implement those commands.

查看更多
来,给爷笑一个
4楼-- · 2019-05-22 22:51

Take a look at the class org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider in bundle org.eclipse.osgi to see how the commands are implemented

查看更多
乱世女痞
5楼-- · 2019-05-22 22:51

Adding to what Tom said, this link might come in handy: http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.equinox/framework/bundles/org.eclipse.osgi/console/src/org/eclipse/osgi/framework/internal/core/FrameworkCommandProvider.java?view=markup&root=RT_Project.

I remember that it took me quite a while to find this class last time I needed to look into it. It might not be the newest version (I didn't check this), but it should be enough to give you a jump start. The CVS repository path btw is "/cvsroot/rt" on "dev.eclipse.org", module "org.eclipse.equinox/framework/bundles/org.eclipse.osgi".

Sorry for not adding this as a comment to Toms answer, but I do not have the permissions to do so it seems.

查看更多
登录 后发表回答