cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens Maukisch" <jmauki...@s-und-n.de>
Subject AW: Instantiating a class on Cocoon startup
Date Mon, 01 Aug 2005 12:29:19 GMT
Hi,

> 
> 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?
> 

You can wirte an avalon component:

e.g.:
class ConfigManager implements Component, ThreadSafe, Initializable {

	String xmlConfig;

	public static String ROLE = ConfigManager.getClass().getName();

	public void initialize() {
		xmlConfig = ....;
	}

	public String getConfiguration() {
		return xmlConfig;
	}

}

and then you can get this component via the ServiceManager
e.g. in Flowscript:
var config = cocoon.getComponent(Packages.ConfigManager.ROLE);
print(config.getConfiguration());

hth
Jens


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


Mime
View raw message