Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Dynamic classloading mechanism in BIRT engine
szucs
Hello Guys,
We have a project with the following reporting requirements:
a. reporting capability
b. high reporting availability: restart of reporting system is unacceptable
c. reporting dynamicity: some facility for hot report deployments/extensions without any restart of reporting system
d. facility for fetching data/metadata from our CMS system (Version Control and Wokflow Management system) as data source for reports
A new report will be packaged and (hot-)deployed as a plugin including all of the resources required for its generation:
a. report resource files such as report design file (.rptdesign)
b. BIRT Java event handlers
So we decided to use BIRT within an OSGi/Equinox application.
Unfortunately BIRT report engine cannot see Java event handler classes from at-runtime deployed report plugins. So I need some kind of dynamic classloading mechanism in BIRT.
I am thinking about how I could realize that...I list some of possible alternative solution drafts below.
Question 1)
What is your opinion about them?
Question 2)
There was a possibility to configure classloader per report generation task (through app context), why doesn't it work any more in latest BIRT version? Maybe that's just what I would need...
Many thanks, Csaba
Solution 1)
With no usage of BIRT Java event handlers during report generation phase
a. custom CMS-specific BIRT web service data source?
b. custom CMS-specific BIRT data source and data set items?
c. report data could be fetched and preprocessed by Java classes executed just before report generation phase and could be passed to BIRT report engine
c1. through temporary data files (plain file, CVS file, XML file)
c2. through InputStream objects passed to BIRT datasource or dataset items? Is that possible, will it work? As if I had seen such source example...
Solution 2)
With usage of BIRT Java event handlers during report generation phase
a. classpath to BIRT Java event handlers is set at report engine startup time (not ok, it's not dynamic)
b. JAR file(s) of BIRT Java event handlers are set on Resources tab in report design files (a bit better)
c. custom flexible/dynamic classloading solution in BIRT?
c1. any classloader hook api in BIRT for doing this?
For example: hooking custom classloader into BIRT with some parent delegation to the given report's BundleClassloader (please note: Java event handlers may import other Java classes from other plugins)?
c2. some OSGi/Equinox classloading workaround in order BIRT report engine plugin could see Java event handlers from report plugins
-dynamic imports (in reference to the packages of BIRT Java event handlers)?
-fragments (reports could be fragments to the host plugin of BIRT report engine)?
-resolver hook / bundle hook / weaving hook services (what about these OSGi hook facility)?
-Equinox Framework Adaptor API (Class Loading Hook)?
Find more posts tagged with
Comments
JasonW
Have you tried accessing the plugin with some script? For example look at this beforeFactory script:
importPackage(Packages.org.eclipse.core.runtime);
mybundle = Packages.org.eclipse.core.runtime.Platform.getBundle("org.eclipse.birt.report.viewer");
furl = FileLocator.find(mybundle, new Path("/birt/webcontent"), null);
myfolder = FileLocator.toFileURL(furl).getPath();
mc = mybundle.loadClass( "org.eclipse.birt.report.viewer.utilities.WebViewer");
mi = mc.newInstance();
xyz = mi.getCurrentWebApp().getName();
You can see where the loadClass is being used.
Jason
szucs
Jason,
it does work, thanks!
And what about this script at beforeFactory, it does not work unfortunately:
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.report.model.api.elements);
importPackage(Packages.org.eclipse.birt.report.model.api.elements.structures);
reportDesignHandle = reportContext.getReportRunnable().designHandle.getDesignHandle();
scriptlib = StructureFactory.createScriptLib();
scriptlib.setName("handlers.jar");
reportDesignHandle.addScriptLib(scriptlib);
Thanks, Csaba.
JasonW
Csaba,
I believe you would have to call that before the report is opened.
Jason