Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[birt-dev] CHECKIN: Avoid copying plugins into viewer folder in BIRT development

Title: CHECKIN: Avoid copying plugins into viewer folder in BIRT development

- Summary:
Avoid copying plugins into viewer folder in BIRT development

- Bugzilla Bug (s) Resolved:
None

- Description:
As of today, when viewer is running in the embedded Tomcat in BIRT Designer, server platform is used to get plugin information, build extension registry and load classes. In order for server platform to parse plugin, a BIRT_HOME (i.e. where the plugins are located) needs to be provided. Currently, the BIRT_HOME is set to the viewer's plugins folder. That's why the latest version of the plugins must be put under viewer's plugins folder.

 
In order not to copy plugins into viewer's plugin folder, we need to get plugin information and load classes from Eclipse workspace instead of an arbitrary disk location like BIRT_HOME. Since server platform can not do it, the Eclipse platform needs to be used. Eclipse platform is able to get all the plugin information and load the classes from workspace because through project configuration, Eclipse platform is aware of all the external plugins (i.e. plugins under Eclipse's plugin folder) as well as the workspace plugins (i.e. plugins included in the current workspace).

 
To use Eclipse platform when viewer is running in the embedded Tomcat in BIRT Designer, we can simply remove all the BIRT related jar files from viewer\birt\web-inf\lib folder. To understand why it works, we need to look at the classloading of the embedded viewer first. The embedded viewer is running in Tomcat, hence a class is loaded by Tomcat classloader first. If a class can not be loaded by Tomcat, the Eclipse's PluginClassloaderWrapper will be used which will load viewer and its dependency plugin from Eclipse workspace. When the birt related jar files are removed from web-inf\lib folder, the Tomcat classloader can not load birt.core, and the PluginClassloaderWrapper is used. Since birt.core was loaded already when the Designer started and the Eclipse platform (instead of server platform) was used, Eclipse's PluginClassloaderWrapper simply return the Eclipse platform. With this Eclipse platform, all the BIRT plugins/classes are loaded from the workspace instead of the viewer's plugin folder. So, the solution is to removing the birt related JAR files from the web-inf/lib folder in the embedded viewer.

 
This checkin changed the build script as follows.

It implemented the new build viewer script which only builds viewer itself. This new build script will be used for the embedded viewer. It also changed the original build viewer to build web viewer which copies birt related Jar file to lib folder and plugins to plugins folder (the same behavior as before). This script will be used to build the WAR file for viewer.

- Tests Description:
Here are the tests we've conducted. We tried to simulate what BIRT developer will do in the real world.
1. Have a clean Eclipse installation.
2. Install BIRT framework into the Eclipse.
3. Run BIRT Designer in the Eclipse and design a report.
4. Run viewer in embedded tomcat (by doing a preview). The report can be previewed correctly. (This is the case before the fix. Since web-inf\lib folder contains birt related jar files, BIRT server platform is used and it loads the plugins from viewer's plugin folder.)

5. Remove all the plugins from viewer\birt\plugins folder. Also remove all of the jar file from viewer\birt\web-inf\lib except for viewservlets.jar.

6. Run BIRT Designer and do a preview. The report can be viewed correctly. (This is the case after the fix. Eclipse platform is used and the plugins are loaded from Eclipse's workspace.)

7. Remove the sample db plugin from Eclipse's plugin folder. Run BIRT Designer in Eclipse. Since the sample DB plugin is removed, sample DB can not be used.

8. Get the source code for sample DB and the source code for rotated text. Put them into a directory other than Eclipse's plugin folder. Import them into the Eclipse workspace. (This is to simulate the case where user developed some new plugins).

9. Run viewer. A new workbench is loaded. In the new workbench, user can use sample DB and rotated text in the designer. Clicking Preview will show the sample DB and rotated text correctly. Note we didn't copy the plugins into the viewer folder and the new plugin still works.

10. Go into the source code of rotated text and modify the code (e.g. hardcoded a new text string). Set a break point there. Click Debug and do a preview without copying the plugins into the viewer folder. The breakpoint is hit and the hardcoded string is shown up in the report output. Note we didn't copy the modified plugin into the viewer folder and the modified plugin is loaded directly from Eclipse workbench.

- Files Edited:
/org.eclipse.birt.report.viewer/BuildViewer.xml

- Files Added:
/org.eclipse.birt.report.viewer/BuildWebViewer.xml

- Code Reviewer:
Wenbin, Jun

- Notes to Build Team:
The build script needs to be changed accordingly. Wenbin and I have already talked to the build team.

- Notes to Developers:

- Notes to QA: 
 
- Notes to Documentation:


Back to the top