cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Engelhart <mengelh...@earthtrip.com>
Subject shared object Proposal
Date Tue, 11 Jan 2000 03:40:53 GMT
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?)

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