cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <Ralph.Go...@dslextreme.com>
Subject Re: Writing my own generator.
Date Mon, 17 Oct 2005 15:03:25 GMT
Aurélien DEHAY wrote:

> Hello all.
>
> I'm currently writing a generator. I'm a bit mess up about dispose() 
> recycle(), Serviceable, Disposable and CacheableProcessingComponent...
>
> What do I really need to have a cacheable and poolable generator? I've 
> read the tutorial "Write a Custom Generator", but the Composable and 
> Disposable is not very clear: do I need to implement both dispose() 
> and compose() ?
>
> Thank you for your answer.
>
> Regards.

The easiest answer is to tell you to look at the FileGenerator. It is 
cacheable and poolable.

When components (such as generators) are pooled they are first 
initialized by calling the lifecycle methods you have declared, such as 
service, configure, etc.  The service method simply gives you access to 
the service manager. If you need this then just extend ServiceableGenerator.

Each time the generator is used its setup method is called first. This 
should be as light as possible. They validity methods will then be 
called to determine if the cached version can be used. If it cannot, the 
generate method is then called.
You only need to use the Disposable interface (and thus the dispose() 
method) if you acquire a resource from the service manager that must be 
released when your generator is freed by the component manager.  If you 
acquire resources during the generate method they should be released there.

BTW - these principals apply to most Avalon based components, not just 
generators.

HTH
Ralph

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


Mime
View raw message