You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jan Hoskens <jh...@schaubroeck.be> on 2004/11/04 10:49:05 UTC
getComponent / Release Component
Hi,
When editing my flowscript, I notice that there are some components that
are used a lot.
Eg:
var resolver = null;
var filesource = null;
try
{
resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
filesource = resolver.resolveURI(uri);
return filesource.exists();
}
finally
{
if(filesource != null) resolver.release(filesource);
cocoon.releaseComponent(resolver);
}
Is it appropriate to declare these components that are used a lot as
global variables? If I do set them globally, how do I release them?
Or are these getComponent/release couples no real threat to slow things
down and am I only worried about code duplication?
Kind Regards,
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: getComponent / Release Component
Posted by Leszek Gawron <lg...@mobilebox.pl>.
Jan Hoskens wrote:
> Hi,
>
> When editing my flowscript, I notice that there are some components that
> are used a lot.
> Eg:
>
> var resolver = null;
> var filesource = null;
> try
> {
> resolver =
> cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
>
> filesource = resolver.resolveURI(uri);
> return filesource.exists();
> }
> finally
> {
> if(filesource != null) resolver.release(filesource);
> cocoon.releaseComponent(resolver);
> }
>
> Is it appropriate to declare these components that are used a lot as
> global variables? If I do set them globally, how do I release them?
> Or are these getComponent/release couples no real threat to slow things
> down and am I only worried about code duplication?
unused component should be released as soon as it's possible. Also you cannot
get a component reference and store it in global variable because it may not
be released at all. Automatic release of components is something being
discussed but far from being implemented. For now you have to stay with syntax
you have.
--
Leszek Gawron lgawron@mobilebox.pl
Project Manager MobileBox sp. z o.o.
+48 (61) 855 06 67 http://www.mobilebox.pl
mobile: +48 (501) 720 812 fax: +48 (61) 853 29 65