cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <lgaw...@mobilebox.pl>
Subject Re: getComponent / Release Component
Date Thu, 04 Nov 2004 09:53:24 GMT
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

Mime
View raw message