|
Re: Scripted Data Source - Method call for each field [message #498436 is a reply to message #498027] |
Mon, 16 November 2009 21:54 |
|
Tero,
does your getInstance create a new connection everytime? It would be
better to wrap a connection in singleton for all to use and maybe
provide a method to do a close on the datasource. If you are only using
one row you could always skip the scripted dataset and put something
like this in a data element expression.
importPackage(Packages.com.abd.factory);
var obj = SeMediator.getInstance();
obj.getData1();
Jason
tero wrote:
> Hello,
>
> I have a big report with many Data Sets all based on a Scripted Data
> Source.
>
> Each Data Set has a script implemented on "open":
> count = 0; // Create instance of the mediator class
> seMediator = Packages.com.abd.factory.SeMediator.getInstance();
> //Load the arrays
> seDataObj = seMediator.getAllData();
>
> "fetch":
> if(count < 1){
> row["field1"] = seDataObj.getData1();
> row["field2"] = seDataObj.getData2();
> row["field3"] = seDataObj.getData3();
> row["field4"] = seDataObj.getData4();
> row["field5"] = seDataObj.getData5();
> ..
> }
> count++;
> return true;
> }
> return false;
>
> "close":
> seMediator = null;
> seDataObj = null;
>
> Due to the nature of the report, very often I cannot use tables and
> therefore each of the above "rows" are single Data fields. Therefore I
> changed the scripts I have for producing "table data" within that if
> loop in the fetch section, to cover only "one loop" (I know it looks
> strange but couldn't find a doc about scripting within a Data Set).
>
> Now the problem:
> the whole process; open + fetch + close with its corresponding method
> call and database connection! is being done for each single Data field.
>
> As you can imagine that is not performing well, but even worse, I am
> getting an OutOfMemoryError: PermGen space very soon if the report is
> called more than once.
>
> Any possibility to design this a better way within the BIRT logic?
> Partly I could cover that within the Java class, but it would be better
> if possible within the BIRT logic.
>
> Many thanks,
> Tero
|
|
|
|
Re: Scripted Data Source - Method call for each field [message #501352 is a reply to message #501253] |
Tue, 01 December 2009 22:32 |
|
Maybe afterFactory. Or open and close it in servlet context listener
which you would have to add to the viewer.
tero wrote:
> Hello Jason,
>
> Many thanks for your ideas.
> I was already using a singleton class as the data "provider" and after
> learning (in another thread, and also from you :) ) how to use variables
> within the scripts, had already some ideas of using something like
> importPackage(Packages.com.abd.factory);
> var obj = SeMediator.getInstance();
> obj.getData1(); So I will often replace the "Script Data Source" with
> this approach, in the case no iteration (loop) is required to gather the
> data.
>
> About "... provide a method to do a close on the datasource ..." : where
> would you call such a method from the script?
>
> Thanks again!
> Gerardo
|
|
|
|
Re: Scripted Data Source - Method call for each field [message #505999 is a reply to message #505818] |
Tue, 05 January 2010 13:16 |
|
Tero,
I don't have an example but it should be simple to implement one/
Take a look at this article at OnJava
http://onjava.com/onjava/2001/04/12/listeners.html
Also note that the BIRT viewer uses one, so you can check out the code
and have a look.
Jason
tero wrote:
> Hello Jason,
>
> Do you have an example of the second option:
>
> open and close it in servlet context listener which you would have to
> add to the viewer.
>
> Thanks!
>
> Jason Weathersby wrote on Tue, 01 December 2009 17:32
>> Maybe afterFactory. Or open and close it in servlet context listener
>> which you would have to add to the viewer.
>
>
|
|
|
|
Re: Scripted Data Source - Method call for each field [message #506479 is a reply to message #506368] |
Thu, 07 January 2010 11:30 |
|
The BIRT Viewer one actually uses a session manager. Take a look at
ViewingSessionManager and ViewingCache class files from the viewer
source. The call ViewingSessionUtil.createSession(..) creates the
sessions.
BIRT has a ViewerHttpSessionListener as well but it does not delete the
files, but there is no reason you could not use a session listener to do
this.
tero wrote:
> Thanks Jason, I will do so.
>
> BTW, any hint on how the "BIRT viewer one" is called/declared?
|
|
|
Powered by
FUDForum. Page generated in 0.03951 seconds