Reputation: 129
I need to listen to perspective state changes in my plugin, which I am doing in IStartup
public void earlyStartup() {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
// register perspective listener to workbench
}
});
}
Launching IDE in a new workspace, after plugin update, I see below exception so frequently.
!MESSAGE While loading class "com.test.Startup", thread "Thread[Worker-2,5,main]" timed out waiting (5008ms) for thread "Thread[Thread-6,5,main]" to finish starting bundle "test.startup [55]".
To avoid deadlock, thread "Thread[Worker-2,5,main]" is proceeding but "com.test.Startup" may not be fully initialized.
!STACK 0
org.osgi.framework.BundleException: State change in progress for bundle
Any suggestions ?
Upvotes: 1
Views: 167
Reputation: 129
Finally I am using my 'BundleListener' to register listeners like 'IWindowCloseHandler' and 'IPerspectiveListener' etc, after bundle is started.
public class StudioBundleListener implements BundleListener {
@Override
public void bundleChanged(BundleEvent event) {
String symbolicName = event.getBundle().getSymbolicName();
int type = event.getType();
if(symbolicName.equals(MYPlugin.PLUGIN_ID) && type == BundleEvent.STARTED) {
//Register my listeners
}
}
}
This solved the class load issue.
Upvotes: 1
Reputation: 3559
I would suggest it's better to call with in your Perspective factory Plugin Activator class start() method. That will avoid the errors which you are facing.
Invoke this at the end of start() method. This won't impact the performance of the plugin loading.
Job job = new UIJob("Add Perspective listener") {
public IStatus runInUIThread(IProgressMonitor monitor) {
addPerspectiveListener();
return Status.OK_STATUS;
}
};
job.setSystem(true);
job.schedule();
Upvotes: 0