Bug 572874 - Simplify event service registration in ModelServiceImpl
Summary: Simplify event service registration in ModelServiceImpl
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.17   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-15 07:28 EDT by Lars Vogel CLA
Modified: 2021-04-16 14:07 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lars Vogel CLA 2021-04-15 07:28:52 EDT
ModelServiceImpl uses two methods to register its handler.

@Inject
	public ModelServiceImpl(IEclipseContext appContext) {
		Objects.requireNonNull(appContext, "No application context given!"); //$NON-NLS-1$
		this.appContext = appContext;

	Bundle bundle = FrameworkUtil.getBundle(getClass());
		if (bundle != null) {
		 // handle OSGi case
			}
		} else {
		// handle non OSGi case
		}

I suggest to remove the special handling for the OSGi case, the second approach using the IEventBroker directly also works in OSGi.
Comment 1 Lars Vogel CLA 2021-04-15 07:29:15 EDT
Rolf, do you have an opinion here?
Comment 2 Rolf Theunissen CLA 2021-04-16 14:07:19 EDT
It seems to me that this whole registration could be moved to an @Inject on the UIElement.TOPIC_WIDGET topic, so that no explicit registration to a IEventBroker is needed.

Furthermore, I really wonder if this code (and the call to renderer#createGui) should be in the EModelService, the functionality seems less related to other methods in this class. It might have deserved its own service or addon. Also, IPresentationEngine.CUSTOM_RENDERER_KEY could be used to assign a custom renderer to the hosted elements. Such that there is no rendering code in the ModelService.