cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett McLaughlin <bmcla...@algx.net>
Subject Re: shared object Proposal
Date Tue, 11 Jan 2000 14:05:25 GMT
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)));
> >             }
> >         }

Mime
View raw message