You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Nikolaus Rath <Ni...@rath.org> on 2004/09/11 12:49:43 UTC

How to Implement a Javaflow Application properly

Hello,

I want to port a standalone Java application to Cocoon Flow, changing the
view component from Swing to HTML (probably JX generated).

I know that javaflow is still unstable, but that's okay for me. It's
just for private use.

Now I wonder what would be the best way to go in respect to performance
and continuations. I searched hard for some docs about how continuations
work internally but I didn't find anything helpful. 

My current plan is to use a very small handler class (inherited from
org.apache.cocoon.components.flow.java.AbstractContinuable) that calls
the main application with the object itself as the only parameter, so
that the application can use sendPageAndWait.

The thing I'm worried about is the fact that my application loads data
files (3 - 5 MB) completely into memory to work with them. At the end,
the file is written back to disk, overwriting the old one.

I suspect that Cocoon uses some sort of Serialization to implement
Continuations and that the size and amount of referenced objects
directly influences performance.

Therefore I'm playing with the idea to store the application data in an
external database and to access it using JDBC.

To put it into a nutshell, my questions are:
 * How do continuations work in general and what should I consider
   when using them?
 * Is it sensible to use an external database instead of keeping the
   data in-memory?
 * How can my java flow handler retrieve a component manager? It would
   be nice if I can use pooled connections.
 * Will my db connection persist a continuation?
 * What will happen with other threads when one thread calls
   sendPageAndWait? 

Many thanks in advance for any help!


bye
Nikolaus

PS: The Flow feature in cocoon is one of the most exciting ideas I've
ever seen. Really great work - Thanks for all your efforts!





Re: How to Implement a Javaflow Application properly

Posted by Nikolaus Rath <Ni...@rath.org>.
Stephan Michels <st...@apache.org> wrote:
> On Sat, 11 Sep 2004, Nikolaus Rath wrote:
>> I suspect that Cocoon uses some sort of Serialization to implement
>> Continuations and that the size and amount of referenced objects
>> directly influences performance.
> 
> The JavaFlow stores the Continuable objects in the session, so that
> the field have the scope of the session. On the other side the
> local variables are stored into the continuation, managed by the
> ContinuationManager.

Still a bit complicated for me. I will have to dig into Continuable
objects a bit more I think.

>>  * How do continuations work in general and what should I consider
>>    when using them?
> 
> The continuation stores the execution state of a function/method
> invocation. Nothing more or less.

I just looked at Continuation.java and ContinuationStack.java but I'm
unable to figure out how this is done within java. Maybe you can give
me a short outline so I now where to start?

>>  * Is it sensible to use an external database instead of keeping the
>>    data in-memory?
> 
> How do you do it in your normal webapp?

My normal app is not a webapp. It runs standalone with Swing and works
fine with in-memory data. Now I'm nervous that the complete data has
to be serialized and copied whenever the application is interruped and
resumed by a continuation if I keep the in-memory model for the webapp
port.


   --Nikolaus

-- 
$|++;@_=map{chr(ord($_)-$|)}split//,"Kvtu!bopuifs!Qfsm!Ibdlfs-";$\="\r";@a=qw(
< ^ > v);$§="_"x25;until($§!~m~_~){$o=int(rand 28)+65;next if$s{$o}++;$o==91?
$o=44:($o==92?$o=32:0);$g=chr$o;for(0..24){if($_[$_]=~m)$g)i){for$m(@a,$_[$_])
{substr $§,$_,$|,$m;print$§;select$/,$/,$/,0.1}}}print$§}print$/


Re: How to Implement a Javaflow Application properly

Posted by Stephan Michels <st...@apache.org>.
On Sat, 11 Sep 2004, Nikolaus Rath wrote:

> I suspect that Cocoon uses some sort of Serialization to implement
> Continuations and that the size and amount of referenced objects
> directly influences performance.

The JavaFlow stores the Continuable objects in the session, so that
the field have the scope of the session. On the other side the
local variables are stored into the continuation, managed by the
ContinuationManager .


> Therefore I'm playing with the idea to store the application data in an
> external database and to access it using JDBC.
>
> To put it into a nutshell, my questions are:
>  * How do continuations work in general and what should I consider
>    when using them?

The continuation stores the execution state of a function/method
invocation. Nothing more or less.

>  * Is it sensible to use an external database instead of keeping the
>    data in-memory?

How do you do it in your normal webapp?

>  * How can my java flow handler retrieve a component manager? It would
>    be nice if I can use pooled connections.

Yes, you can use the inherited method getComponent() from
AbstractContinuable

>  * Will my db connection persist a continuation?

?? What? You mean if your continuation persist the db connnect?!

Hmm, I'm not an expert, but I would prefer a separate component
to manage the db interaction.

>  * What will happen with other threads when one thread calls
>    sendPageAndWait?

Nothing, I think. The contination manager uses thread locals to the keep
track of the used thread.

> PS: The Flow feature in cocoon is one of the most exciting ideas I've
> ever seen. Really great work - Thanks for all your efforts!

Thanks.