开发者

How to access config.xml of James from the POP3Server class?

开发者 https://www.devze.com 2023-03-20 19:06 出处:网络
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 us

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消