Return-Path: Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 67609 invoked from network); 11 Jan 2000 14:07:17 -0000 Received: from dfwns08.algx.net (216.99.225.37) by 63.211.145.10 with SMTP; 11 Jan 2000 14:07:17 -0000 Received: from algx.net ([216.99.224.6]) by dfwns08.algx.net (Post.Office MTA v3.5.2 release 221 ID# 0-56809U5000L5300S0V35) with ESMTP id net for ; Tue, 11 Jan 2000 08:06:00 -0600 Message-ID: <387B38A5.71BB1CC3@algx.net> Date: Tue, 11 Jan 2000 08:05:25 -0600 From: Brett McLaughlin X-Mailer: Mozilla 4.61 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: Re: shared object Proposal References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Michael Engelhart wrote: > > hello everyone - > This is a proposal to add a simple (but useful) plug-in mechanism to allow > users/developers to add arbitrary shared resources to Cocoon simply by > making changes to cocoon.properties (much like you would a producer). The > only requirement for the classes that are to be shared is that they must > implement Actor (or extend AbstractActor) and optionally the objects can > implement Configurable if they need it. It really makes it very easy to add > things like database connection pool classes without having to hardcode in > this type of extension to Cocoon. To call a shared object you would do > something like this: > Connection conn = > ((ConnectionPool)director.getActor("connectionPool")).getConnection(); > > One thing that really needs to be added to make this more usable (which I > hear is in the works for Cocoon 2) is to add a destroy() method to the Actor > interface so that things like connection pooling objects can clean up after > themselves, etc. (Any chance that if this proposal makes its way into > Cocoon that a destroy() method could be added before v2?) I'm +1 for the idea, -1 on your implementation (nothing personal ;-) ). I think things like this do not belong (coded) in Cocoon. They are part of a large application frameworks, like Turbine (incidentally, where we have implemented something similar to what you outlined). Those frameworks, which are designed to use things like Cocoon (Cocoon, keep in mind, is a _publishing_ framework, not an application framework), should handle services. So maybe take a look at Turbine, this is there, and then Turbine can certainly use Cocoon for screen processing. -Brett > > Let me know what you think. > > Mike > > ****************************** > the diffs > ****************************** > > Index: xml-cocoon/src/org/apache/cocoon/cocoon.properties > =================================================================== > RCS file: > /home/cvspublic/xml-cocoon/src/org/apache/cocoon/cocoon.properties,v > retrieving revision 1.10 > diff -r1.10 cocoon.properties > 210a211,217 > > ########################################## > > # Shared Objects/Resources # > > ########################################## > > shared.connectionPool = [class] > > shared.conf.connectionPool = [configuration] > > Index: xml-cocoon/src/org/apache/cocoon/Defaults.java > =================================================================== > RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/Defaults.java,v > retrieving revision 1.8 > diff -r1.8 Defaults.java > 89a90,92 > > public static final String SHARED_PROP = "shared"; > > public static final String SHARED_CONF = "conf"; > > > > Index: xml-cocoon/src/org/apache/cocoon/Engine.java > =================================================================== > RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/Engine.java,v > retrieving revision 1.9 > diff -r1.9 Engine.java > 174a175,191 > > > > // Create shared objects and register them > > Configurations shared = configurations.getConfigurations("shared"); > > Enumeration sharedKeys = shared.propertyNames(); > > while (sharedKeys.hasMoreElements()) > > { > > String key = (String) sharedKeys.nextElement(); > > String prop = (String) shared.get(key); > > if (! prop.endsWith(SHARED_CONF)) > > { > > String configFile = (String) > shared.getConfigurations(SHARED_CONF).get(key); > > if (configFile == null) > > manager.setRole(prop, (Actor) manager.create(prop)); > > else > > manager.setRole(prop, (Actor) manager.create(prop, new > Configurations(configFile))); > > } > > }