I'm not sure why but when I use SynchronousBundleListener instead of
BundleListener the output starts appearing in the console.
Quoting [email protected]:
I modified my class to this but I am still not seeing anything on the
console. I would have expected this to account for System.out being
redirected.
public class ListenerActivator implements BundleActivator,
FrameworkListener, BundleListener
{
private int invoked = 0;
private PrintStream out;
public void start(BundleContext bundleContext) throws Exception
{
out = System.out;
// Add the listeners
out.println("Adding listeners...");
bundleContext.addFrameworkListener(this);
bundleContext.addBundleListener(this);
}
public void stop(BundleContext bundleContext) throws Exception
{
// Remove the listeners
out.println("Removing listeners... " + invoked);
bundleContext.removeFrameworkListener(this);
bundleContext.removeBundleListener(this);
}
public void frameworkEvent(FrameworkEvent event)
{
out.println("\tFrameworkEvent(type=" + event.getType() +
",bundle=" + event.getBundle() +
",source=" + event.getSource() +
",throwable=" + event.getThrowable() + ")");
invoked++;
}
public void bundleChanged(BundleEvent event)
{
out.println("\tBundleEvent(type=" + event.getType() +
",bundle=" + event.getBundle() +
",source=" + event.getSource() + ")");
invoked++;
}
}
Quoting [email protected]:
Pax Logging is installed in karaf by default so that's definitely
possible. Thanks!
Quoting "Richard S. Hall" <[email protected]>:
On 6/24/11 20:23, [email protected] wrote:
I have the following bundle activator which implements both
FrameworkListener and BundleListener,
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
public class ListenerActivator implements BundleActivator,
FrameworkListener, BundleListener
{
private int invoked = 0;
public void start(BundleContext bundleContext) throws Exception
{
// Add the listeners
System.out.println("Adding listeners");
bundleContext.addFrameworkListener(this);
bundleContext.addBundleListener(this);
}
public void stop(BundleContext bundleContext) throws Exception
{
// Remove the listeners
System.out.println("Removing listeners " + invoked);
bundleContext.removeFrameworkListener(this);
bundleContext.removeBundleListener(this);
}
public void frameworkEvent(FrameworkEvent event)
{
System.out.println("\tFrameworkEvent(type=" + event.getType() +
",bundle=" + event.getBundle() +
",source=" + event.getSource() +
",throwable=" + event.getThrowable() + ")");
invoked++;
}
public void bundleChanged(BundleEvent event)
{
System.out.println("\tBundleEvent(type=" + event.getType() +
",bundle=" + event.getBundle() +
",source=" + event.getSource() + ")");
invoked++;
}
}
However, when I run this in karaf the System.out.println calls
within the start/stop methods work but the ones within
frameworkEvent and bundleChanged do not. I know they are being
invoked because the stop method displays an integer value larger
than zero. Why isn't System.out working?
I'm guessing someone is grabbing stdout and setting it to something
else, perhaps for logging.
-> richard
-John
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]