You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Perez Guerrero, Antonio Javier" <AJ...@sadiel.es> on 2009/06/08 08:47:36 UTC
Avoid a class to be garbage collected
Hi,
Is there any way I can "bind" a class with Cocoon, or make it persistent, so it's never destroyed by the garbage collector?
I've a singleton class containing some data structures (basically Maps), which need to be shared between users (so, I can't store them in session). I could write the data to a XML file, but I'd really prefer to avoid it, because the data is going to change very frecuently.
Thanks
RE: Avoid a class to be garbage collected
Posted by "Perez Guerrero, Antonio Javier" <AJ...@sadiel.es>.
Then the only thing I have to do is to define the class as a bean in my core.xml (which is loaded from applicationContext.xml). Nice!
Thanks a lot Andre
PS: I'm using Cocoon 2.2 and Spring 2.5, I forgot to say it.
________________________________
Hi,
if you rely on Cocoon 2.2, then creating classes with Spring would be
the way to go:
Spring 3.*
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/ch04s04.html#beans-factory-scopes-singleton
Spring 2.5.*
http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-scopes-singleton
While most developers with Spring would prefer XML to define their
beans, one can also do so by annotation.
Cheers,
Andre
Perez Guerrero, Antonio Javier wrote:
> Hi,
>
> Is there any way I can "bind" a class with Cocoon, or make it
> persistent, so it's never destroyed by the garbage collector?
>
> I've a singleton class containing some data structures (basically
> Maps), which need to be shared between users (so, I can't store them
> in session). I could write the data to a XML file, but I'd really
> prefer to avoid it, because the data is going to change very frecuently.
>
> Thanks
--
Andre H. Juffer | Phone: +358-8-553 1161
Biocenter Oulu and | Fax: +358-8-553-1141
Department of Biochemistry | Email: andre.juffer@oulu.fi
University of Oulu, Finland | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat | WWW: www.strubiocat.oulu.fi
NordProt | WWW: www.nordprot.org
Triacle Biocomputing | WWW: www.triacle-bc.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Avoid a class to be garbage collected
Posted by Andre Juffer <an...@oulu.fi>.
Hi,
if you rely on Cocoon 2.2, then creating classes with Spring would be
the way to go:
Spring 3.*
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/ch04s04.html#beans-factory-scopes-singleton
Spring 2.5.*
http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#beans-factory-scopes-singleton
While most developers with Spring would prefer XML to define their
beans, one can also do so by annotation.
Cheers,
Andre
Perez Guerrero, Antonio Javier wrote:
> Hi,
>
> Is there any way I can "bind" a class with Cocoon, or make it
> persistent, so it's never destroyed by the garbage collector?
>
> I've a singleton class containing some data structures (basically
> Maps), which need to be shared between users (so, I can't store them
> in session). I could write the data to a XML file, but I'd really
> prefer to avoid it, because the data is going to change very frecuently.
>
> Thanks
--
Andre H. Juffer | Phone: +358-8-553 1161
Biocenter Oulu and | Fax: +358-8-553-1141
Department of Biochemistry | Email: andre.juffer@oulu.fi
University of Oulu, Finland | WWW: www.biochem.oulu.fi/Biocomputing/
StruBioCat | WWW: www.strubiocat.oulu.fi
NordProt | WWW: www.nordprot.org
Triacle Biocomputing | WWW: www.triacle-bc.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org