cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sunil.Kam...@razorfish.com
Subject Question re: configurable Producers
Date Fri, 10 Nov 2000 19:43:35 GMT


The requirement is as follows:
I want to create a set of producers, each of which handle a different piece of
business functionality. Since these producers will need certain runtime
parameters, they will implement the Configurable interface so that the
ProducerFactory can init() them appropriately.
Here is the problem:
Since these producers are going to share some parameters, I want to create an
abstract Producer which will then be extended by the business specific
Producers. Unfortunately, since the Configurations parameter which is passed to
the Producers on init() is based upon the Producer name, I will have to
duplicate this parameters for each one of them.
Examples:
Abstract Class:
public abstract class BaseProducer implements Producer, Configurable {
     protected String myBaseParam;

     public void init(Configurations conf) {
          myBaseParam = conf.get("baseparam");
          .....

          childInit();
     }

     public abstract void childInit(Configurations conf);
     ....
}

First Child Class:
public class FirstProducer extends BaseProducer {
     protected String myFirstParam;

     public void childInit(Configurations conf) {
          myFirstParam = conf.get("firstparam");
          .....
     }
     ....
}

Second Child Class:
public class SecondProducer extends BaseProducer {
     protected String mySecondParam;

     public void childInit(Configurations conf) {
          mySecondParam = conf.get("secondparam");
          .....
     }
     ....
}

cocoon.properties:
....
producers.type.first=FirstProducer
producers.type.second=SecondProducer
producers.first.baseparam="Base Param"
producers.first.firstparam="First Param"
producers.second.baseparam="Base Param"
producers.second.secondparam="Second Param"


As can be seen from the example, the baseparam property has to be specified
twice in the properties file.
Is there any way to avoid this duplication of effort and maintenance hassle?
---
Thanks,
Sunil



Mime
View raw message