Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 243441

Summary: [selfhosting] refactor registry view model
Product: [Eclipse Project] PDE Reporter: Jacek Pospychala <jacek.pospychala>
Component: UIAssignee: Jacek Pospychala <jacek.pospychala>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: caniszczyk
Version: 4.0   
Target Milestone: 3.5 M3   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 243439, 249087    
Attachments:
Description Flags
patch
none
patch
none
updated patch
none
patch v3
none
tests
none
patch v4 none

Description Jacek Pospychala CLA 2008-08-07 11:48:13 EDT
Abstract model will be more flexible to attach to different backends like local eclipse, eclipse target platform, selfhosted eclipse, etc.
Every of this backend will need a different implementation.

Attached patch gives some idea of the refactoring scale. Basically current model will be split into interfaces (in org.eclipse.pde.runtime.model) and impl (org.eclipse.pde.runtime.model.impl.local) + in future more implementations (model.impl.target, model.impl.remote, ...)

Refactoring should also move some factory methods scattered across ContentProviders and other classes to one factory class.
Comment 1 Jacek Pospychala CLA 2008-08-07 11:55:36 EDT
Created attachment 109423 [details]
patch
Comment 2 Jacek Pospychala CLA 2008-08-07 11:59:42 EDT
Created attachment 109425 [details]
patch
Comment 3 Chris Aniszczyk CLA 2008-08-07 12:01:24 EDT
wow you're fast
Comment 4 Jacek Pospychala CLA 2008-08-08 02:24:13 EDT
attachment 1 [details] and attachment 2 [details] are the same thing. I had some problems with bugzilla when uploading them.
Comment 5 Jacek Pospychala CLA 2008-08-08 09:55:09 EDT
Created attachment 109519 [details]
updated patch

refactoring continued. With this patch applied plug-in registry view still mostly works, there are however few things that got broken - I'll be fixing them in next days.
Done: almost all references to OSGi moved away from view class and content/label provider, view structuring and objects constructing is decoupled: first one in content provider, second one in model implementation. I like how simple now view classes look like.
To do: refactor event notification mechanism
Comment 6 Jacek Pospychala CLA 2008-08-11 09:51:17 EDT
Created attachment 109664 [details]
patch v3

Refactored notification mechanism into: local framework specific part (org.eclipse.pde.internal.runtime.registry.model.impl.local.RegistryBrowserListener) and view specific part (org.eclipse.pde.internal.runtime.registry.RegistryBrowserModelChangeListener).
It's very simple now and should work for changes related to Bundle, ServiceReference, IExtensionPoint, IExtension.
Comment 7 Jacek Pospychala CLA 2008-08-11 09:53:58 EDT
Created attachment 109665 [details]
tests

Today I have also worked on tests :)
There are some model and notifications tests.
Comment 8 Chris Aniszczyk CLA 2008-08-11 11:44:02 EDT
Jacek, let me know when you think it's safe to review and commit to CVS.
Comment 9 Jacek Pospychala CLA 2008-08-13 03:21:05 EDT
(In reply to comment #8)
> Jacek, let me know when you think it's safe to review and commit to CVS.

sure, I'm just attaching patch to monitor progress.

Comment 10 Chris Aniszczyk CLA 2008-09-15 11:53:24 EDT
any updates on this work Jacek?

I'd like to have the model updates in for the M3 timeframe so we can spend time on looking at bug 243439 :)
Comment 11 Jacek Pospychala CLA 2008-09-16 04:23:14 EDT
(In reply to comment #10)
> any updates on this work Jacek?
> 
> I'd like to have the model updates in for the M3 timeframe so we can spend time
> on looking at bug 243439 :)
> 


Thanks for reminder. The work here is mostly done, I'll try to get back to this in next couple of days.
Comment 12 Chris Aniszczyk CLA 2008-09-16 10:24:28 EDT
Thanks Jacek, I will get this in once you're ready.
Comment 13 Chris Aniszczyk CLA 2008-09-22 11:10:21 EDT
how are things going here?

M3 is open for submissions now :)
Comment 14 Jacek Pospychala CLA 2008-09-29 11:12:39 EDT
fyi, I'm writing tests for this code now. I'd like them to verify that runtime model correctly reflects the reality and change notification works.
As soon as that's done, we can go forward with this patch. Hopefully that's one-two days.
Comment 15 Chris Aniszczyk CLA 2008-10-03 17:17:20 EDT
poke :)
Comment 16 Jacek Pospychala CLA 2008-10-17 12:00:54 EDT
ok, so I have a refactored view impl, that I've used for a moment, and so far it looks good (read: works).

The view works now as following:

1. RegistryView (class containing the Plug-in registry view itself) calls RegistryModelFactory to create a RegistryModel
2. RegistryModel stores Eclipse runtime model, so all bundles, extension points and services. It doesn't refer to any OSGi types, but just to POJO objects, so RegistryModel should be able to store information about any runtime, doesn't matter whether it's local or remote one.
3. RegistryModel uses RegistryBackend class to do any operations on real registry. For example RegistryBackend is queried for all plug-in data, it's also responsible for starting and stopping plug-ins on RegistryModel request. In other words, RegistryModel contains data and RegistryBackend performs operations.
4. There's only one RegistryBackend implementation now - LocalRegistryBackend. It basically uses OSGi API (Bundle, BundleContext, BundleListener) and Equinox Runtime (extension points registry).
There's place to implement other RegistryBackends.

Code needs a bit more comments and probably still a lot more polishing.
Chris, could you review it and commit maybe somewhere around next week?
Comment 17 Jacek Pospychala CLA 2008-10-17 12:01:34 EDT
Created attachment 115415 [details]
patch v4
Comment 18 Chris Aniszczyk CLA 2008-10-17 15:32:17 EDT
Looks great! Jacek, can you also update the tests zip? I tried to apply it to pde.ui.tests but it was borked.

I think a patch against org.eclipse.pde.ui.tests is fine. Just add pde.runtime as a dependency and go wild.
Comment 19 Chris Aniszczyk CLA 2008-10-20 18:11:01 EDT
I committed changes to HEAD.

Can you please update the tests Jacek so I can add them too ;)?
Comment 20 Chris Aniszczyk CLA 2008-10-20 18:11:16 EDT
done.

> 20091020
Comment 21 Jacek Pospychala CLA 2008-10-21 05:50:36 EDT
(In reply to comment #19)
> Can you please update the tests Jacek so I can add them too ;)?

sorry the tests got bit outdated, I'll add them in separate bug until the end of week.
Comment 22 Jacek Pospychala CLA 2008-10-21 06:30:30 EDT
(In reply to comment #21)
> sorry the tests got bit outdated, I'll add them in separate bug until the end
> of week.

actually in bug 248924.