cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "g[R]eK" <>
Subject Re: Instantiating a class on Cocoon startup
Date Mon, 01 Aug 2005 12:41:13 GMT
Christoph Hermann napisaƂ(a):

>Hash: SHA1
>is there a way in Cocoon to load a class on cocoon startup?
>What i want to accomplish is like read some sort of configuration file
>and then hold these values in memory while cocoon is running.
>So i thought of building a xml file which is loaded through xmlbeans
>into a static var or so. Thath way i wouldn't have to load the
>configuration File on each request.
>Can anyone give me some hints on how to accomplish this?
If you want your class to be loaded at startup you have to create 
interface like:
package your.package;

import org.apache.avalon.framework.component.Component;

public interface YourNiceIterface extends Component {
String ROLE = PersistenceFactory.class.getName();

//some methods

and then class:
public class YourNiceClass implements YourNiceInterface, Configurable, 
Serviceable, Initializable, Disposable, ThreadSafe {
//implement what you want

All these interfaces (excluding YourNiceInterface) are Avalon's 
interfaces and they are to tell that you need initialization 
(Initializable) of your component.
If you need some logging, then your class should derive from 
AbstractLogEnabled. If you need more details about intefaces, just ask.

Then you have to put in cocon.xconf something like this:
<component class="your.package.YourNiceClass" 

*BUT*, maybe you just need XMLFileModule[1]? ;-)
Or at least you should implement your own input module to easy obtain 
your configuration.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message