如何从POP3Server类访问James的config.xml?

发布于 2024-11-24 18:34:14 字数 244 浏览 5 评论 0原文

我正在更改 James POP3Server 类的某些部分,然后通过 IoC 注入它。 我需要配置一些我喜欢在修改中使用的部分,并且我认为如果可以使用 config.xml 来存储我的设置会很方便。

POP3Server.class <-> config.xml (可以直接访问吗?)

有没有一种简单的方法来访问这个 XML 或者我必须在 James 内部更深处的地方访问它?

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 have to access it somewhere deeper inside James?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若有似无的小暗淡 2024-12-01 18:34:14

查看 org.apache.james.pop3server.POP3Server 的代码并找到 public void configure(final Configuration configuration):这使用来自 的 XML 处理服务器的配置代码>config.xml。例如,如果您将 james-config 文件中的 POP3Server XML 配置块修改为如下所示:

<pop3server enabled="true">
      <port>110</port>
      <handler>
         <helloName autodetect="true">myMailServer</helloName>
         <connectiontimeout>120000</connectiontimeout>
      </handler>
      <myconfigvariable>12</myconfigvariable>
   </pop3server>

您将能够在 configure 中添加一行,如下所示:

int myconfig = configuration.getChild("myconfigvariable").getValueAsInteger(25);

这里的 25 是缺少配置变量时的默认值。让我知道这是否符合您的要求。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文