I am changing some parts of the James POP3Server class and inject it afterwards via IoC.
I need to configure some parts I like to use in my modifications, and I thought it would be handy if I could use the config.xml to store my settings.
POP3Server.class <-> config.xml (direct access possible?)
Is there a easy way of accessing this XML or do I ha开发者_运维技巧ve to access it somewhere deeper inside James?
Look at the code for org.apache.james.pop3server.POP3Server and find public void configure(final Configuration configuration): this handles configuration of the server with the XML from config.xml. For example, if you modify the POP3Server XML configuration block in the james-config file to look like this:
<pop3server enabled="true">
<port>110</port>
<handler>
<helloName autodetect="true">myMailServer</helloName>
<connectiontimeout>120000</connectiontimeout>
</handler>
<myconfigvariable>12</myconfigvariable>
</pop3server>
you'll be able to add a line in configure like this:
int myconfig = configuration.getChild("myconfigvariable").getValueAsInteger(25);
The 25 here is the default in the case where the config variable is missing. Let me know if that does what you want.
加载中,请稍侯......
精彩评论