How A Bundle can access OSGi output stream?
Is there a开发者_如何学编程ny way for a bundle to print an string in OSGi output stream?
I mean like System.out.println("String");
. Instead of this I want the bundle to print its strings in that stream.
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
System.out.println("Hello World!"); // I want to print this string in osgi console.
}
You see, if I run the OSGi framework it will print its responses to commands in Java Console, where System.out prints as well.
But my problem is that, I'm printing its outputs in a JTextArea, so I want bundles to be able to print there too (Print its strings in OSGi Console output stream). in this case I need a way to access the OSGi output stream.
If I understand you correctly, your JTextArea serves as a console or a view for the console output. So I'd suggest to just display the System.out stream in that JTextArea. Here's an example to achieve this: http://unserializableone.blogspot.com/2009/01/redirecting-systemout-and-systemerr-to.html
I guess I don't understand the question. That will write to where ever System.out is directed. If you start an OSGi framework from the command line, that should write to the terminal session.
精彩评论