throw new IllegalStateException("Central has not been initialised");
if (workspace != null)
return workspace;
Workspace newWorkspace = null;
try {
Workspace.setDriver(Constants.BNDDRIVER_ECLIPSE);
newWorkspace = Workspace.getWorkspace(getWorkspaceDirectory());
newWorkspace.addBasicPlugin(new WorkspaceListener(newWorkspace));
newWorkspace.addBasicPlugin(instance.repoListenerTracker);
newWorkspace.addBasicPlugin(getWorkspaceR5Repository());
// Initialize projects in synchronized block
newWorkspace.getBuildOrder();
// Monitor changes in cnf so we can refresh the workspace
addCnfChangeListener(newWorkspace);
// The workspace has been initialized fully, set the field now
workspace = newWorkspace;
// Call the queued workspace init callbacks
while (!workspaceInitCallbackQueue.isEmpty()) {
Function<Workspace,Void> callback = workspaceInitCallbackQueue.remove(0);
callback.run(workspace);
}
return workspace;
} catch (final Exception e) {
if (newWorkspace != null) {
newWorkspace.close();
}
throw e;
}
}