开发者

how do i find a class if I don't want to use a jar in osgi

i run the osgi using the java command: java -jar org.eclipse.osgi_3.5.1.R35x_v200908开发者_高级运维27.jar -console and then the bundles could be find in the ./plugins directory.

There are 2 questions. (1)I just edited 1 class file in the local machine and transfered it to the remote server. so I want to osgi just load the classes not the jar. how should I do it ? if the osgi framework didn't support this feature. I must package the jar which has only one class file edited and transfer it to remote server. it is to slow to package it and transfer the whole jar.

(2)when I run the command in background. how could I get the osgi console again?


There might be non-standard ways to load classes, but there is no ways to do that with pure OSGi. In OSGi the bundle (the jar file) is the delivery package that can be loaded and managed by an OSGi framework. Usually, each bundle is loaded by an separate classloader. You gain a lot with that: you specify which packages with which version a bundle exports or imports. In the Manifest you indicate these relationships in an orderly manner. This ways the OSGi framework is able to manage the dependencies without interrupting other bundles.


If you are trying to replace the class for debugging purposes, you could try a remote debug on a VM that supports hot code replace. This will allow you to step through, find a problem, and fix it without restarting OSGi.

Once you find the fix though, you will need to rebuild the bundle. @akr is correct that the packaging mechanism for OSGi is bundles.

To answer your second question, don't run it in the background if you want the console. Just run the command in its own shell. At development time, this shouldn't be a problem. At deployment time, you shouldn't really be using the console to do things. Technologies like P2 from Eclipse can help with managing deployed OSGi runtimes.


Answering question 2: there are shells for OSGi that support telnet and SSH. Using one of those allows you to run the process in the background but still connect to it (even remotely obviously).


If you use the bundleContext.installBundle(String location) to install your bundle you can define a folder on your server where the jar is unpackaged. After that you can copy only that class to the server folder and call the update command on that bundle.

If you use Eclipse with m2e and maven-bundle-plugin you can simply sinchronize the target/classes directory to the folder on your server right after saving the class (as in that case MANIFEST.MF is refreshed as well as soon as you save your .java file)

As you can see you have to copy the generated MANIFEST.MF always to be sure that Import-Package section is refreshed as well.

You can write a short shell script (or cmd in windows) to do this if you can connect to your server via ssh or telnet (e.g. using felix-osgi-console or equinox-console).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜