Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354802 - Consider replacing static singletons with Guice
Summary: Consider replacing static singletons with Guice
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: 4.0.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Birt-ReportViewer CLA
QA Contact: Maggie Shen CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-16 05:09 EDT by Aaron Digulla CLA
Modified: 2011-10-24 03:42 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 Aaron Digulla CLA 2011-08-16 05:09:49 EDT
The Xtext project has used Guice with a lot of success to allow customers to replace almost every part of the framework with custom components.

Please consider converting BIRT for the next major release to Guice, too. This would reduce unnecessary dependencies between modules, get rid of global variables like BirtReportServiceFactory.service and allow to tweak engine setup, logging and various other aspect of BIRT.

For what it's worth, I have create a local fork where I started to do this. It's not a lot of work and migration can be done in several steps, so it's low risk - unless you want to restructure some of the code at the same time.
Comment 1 Jun Ouyang CLA 2011-08-22 03:30:43 EDT
What do you think BIRT can do with Guice? BIRT uses OSGi extension framework to resolve module depending.
Comment 2 Aaron Digulla CLA 2011-08-22 05:47:33 EDT
I'm not talking about class loading.

BIRT code contains a lot of singletons which make it hard to test, integrate and extend. Just look at the code which calls BirtReportServiceFactory.init() - you need to call this several times from several places in the JEE life cycle to make sure the factory eventually is initialized.

I want to get rid of the singletons like BirtReportServiceFactory and all the others.

I know that OSGi offers a "Blueprint Service" which does DI and IoC. Maybe this can be used instead of Guice. My concern is that Xtext uses Guice and Xtext is a very successful project. Using the code gives me a feeling that a lot of thought has went into it. When these people chose Guice over OSGi, that's a strong indication for me to wonder why.
Comment 3 Aaron Digulla CLA 2011-08-22 06:35:25 EDT
I'm not sure the component change makes sense. I only mentioned the singletons in the viewer component but the engine also uses singletons.

Similarily, ReportEngine uses new to create a ReportEngineHelper which means that it's impossible to overrode the behavior of that class.

With DI, it would be possible to configure these pieces of the BIRT framework and inject them preconfigured instead of adding options to AppContext or the EngineConfig.
Comment 4 Jun Ouyang CLA 2011-08-22 06:41:11 EDT
OK. Get it. We will discuss about it. Thanks.