You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Oki DZ <ok...@pindad.com> on 2001/09/25 11:25:27 UTC
Matchers/mailets as Components/Composables?
Hi,
I'd like to record the senders and recipients of the messages in a db
table. I think I'm having headaches in getting a JdbcDataSource from a
mailet. So I have to come up with the following. I know, it has problems;
getting the configuration from the config.xml file by defining the path,
for example.
public void init() {
Configuration config;
Configuration[] dataStoreConfig;
Configuration[] compConfs;
try {
configBuilder = new DefaultConfigurationBuilder();
config =
configBuilder.buildFromFile("./dist/apps/james/conf/config.xml"); //Fixme:
dataStoreConfig = config.getChildren("data-store");
compConfs = dataStoreConfig[0].getChildren();
componentSelector = new ExcaliburComponentSelector();
componentSelector.setLogger(Hierarchy.getDefaultHierarchy().getLoggerFor("data-store"));
// Fixme:
componentSelector.configure(compConfs[0]);
componentSelector.initialize();
dataSource = (JdbcDataSource)
componentSelector.select("mailetsource");
storeSQL = "insert into SenderRecipients (sender, recipients,
size) " +
"values (?, ?, ?)";
conn = (JdbcConnection) dataSource.getConnection();
ps = conn.prepareStatement(storeSQL);
} catch(Exeption e) {
//...
}
}
I think it would be nicer if the matchers and mailets in James become
Avalon Components, so that the compose(), configure(), and initialize()
would be executed by Avalon. I don't know anything better than the code
above.
Maybe there's a way to get a reference to a Block or Component from
classes which are not Avalon components. As I understand it, Avalon
components are usable if they are initialized from Avalon blocks (so that
they can have a reference to the (system's) ExcaliburComponentManager. Or
I could be just plain wrong...
BTW, building Avalon components by feeding the Configuration into the
ComponentSelector is really neat, I believe.
Oki
---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org