cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Haul <h...@informatik.tu-darmstadt.de>
Subject Re: Best practice for "database" manipulation?
Date Sat, 21 Feb 2004 13:41:21 GMT
H.vanderLinden@MI.unimaas.nl wrote:
> Hello Christian, 
> 
> 
>>-----Original Message-----
>>From: Christian Haul [mailto:haul@informatik.tu-darmstadt.de] 
>>Sent: Monday, 16 February 2004 13:51
>>To: users@cocoon.apache.org
>>Subject: Re: Best practice for "database" manipulation?
> 
> 
>>Other than that, my advice is to put your database access into a java 
>>class (better: Avalon components) and access it from flow. If 
> 
> 
> This sounds like a good idea. I've been studying several *.js files and I
> get a general idea of how it should work, but...what do I get from building
> my classes into Avalon components and... what should I do to convert my
> classes into Avalon components? I cannot afford to spend a considerable
> amount of time to study yet another framework.

You gain flexibility and if your classes hold state or configuration, 
the Avalon component manager (soon service manager) manages them for you.

The pattern is to define an interface as contract to fulfill and 
configure at startuo time the "right" implementation to use. Avalon
provides a number of lifecycle interfaces that allow the manager to
setup your components. E.g. give access to other components or pass
configuration data to them. It also manages concurrent access to a
component by instantiating additional ones, pooling instances or
sharing instances across thread depending on the marker on the component.

Cocoon is based on this principle and whenever you access a generator
for example, the Avalon component manager directs the play.

If your classes don't have any such requirements, converting a normal
class to a component is to
a) create a corresponding interface
b) add a ROLE constant to the interface as individual name
c) declare your component in cocoon.xconf using 	
	<component-instance..../>
d) access the component from other components that implement the
    "servicable" interface. (your component gets a reference to its
    managing component manager)
e) use manager.lookup(YourInterface.ROLE) to access it
f) release the component when done using manager.release(myComponent)

d) does not apply for flow
e+f) there are methods on the "cocoon" object in flow for this.

Avalon is very easy to program to.

	Chris.

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


Mime
View raw message