You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Upayavira <uv...@upaya.co.uk> on 2003/01/03 12:22:14 UTC

Environments and the CocoonBean

Guys,

I have been trying more to get my head around the code I extracted from the 
Main.java class.

Firstly - environments:

The way the Main.java code works is that it creates an OutputStream outside of the 
FileSavingEnvironment, and hands this stream to this Environment. Cocoon then 
asks the FileSavingEnvironment for an OutputStream.

What I have done is implemented Destination classes, where this class provides an 
OutputStream customised for sending information by FTP, HTTP, etc.

However, it strikes me that this is the role of the Environment objects.

So, rather than have a Destination object hand its OutputStream to a 
FileSavingEnvironment, and that hand it to Cocoon, I would propose that I create an 
abstract BeanEnvironment class, and then subclass that as an FTPEnvironment, 
HTTPEnvironment (better name probably needed), FileSaveEnvironment, 
EmailEnvironment, etc, adding to these the behaviour that I originally had within my 
Destination classes.

Have I understood the role of the environment object correctly? I.e. it deals with a 
single request and the response to that request.

Regards, Upayavira

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: Environments and the CocoonBean

Posted by Bernhard Huber <be...@a1.net>.
hi,
<snip/>
> 
> Have I understood the role of the environment object correctly? I.e. it deals with a 
> single request and the response to that request.
yes, that's right
more specific:
in case of Main.java the outputStream is bound to an FileOutputStream
BEFORE cocoon page processing starts. Thus in case of FTP, et al.
you should already know the destination BEFORE you make do the page 
processing.

It took me some time to understand that, you might want to check out
the scratchpad area, there is a Cocoon Ant task.
The Ant task delayes writing to the OutputStream 'til the content-type
of data is fixed which will go through the OutputStream, see the
org.apache.cocoon.ant.DelayedFileSavingEnvironment

regards bernhard


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org